Class TransactionResponse

A TransactionResponse includes all properties about a transaction that was sent to the network, which may or may not be included in a block.

The [[TransactionResponse-isMined]] can be used to check if the transaction has been mined as well as type guard that the otherwise possibly null properties are defined.

Implements

  • TransactionLike<string>
  • TransactionResponseParams

Constructors

  • @_ignore:

    Parameters

    • tx: TransactionResponseParams
    • provider: Provider

    Returns TransactionResponse

Properties

provider: Provider

The provider this is connected to, which will influence how its methods will resolve its async inspection methods.

blockNumber: null | number

The block number of the block that this transaction was included in.

This is null for pending transactions.

blockHash: null | string

The blockHash of the block that this transaction was included in.

This is null for pending transactions.

index: number

The index within the block that this transaction resides at.

hash: string

The transaction hash.

type: number

The [[link-eip-2718]] transaction envelope type. This is 0 for legacy transactions types.

to: null | string

The receiver of this transaction.

If null, then the transaction is an initcode transaction. This means the result of executing the [[data]] will be deployed as a new contract on chain (assuming it does not revert) and the address may be computed using [[getCreateAddress]].

from: string

The sender of this transaction. It is implicitly computed from the transaction pre-image hash (as the digest) and the [[signature]] using ecrecover.

nonce: number

The nonce, which is used to prevent replay attacks and offer a method to ensure transactions from a given sender are explicitly ordered.

When sending a transaction, this must be equal to the number of transactions ever sent by [[from]].

gasLimit: bigint

The maximum units of gas this transaction can consume. If execution exceeds this, the entries transaction is reverted and the sender is charged for the full amount, despite not state changes being made.

gasPrice: bigint

The gas price can have various values, depending on the network.

In modern networks, for transactions that are included this is the //effective gas price// (the fee per gas that was actually charged), while for transactions that have not been included yet is the [[maxFeePerGas]].

For legacy transactions, or transactions on legacy networks, this is the fee that will be charged per unit of gas the transaction consumes.

maxPriorityFeePerGas: null | bigint

The maximum priority fee (per unit of gas) to allow a validator to charge the sender. This is inclusive of the [[maxFeeFeePerGas]].

maxFeePerGas: null | bigint

The maximum fee (per unit of gas) to allow this transaction to charge the sender.

maxFeePerBlobGas: null | bigint

The [[link-eip-4844]] max fee per BLOb gas.

data: string

The data.

value: bigint

The value, in wei. Use [[formatEther]] to format this value as ether.

chainId: bigint

The chain ID.

signature: Signature

The signature.

accessList: null | AccessList

The [[link-eip-2930]] access list for transaction types that support it, otherwise null.

blobVersionedHashes: null | string[]

The [[link-eip-4844]] BLOb versioned hashes.

Methods

  • Returns a JSON-compatible representation of this transaction.

    Returns any

  • Resolves to the Block that this transaction was included in.

    This will return null if the transaction has not been included yet.

    Returns Promise<null | Block>

  • Resolves to this transaction being re-requested from the provider. This can be used if you have an unmined transaction and wish to get an up-to-date populated instance.

    Returns Promise<null | TransactionResponse>

  • Resolve to the number of confirmations this transaction has.

    Returns Promise<number>

  • Resolves once this transaction has been mined and has %%confirms%% blocks including it (default: 1) with an optional %%timeout%%.

    This can resolve to null only if %%confirms%% is 0 and the transaction has not been mined, otherwise this will wait until enough confirmations have completed.

    Parameters

    • Optional_confirms: number
    • Optional_timeout: number

    Returns Promise<null | TransactionReceipt>

  • Returns true if this transaction has been included.

    This is effective only as of the time the TransactionResponse was instantiated. To get up-to-date information, use [[getTransaction]].

    This provides a Type Guard that this transaction will have non-null property values for properties that are null for unmined transactions.

    Returns this is MinedTransactionResponse

  • Returns true if the transaction is a legacy (i.e. type == 0) transaction.

    This provides a Type Guard that this transaction will have the null-ness for hardfork-specific properties set correctly.

    Returns this is TransactionResponse & {
        accessList: null;
        maxFeePerGas: null;
        maxPriorityFeePerGas: null;
    }

  • Returns true if the transaction is a Berlin (i.e. type == 1) transaction. See [[link-eip-2070]].

    This provides a Type Guard that this transaction will have the null-ness for hardfork-specific properties set correctly.

    Returns this is TransactionResponse & {
        accessList: AccessList;
        maxFeePerGas: null;
        maxPriorityFeePerGas: null;
    }

  • Returns true if the transaction is a London (i.e. type == 2) transaction. See [[link-eip-1559]].

    This provides a Type Guard that this transaction will have the null-ness for hardfork-specific properties set correctly.

    Returns this is TransactionResponse & {
        accessList: AccessList;
        maxFeePerGas: bigint;
        maxPriorityFeePerGas: bigint;
    }

  • Returns true if hte transaction is a Cancun (i.e. type == 3) transaction. See [[link-eip-4844]].

    Returns this is TransactionResponse & {
        accessList: AccessList;
        maxFeePerGas: bigint;
        maxPriorityFeePerGas: bigint;
        maxFeePerBlobGas: bigint;
        blobVersionedHashes: string[];
    }

  • Returns a filter which can be used to listen for orphan events that evict this transaction.

    Returns OrphanFilter

  • Returns a filter which can be used to listen for orphan events that re-order this event against %%other%%.

    Parameters

    Returns OrphanFilter

  • Returns a new TransactionResponse instance which has the ability to detect (and throw an error) if the transaction is replaced, which will begin scanning at %%startBlock%%.

    This should generally not be used by developers and is intended primarily for internal use. Setting an incorrect %%startBlock%% can have devastating performance consequences if used incorrectly.

    Parameters

    • startBlock: number

    Returns TransactionResponse

""