The TransactionsModule handles transaction related operations and provides convenient methods for sending transactions and waiting for transaction confirmation.

Constructors

Properties

blocksModule: BlocksModule
debugModule: DebugModule
forkDetector: ForkDetector
gasModule: GasModule
logsModule: LogsModule

Methods

  • Builds a transaction body with the given clauses without having to specify the chainTag, expiration, gasPriceCoef, gas, dependsOn and reserved fields.

    Parameters

    • clauses: TransactionClause[]

      The clauses of the transaction.

    • gas: number

      The gas to be used to perform the transaction.

    • Optionaloptions: TransactionBodyOptions

      Optional parameters for the request. Includes the expiration, gasPriceCoef, maxFeePErGas, maxPriorityFeePerGas, dependsOn and isDelegated fields. If the expiration is not specified, the transaction will expire after 32 blocks. If the gasPriceCoef is not specified & galactica fork didn't happen yet, the transaction will use the default gas price coef of 0. If the gasPriceCoef is not specified & galactica fork happened, the transaction will use the default maxFeePerGas and maxPriorityFeePerGas. If the dependsOn is not specified, the transaction will not depend on any other transaction. If the isDelegated is not specified, the transaction will not be delegated.

    Returns Promise<TransactionBody>

    A promise that resolves to the transaction body.

    an error if the genesis block or the latest block cannot be retrieved.

  • Decode the revert reason from the encoded revert reason into a transaction.

    Parameters

    • encodedRevertReason: string

      The encoded revert reason to decode.

    • OptionalerrorFragment: string

      (Optional) The error fragment to use to decode the revert reason (For Solidity custom errors).

    Returns string

    A promise that resolves to the decoded revert reason. Revert reason can be a string error or Panic(error_code)

  • Estimates the amount of gas required to execute a set of transaction clauses.

    Parameters

    • clauses: TransactionClause[]

      An array of clauses to be simulated. Must contain at least one clause.

    • Optionalcaller: string

      The address initiating the transaction. Optional.

    • Optionaloptions: EstimateGasOptions

      Additional options for the estimation, including gas padding.

    Returns Promise<EstimateGasResult>

    • The estimated gas result, including total gas required, whether the transaction reverted, revert reasons, and any VM errors.
    • If clauses array is empty or if gas padding is not within the range (0, 1].
  • Executes a read-only call to a smart contract function, simulating the transaction to obtain the result.

    The method simulates a transaction using the provided parameters without submitting it to the blockchain, allowing read-only operations to be tested without incurring gas costs or modifying the blockchain state.

    Parameters

    • contractAddress: string

      The address of the smart contract.

    • functionAbi: ABIFunction<Abi, string>

      The ABI definition of the smart contract function to be called.

    • functionData: unknown[]

      The arguments to be passed to the smart contract function.

    • OptionalcontractCallOptions: ContractCallOptions

      Optional parameters for the contract call execution.

    Returns Promise<ContractCallResult>

    The result of the contract call.

  • Fills the transaction body with the default options.

    Parameters

    • body: TransactionBody

      The transaction body to fill.

    Returns Promise<TransactionBody>

    A promise that resolves to the filled transaction body.

  • Retrieves the base gas price from the blockchain parameters.

    This method sends a call to the blockchain parameters contract to fetch the current base gas price. The base gas price is the minimum gas price that can be used for a transaction. It is used to obtain the VTHO (energy) cost of a transaction.

    Returns Promise<ContractCallResult>

    A promise that resolves to the result of the contract call, containing the base gas price.

  • Get the revert reason of an existing transaction.

    Parameters

    • transactionHash: string

      The hash of the transaction to get the revert reason for.

    • OptionalerrorFragment: string

      (Optional) The error fragment to use to decode the revert reason (For Solidity custom errors).

    Returns Promise<string>

    A promise that resolves to the revert reason of the transaction.

  • Ensures that names in clauses are resolved to addresses

    Parameters

    • clauses: TransactionClause[]

      The clauses of the transaction.

    Returns Promise<TransactionClause[]>

    A promise that resolves to clauses with resolved addresses

  • Simulates the execution of a transaction. Allows to estimate the gas cost of a transaction without sending it, as well as to retrieve the return value(s) of the transaction.

    Parameters

    • clauses: TransactionClause[]

      The clauses of the transaction to simulate.

    • Optionaloptions: SimulateTransactionOptions

      (Optional) The options for simulating the transaction.

    Returns Promise<TransactionSimulationResult[]>

    A promise that resolves to an array of simulation results. Each element of the array represents the result of simulating a clause.

  • Waits for a transaction to be included in a block.

    Parameters

    • txID: string

      The transaction ID of the transaction to wait for.

    • Optionaloptions: WaitForTransactionOptions

      Optional parameters for the request. Includes the timeout and interval between requests. Both parameters are in milliseconds. If the timeout is not specified, the request will not time out!

    Returns Promise<TransactionReceipt>

    A promise that resolves to the transaction receipt of the transaction. If the transaction is not included in a block before the timeout, the promise will resolve to null.