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: PublicAddress
The public address of the external account which signed this transaction
nonce: u64
The 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: u64
The maximum number of gas units (ref.) that should be used in executing this transaction
max_base_fee_per_gas: u64
The maximum number of grays that the signer is willing to burn for a gas unit used in this transaction
priority_fee_per_gas: u64
the number of grays that the signer is willing to pay the block proposer for including this transaction in a block
signature: SignatureBytes
the signature formed by signing over content of this transaction by using the signer’s private key
hash: Sha256Hash
The 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 Transaction
impl BorshDeserialize for Transaction
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 Transaction
impl BorshSerialize for Transaction
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more