Skip to main content

FeeMarketEIP1559Transaction

Typed transaction with a new gas fee market mechanism

Hierarchy

Index

Constructors

publicconstructor

  • This constructor takes the values, validates them, assigns them and freezes the object.

    It is not recommended to use this constructor directly. Instead use the static factory methods to assist in creating a Transaction object from varying data types.


    Parameters

    Returns FeeMarketEIP1559Transaction

Properties

publicreadonlyAccessListJSON

AccessListJSON: AccessList

publicreadonlyaccessList

publicreadonlychainId

chainId: bigint

publicreadonlycommon

common: Common

publicreadonlydata

data: Uint8Array

publicreadonlygasLimit

gasLimit: bigint

publicreadonlymaxFeePerGas

maxFeePerGas: bigint

publicreadonlymaxPriorityFeePerGas

maxPriorityFeePerGas: bigint

publicreadonlynonce

nonce: bigint

publicoptionalreadonlyr

r?: bigint

publicoptionalreadonlys

s?: bigint

publicoptionalreadonlyto

to?: Address

publicoptionalreadonlyv

v?: bigint

publicreadonlyvalue

value: bigint

Accessors

publictype

  • get type(): number
  • Returns the transaction type.

    Note: legacy txs will return tx type 0.


    Returns number

Methods

public_processSignature

publicerrorStr

  • errorStr(): string
  • Return a compact error string representation of the object


    Returns string

publicgetBaseFee

  • getBaseFee(): bigint
  • The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)


    Returns bigint

publicgetDataFee

  • getDataFee(): bigint
  • The amount of gas paid for the data in this tx


    Returns bigint

publicgetMessageToSign

  • getMessageToSign(hashMessage?: boolean): Uint8Array
  • Returns the serialized unsigned tx (hashed or raw), which can be used to sign the transaction (e.g. for sending to a hardware wallet).

    Note: in contrast to the legacy tx the raw message format is already serialized and doesn't need to be RLP encoded any more.

    const serializedMessage = tx.getMessageToSign(false) // use this for the HW wallet input

    Parameters

    • hashMessage: boolean = true

      Return hashed message if set to true (default: true)

    Returns Uint8Array

publicgetMessageToVerifySignature

  • getMessageToVerifySignature(): Uint8Array
  • Computes a sha3-256 hash which can be used to verify the signature


    Returns Uint8Array

publicgetSenderAddress

  • getSenderAddress(): Address
  • Returns the sender's address


    Returns Address

publicgetSenderPublicKey

  • getSenderPublicKey(): Uint8Array
  • Returns the public key of the sender


    Returns Uint8Array

publicgetUpfrontCost

  • getUpfrontCost(baseFee?: bigint): bigint
  • The up front amount that an account must have for this transaction to be valid


    Parameters

    • baseFee: bigint = ...

      The base fee of the block (will be set to 0 if not provided)

    Returns bigint

publichash

  • hash(): Uint8Array
  • Computes a sha3-256 hash of the serialized tx.

    This method can only be used for signed txs (it throws otherwise). Use FeeMarketEIP1559Transaction.getMessageToSign to get a tx hash for the purpose of signing.


    Returns Uint8Array

publicisSigned

  • isSigned(): boolean
  • Returns boolean

publicraw

  • Returns a Uint8Array Array of the raw Uint8Arrays of the EIP-1559 transaction, in order.

    Format:

    [chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
    accessList, signatureYParity, signatureR, signatureS]

    Use FeeMarketEIP1559Transaction.serialize to add a transaction to a block with Block.fromValuesArray.

    For an unsigned tx this method uses the empty Uint8Array values for the signature parameters v, r and s for encoding. For an EIP-155 compliant representation for external signing use FeeMarketEIP1559Transaction.getMessageToSign.


    Returns FeeMarketEIP1559ValuesArray

publicserialize

  • serialize(): Uint8Array
  • Returns the serialized encoding of the EIP-1559 transaction.

    Format:

    0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
    accessList, signatureYParity, signatureR, signatureS])

    Note that in contrast to the legacy tx serialization format this is not valid RLP any more due to the raw tx type preceding and concatenated to the RLP encoding of the values.


    Returns Uint8Array

publicsign

  • Signs a transaction.

    Note that the signed tx is returned as a new object, use as follows:

    const signedTx = tx.sign(privateKey)

    Parameters

    • privateKey: Uint8Array

    Returns FeeMarketEIP1559Transaction

publicsupports

  • Checks if a tx type defining capability is active on a tx, for example the EIP-1559 fee market mechanism or the EIP-2930 access list feature.

    Note that this is different from the tx type itself, so EIP-2930 access lists can very well be active on an EIP-1559 tx for example.

    This method can be useful for feature checks if the tx type is unknown (e.g. when instantiated with the tx factory).

    See Capabilites in the types module for a reference on all supported capabilities.


    Parameters

    Returns boolean

publictoCreationAddress

  • toCreationAddress(): boolean
  • If the tx's to is to the creation address


    Returns boolean

publictoJSON

  • Returns an object with the JSON representation of the transaction


    Returns JsonTx

publicvalidate

  • validate(): boolean
  • validate(stringError: false): boolean
  • validate(stringError: true): string[]
  • Checks if the transaction has the minimum amount of gas required (DataFee + TxFee + Creation Fee).


    Returns boolean

publicverifySignature

  • verifySignature(): boolean
  • Determines if the signature is valid


    Returns boolean

publicstaticfromSerializedTx

  • Instantiate a transaction from the serialized tx.

    Format:

    0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
    accessList, signatureYParity, signatureR, signatureS])


    Parameters

    Returns FeeMarketEIP1559Transaction

publicstaticfromTxData

  • Instantiate a transaction from a data dictionary.

    Format: { chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, v, r, s }

    Notes:

    • chainId will be set automatically if not provided
    • All parameters are optional and have some basic default values

    Parameters

    Returns FeeMarketEIP1559Transaction

publicstaticfromValuesArray