Struct 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:

  1. Using the constructor function: this takes in the user-provided fields of a transaction and computes its signature and hash automatically.
  2. 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

Source

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

Source

pub fn is_cryptographically_correct( &self, ) -> Result<(), CryptographicallyIncorrectTransactionError>

Check whether the Transaction’s:

  1. Signer is a valid Ed25519 public key.
  2. Signature is a valid Ed25519 signature.
  3. Signature is produced by the signer over the intermediate transaction.
  4. Hash is the SHA256 hash over the signature.

Trait Implementations§

Source§

impl BorshDeserialize for Transaction

Source§

fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for Transaction

Source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl Clone for Transaction

Source§

fn clone(&self) -> Transaction

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transaction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deserializable for Transaction

Source§

fn deserialize(args: &[u8]) -> Result<Self, Error>

Source§

impl PartialEq for Transaction

Source§

fn eq(&self, other: &Transaction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serializable for Transaction

Source§

fn serialize(&self) -> Vec<u8>

Source§

impl Eq for Transaction

Source§

impl StructuralPartialEq for Transaction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V