ethereumjs-monorepo

@ethereumjs/tx / FeeMarketEIP1559Transaction

Class: FeeMarketEIP1559Transaction

Typed transaction with a new gas fee market mechanism

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new FeeMarketEIP1559Transaction(txData, opts?)

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

Name Type
txData FeeMarketEIP1559TxData
opts TxOptions

Overrides

BaseTransaction<TransactionType.FeeMarketEIP1559\>.constructor

Defined in

tx/src/eip1559Transaction.ts:150

Properties

AccessListJSON

Readonly AccessListJSON: AccessList

Defined in

tx/src/eip1559Transaction.ts:46


accessList

Readonly accessList: AccessListBytes

Defined in

tx/src/eip1559Transaction.ts:45


cache

cache: TransactionCache

Inherited from

BaseTransaction.cache

Defined in

tx/src/baseTransaction.ts:54


chainId

Readonly chainId: bigint

Defined in

tx/src/eip1559Transaction.ts:44


common

Readonly common: Common

Overrides

BaseTransaction.common

Defined in

tx/src/eip1559Transaction.ts:50


data

Readonly data: Uint8Array

Inherited from

BaseTransaction.data

Defined in

tx/src/baseTransaction.ts:46


gasLimit

Readonly gasLimit: bigint

Inherited from

BaseTransaction.gasLimit

Defined in

tx/src/baseTransaction.ts:43


maxFeePerGas

Readonly maxFeePerGas: bigint

Defined in

tx/src/eip1559Transaction.ts:48


maxPriorityFeePerGas

Readonly maxPriorityFeePerGas: bigint

Defined in

tx/src/eip1559Transaction.ts:47


nonce

Readonly nonce: bigint

Inherited from

BaseTransaction.nonce

Defined in

tx/src/baseTransaction.ts:42


r

Optional Readonly r: bigint

Inherited from

BaseTransaction.r

Defined in

tx/src/baseTransaction.ts:49


s

Optional Readonly s: bigint

Inherited from

BaseTransaction.s

Defined in

tx/src/baseTransaction.ts:50


to

Optional Readonly to: Address

Inherited from

BaseTransaction.to

Defined in

tx/src/baseTransaction.ts:44


v

Optional Readonly v: bigint

Inherited from

BaseTransaction.v

Defined in

tx/src/baseTransaction.ts:48


value

Readonly value: bigint

Inherited from

BaseTransaction.value

Defined in

tx/src/baseTransaction.ts:45

Accessors

type

get type(): TransactionType

Returns the transaction type.

Note: legacy txs will return tx type 0.

Returns

TransactionType

Inherited from

BaseTransaction.type

Defined in

tx/src/baseTransaction.ts:121

Methods

addSignature

addSignature(v, r, s, convertV?): FeeMarketEIP1559Transaction

Parameters

Name Type Default value
v bigint undefined
r bigint | Uint8Array undefined
s bigint | Uint8Array undefined
convertV boolean false

Returns

FeeMarketEIP1559Transaction

Overrides

BaseTransaction.addSignature

Defined in

tx/src/eip1559Transaction.ts:319


errorStr

errorStr(): string

Return a compact error string representation of the object

Returns

string

Overrides

BaseTransaction.errorStr

Defined in

tx/src/eip1559Transaction.ts:367


getBaseFee

getBaseFee(): bigint

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

Returns

bigint

Inherited from

BaseTransaction.getBaseFee

Defined in

tx/src/baseTransaction.ts:176


getDataFee

getDataFee(): bigint

The amount of gas paid for the data in this tx

Returns

bigint

Overrides

BaseTransaction.getDataFee

Defined in

tx/src/eip1559Transaction.ts:205


getEffectivePriorityFee

getEffectivePriorityFee(baseFee): bigint

Returns the minimum of calculated priority fee (from maxFeePerGas and baseFee) and maxPriorityFeePerGas

Parameters

Name Type Description
baseFee bigint Base fee retrieved from block

Returns

bigint

Overrides

BaseTransaction.getEffectivePriorityFee

Defined in

tx/src/eip1559Transaction.ts:213


getHashedMessageToSign

getHashedMessageToSign(): Uint8Array

Returns the hashed serialized unsigned tx, 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.

Returns

Uint8Array

Overrides

BaseTransaction.getHashedMessageToSign

Defined in

tx/src/eip1559Transaction.ts:291


getMessageToSign

getMessageToSign(): Uint8Array

Returns the raw serialized unsigned tx, 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() // use this for the HW wallet input

Returns

Uint8Array

Overrides

BaseTransaction.getMessageToSign

Defined in

tx/src/eip1559Transaction.ts:280


