Skip to main content

abstractBaseTransaction <TransactionObject>

This base class will likely be subject to further refactoring along the introduction of additional tx types on the Ethereum network.

It is therefore not recommended to use directly.

Hierarchy

Index

Constructors

publicconstructor

Properties

publicreadonlycommon

common: Common

publicreadonlydata

data: Uint8Array

publicreadonlygasLimit

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

publicabstracterrorStr

  • 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

publicabstractgetMessageToSign

  • getMessageToSign(hashMessage: false): Uint8Array | Uint8Array[]
  • getMessageToSign(hashMessage?: true): Uint8Array
  • Parameters

    • hashMessage: false

    Returns Uint8Array | Uint8Array[]

publicabstractgetMessageToVerifySignature

  • getMessageToVerifySignature(): Uint8Array
  • Returns Uint8Array

publicgetSenderAddress

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


    Returns Address

publicabstractgetSenderPublicKey

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


    Returns Uint8Array

publicabstractgetUpfrontCost

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


    Returns bigint

publicabstracthash

  • hash(): Uint8Array
  • Returns Uint8Array

publicisSigned

  • isSigned(): boolean
  • Returns boolean

publicabstractraw

  • Returns a Uint8Array Array of the raw Uint8Arrays of this transaction, in order.

    Use BaseTransaction.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 BaseTransaction.getMessageToSign.


    Returns FeeMarketEIP1559ValuesArray | AccessListEIP2930ValuesArray | TxValuesArray

publicabstractserialize

  • serialize(): Uint8Array
  • Returns the encoding of the transaction.


    Returns Uint8Array

publicsign

  • sign(privateKey: Uint8Array): TransactionObject
  • 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 TransactionObject

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

publicabstracttoJSON

  • 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

  • fromSerializedTx(serialized: Uint8Array, opts?: TxOptions): any
  • Parameters

    Returns any

publicstaticfromTxData

  • fromTxData(txData: any, opts?: TxOptions): any
  • Parameters

    Returns any