Represents an immutable transaction entity.

Constructors

Properties

It represents the content of the transaction.

signature?: Uint8Array

It represents the signature of the transaction content.

transactionType: TransactionType

It represents the type of the transaction.

GAS_CONSTANTS: {
    CLAUSE_GAS: bigint;
    CLAUSE_GAS_CONTRACT_CREATION: bigint;
    NON_ZERO_GAS_DATA: bigint;
    TX_GAS: bigint;
    ZERO_GAS_DATA: bigint;
} = ...

A collection of constants used for gas calculations in transactions.

Properties

  • TX_GAS - The base gas cost for a transaction.
  • CLAUSE_GAS - The gas cost for executing a clause in a transaction.
  • CLAUSE_GAS_CONTRACT_CREATION - The gas cost for creating a contract via a clause.
  • ZERO_GAS_DATA - The gas cost for transmitting zero bytes of data.
  • NON_ZERO_GAS_DATA - The gas cost for transmitting non-zero bytes of data.

Accessors

  • get id(): Blake2b256
  • Get transaction ID.

    The ID is the Blake2b256 hash of the transaction's signature concatenated with the origin's address. If the transaction is not signed, it throws an UnavailableTransactionField error.

    Returns Blake2b256

    The concatenated hash of the signature and origin if the transaction is signed.

    If the transaction is not signed.

    Security auditable method, depends on

  • get origin(): Address
  • Return the origin (also known as sender) address of the transaction.

    The origin is determined by recovering the public key from the transaction's sender.

    Returns Address

    The address derived from the public key of the transaction's sender.

    If the transaction is not signed, an exception is thrown indicating the absence of the origin field.

    Security auditable method, depends on

Methods

  • Computes the transaction hash, optionally incorporating a gas payer's address.

    Parameters

    • Optionalsender: Address

      Optional transaction origin's address to include in the hash computation.

    Returns Blake2b256

    • The computed transaction hash.

    sender is used to sign a transaction on behalf of another account.

  • Signs a transaction as a gas payer using the provided private key. This is applicable only if the transaction has been marked as delegated and already contains the signature of the transaction sender that needs to be extended with the gas payer's signature.

    Parameters

    • sender: Address

      The address of the sender for whom the transaction hash is generated.

    • gasPayerPrivateKey: Uint8Array

      The private key of the gas payer. Must be a valid secp256k1 key.

    Returns Transaction

    • A new transaction object with the gas payer's signature appended.

    If the provided gas payer private key is not valid.

    If the transaction is unsigned or lacks a valid signature.

    If the transaction is not set as delegated.

    Security auditable method, depends on

  • Signs a delegated transaction using the provided transaction sender's private key, call the signAsGasPayer to complete the signature, before such call isDelegated returns true but isSigned returns false.

    Parameters

    • senderPrivateKey: Uint8Array

      The private key of the transaction sender, represented as a Uint8Array. It must be a valid secp256k1 private key.

    Returns Transaction

    A new Transaction object with the signature applied, if the transaction is delegated and the private key is valid.

    NotDelegatedTransaction if the current transaction is not marked as delegated, instructing to use the regular sign method instead.

    InvalidSecp256k1PrivateKey if the provided senderPrivateKey is not a valid secp256k1 private key.

    Security auditable method, depends on

  • Signs the transaction using both the transaction sender and the gas payer private keys.

    Parameters

    • senderPrivateKey: Uint8Array

      The private key of the transaction sender.

    • gasPayerPrivateKey: Uint8Array

      The private key of the gas payer.

    Returns Transaction

    A new transaction with the concatenated signatures of the transaction sender and the gas payer.

    • If either the private key of the transaction sender or gas payer is invalid.
    • If the transaction is not delegated.

    Security auditable method, depends on

  • Decodes a raw transaction byte array into a new Transaction object.

    Parameters

    • rawTransaction: Uint8Array

      The raw transaction bytes to decode.

    • isSigned: boolean

      Flag indicating if the transaction is signed.

    Returns Transaction

    The decoded transaction object.

    encoded

  • Calculates the intrinsic gas required for the given transaction clauses.

    Parameters

    • clauses: TransactionClause[]

      An array of transaction clauses to calculate the intrinsic gas for.

    Returns VTHO

    The total intrinsic gas required for the provided clauses.

    If clauses have invalid data as invalid addresses.