Struct pchain_types::blockchain::Transaction
source · pub struct Transaction {
pub signer: PublicAddress,
pub nonce: u64,
pub commands: Vec<Command>,
pub gas_limit: u64,
pub max_base_fee_per_gas: u64,
pub priority_fee_per_gas: u64,
pub signature: SignatureBytes,
pub hash: Sha256Hash,
}Expand description
Digitally signed instructions that tell the ParallelChain state machine to execute a sequence of commands.
Creating a Transaction
There are two ways of creating an instance of transaction:
- Using the constructor function: this takes in the user-provided fields of a transaction and computes its signature and hash automatically.
- Using a struct expression (i.e.,
Transaction { signer: ..., }): this does not check the signature and hash fields.
Fields§
§signer: PublicAddressThe public address of the external account which signed this transaction
nonce: u64The number of transactions signed by the signer that have been included on the blockchain before this transaction. This ensures that all of the signer’s transactions are included in the blockchain in an expected order, and prevents the same transaction from being included in multiple blocks.
commands: Vec<Command>A list of execution commands that triggers a sequence of state transitions
gas_limit: u64The maximum number of gas units (ref.) that should be used in executing this transaction
max_base_fee_per_gas: u64The maximum number of grays that the signer is willing to burn for a gas unit used in this transaction
priority_fee_per_gas: u64the number of grays that the signer is willing to pay the block proposer for including this transaction in a block
signature: SignatureBytesthe signature formed by signing over content of this transaction by using the signer’s private key
hash: Sha256HashThe cryptographic hash of signature
Implementations§
source§impl Transaction
impl Transaction
pub fn new( signer: &Keypair, nonce: u64, commands: Vec<Command>, gas_limit: u64, max_base_fee_per_gas: u64, priority_fee_per_gas: u64 ) -> Transaction
sourcepub fn is_cryptographically_correct(
&self
) -> Result<(), CryptographicallyIncorrectTransactionError>
pub fn is_cryptographically_correct( &self ) -> Result<(), CryptographicallyIncorrectTransactionError>
Check whether the Transaction’s:
- Signer is a valid Ed25519 public key.
- Signature is a valid Ed25519 signature.
- Signature is produced by the signer over the intermediate transaction.
- Hash is the SHA256 hash over the signature.
Trait Implementations§
source§impl BorshDeserialize for Transactionwhere
PublicAddress: BorshDeserialize,
u64: BorshDeserialize,
Vec<Command>: BorshDeserialize,
SignatureBytes: BorshDeserialize,
Sha256Hash: BorshDeserialize,
impl BorshDeserialize for Transactionwhere PublicAddress: BorshDeserialize, u64: BorshDeserialize, Vec<Command>: BorshDeserialize, SignatureBytes: BorshDeserialize, Sha256Hash: BorshDeserialize,
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where R: Read,
source§impl BorshSerialize for Transactionwhere
PublicAddress: BorshSerialize,
u64: BorshSerialize,
Vec<Command>: BorshSerialize,
SignatureBytes: BorshSerialize,
Sha256Hash: BorshSerialize,
impl BorshSerialize for Transactionwhere PublicAddress: BorshSerialize, u64: BorshSerialize, Vec<Command>: BorshSerialize, SignatureBytes: BorshSerialize, Sha256Hash: BorshSerialize,
source§impl Clone for Transaction
impl Clone for Transaction
source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Transaction
impl Debug for Transaction
source§impl Deserializable for Transaction
impl Deserializable for Transaction
source§impl PartialEq<Transaction> for Transaction
impl PartialEq<Transaction> for Transaction
source§fn eq(&self, other: &Transaction) -> bool
fn eq(&self, other: &Transaction) -> bool
self and other values to be equal, and is used
by ==.