getMessageToVerifySignature

getMessageToVerifySignature(): Uint8Array

Computes a sha3-256 hash which can be used to verify the signature

Returns

Uint8Array

Overrides

BaseTransaction.getMessageToVerifySignature

Defined in

tx/src/eip1559Transaction.ts:308


getSenderAddress

getSenderAddress(): Address

Returns the sender’s address

Returns

Address

Inherited from

BaseTransaction.getSenderAddress

Defined in

tx/src/baseTransaction.ts:279


getSenderPublicKey

getSenderPublicKey(): Uint8Array

Returns the public key of the sender

Returns

Uint8Array

Overrides

BaseTransaction.getSenderPublicKey

Defined in

tx/src/eip1559Transaction.ts:315


getUpfrontCost

getUpfrontCost(baseFee?): bigint

The up front amount that an account must have for this transaction to be valid

Parameters

Name Type Default value Description
baseFee bigint BIGINT_0 The base fee of the block (will be set to 0 if not provided)

Returns

bigint

Overrides

BaseTransaction.getUpfrontCost

Defined in

tx/src/eip1559Transaction.ts:221


getValidationErrors

getValidationErrors(): string[]

Validates the transaction signature and minimum gas requirements.

Returns

string[]

an array of error strings

Inherited from

BaseTransaction.getValidationErrors

Defined in

tx/src/baseTransaction.ts:149


hash

hash(): Uint8Array

Computes a sha3-256 hash of the serialized tx.

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

Returns

Uint8Array

Overrides

BaseTransaction.hash

Defined in

tx/src/eip1559Transaction.ts:301


isSigned

isSigned(): boolean

Returns

boolean

Inherited from

BaseTransaction.isSigned

Defined in

tx/src/baseTransaction.ts:254


isValid

isValid(): boolean

Validates the transaction signature and minimum gas requirements.

Returns

boolean

true if the transaction is valid, false otherwise

Inherited from

BaseTransaction.isValid

Defined in

tx/src/baseTransaction.ts:167


raw

raw(): FeeMarketEIP1559TxValuesArray

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

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

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

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

Returns

FeeMarketEIP1559TxValuesArray

Overrides

BaseTransaction.raw

Defined in

tx/src/eip1559Transaction.ts:238


serialize

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

Overrides

BaseTransaction.serialize

Defined in

tx/src/eip1559Transaction.ts:265


sign

sign(privateKey): FeeMarketEIP1559Transaction

Signs a transaction.

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

const signedTx = tx.sign(privateKey)

Parameters

Name Type
privateKey Uint8Array

Returns

FeeMarketEIP1559Transaction

Inherited from

BaseTransaction.sign

Defined in

tx/src/baseTransaction.ts:297


supports

supports(capability): boolean

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 Capabilities in the types module for a reference on all supported capabilities.

Parameters

Name Type
capability Capability

Returns

boolean

Inherited from

BaseTransaction.supports

Defined in

tx/src/baseTransaction.ts:141


toCreationAddress

toCreationAddress(): boolean

If the tx’s to is to the creation address

Returns

boolean

Inherited from

BaseTransaction.toCreationAddress

Defined in

tx/src/baseTransaction.ts:223


toJSON

toJSON(): JsonTx

Returns an object with the JSON representation of the transaction

Returns

JsonTx

Overrides

BaseTransaction.toJSON

Defined in

tx/src/eip1559Transaction.ts:351


verifySignature

verifySignature(): boolean

Determines if the signature is valid

Returns

boolean

Inherited from

BaseTransaction.verifySignature

Defined in

tx/src/baseTransaction.ts:266


fromSerializedTx

Static fromSerializedTx(serialized, opts?): FeeMarketEIP1559Transaction

Instantiate a transaction from the serialized tx.

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

Parameters

Name Type
serialized Uint8Array
opts TxOptions

Returns

FeeMarketEIP1559Transaction

Defined in

tx/src/eip1559Transaction.ts:72


fromTxData

Static fromTxData(txData, opts?): FeeMarketEIP1559Transaction

Instantiate a transaction from a data dictionary.

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

Notes:

Parameters

Name Type
txData FeeMarketEIP1559TxData
opts TxOptions

Returns

FeeMarketEIP1559Transaction

Defined in

tx/src/eip1559Transaction.ts:62


fromValuesArray

Static fromValuesArray(values, opts?): FeeMarketEIP1559Transaction

Create a transaction from a values array.

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

Parameters

Name Type
values FeeMarketEIP1559TxValuesArray
opts TxOptions

Returns

FeeMarketEIP1559Transaction

Defined in

tx/src/eip1559Transaction.ts:99