ethereumjs-monorepo

@ethereumjs/tx


@ethereumjs/tx / EOACode7702Tx

Class: EOACode7702Tx

Defined in: 7702/tx.ts:54

Typed transaction with the ability to set codes on EOA accounts

Implements

Constructors

Constructor

new EOACode7702Tx(txData, opts): EOACode7702Tx

Defined in: 7702/tx.ts:96

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

txData

EOACode7702TxData

opts

TxOptions = {}

Returns

EOACode7702Tx

Properties

accessList

readonly accessList: AccessListBytes

Defined in: 7702/tx.ts:63


authorizationList

readonly authorizationList: AuthorizationListBytes

Defined in: 7702/tx.ts:64


cache

readonly cache: TransactionCache = {}

Defined in: 7702/tx.ts:80

Implementation of

TransactionInterface.cache


chainId

readonly chainId: bigint

Defined in: 7702/tx.ts:65


common

readonly common: Common

Defined in: 7702/tx.ts:76

Implementation of

TransactionInterface.common


data

readonly data: Uint8Array

Defined in: 7702/tx.ts:61

Implementation of

TransactionInterface.data


gasLimit

readonly gasLimit: bigint

Defined in: 7702/tx.ts:59

Implementation of

TransactionInterface.gasLimit


maxFeePerGas

readonly maxFeePerGas: bigint

Defined in: 7702/tx.ts:67


maxPriorityFeePerGas

readonly maxPriorityFeePerGas: bigint

Defined in: 7702/tx.ts:66


nonce

readonly nonce: bigint

Defined in: 7702/tx.ts:58

Implementation of

TransactionInterface.nonce


r?

readonly optional r: bigint

Defined in: 7702/tx.ts:71

Implementation of

TransactionInterface.r


s?

readonly optional s: bigint

Defined in: 7702/tx.ts:72

Implementation of

TransactionInterface.s


to?

readonly optional to: Address

Defined in: 7702/tx.ts:62

Implementation of

TransactionInterface.to


txOptions

readonly txOptions: TxOptions

Defined in: 7702/tx.ts:78

Implementation of

TransactionInterface.txOptions


type

type: 4 = TransactionType.EOACodeEIP7702

Defined in: 7702/tx.ts:55

Implementation of

TransactionInterface.type


v?

readonly optional v: bigint

Defined in: 7702/tx.ts:70

Implementation of

TransactionInterface.v


value

readonly value: bigint

Defined in: 7702/tx.ts:60

Implementation of

TransactionInterface.value

Methods

addSignature()

addSignature(v, r, s): EOACode7702Tx

Defined in: 7702/tx.ts:331

Parameters

v

bigint

r
bigint Uint8Array<ArrayBufferLike>
s
bigint Uint8Array<ArrayBufferLike>

Returns

EOACode7702Tx

Implementation of

TransactionInterface.addSignature


errorStr()

errorStr(): string

Defined in: 7702/tx.ts:409

Return a compact error string representation of the object

Returns

string

Implementation of

TransactionInterface.errorStr


getDataGas()

getDataGas(): bigint

Defined in: 7702/tx.ts:198

The amount of gas paid for the data in this tx

Returns

bigint

Implementation of

TransactionInterface.getDataGas


getEffectivePriorityFee()

getEffectivePriorityFee(baseFee): bigint

Defined in: 7702/tx.ts:206

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

Parameters

baseFee

bigint

Base fee retrieved from block

Returns

bigint


getHashedMessageToSign()

getHashedMessageToSign(): Uint8Array

Defined in: 7702/tx.ts:303

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

Implementation of

TransactionInterface.getHashedMessageToSign


getIntrinsicGas()

getIntrinsicGas(): bigint

Defined in: 7702/tx.ts:224

The minimum gas limit which the tx to have to be valid. This covers costs as the standard fee (21000 gas), the data fee (paid for each calldata byte), the optional creation fee (if the transaction creates a contract), and if relevant the gas to be paid for access lists (EIP-2930) and authority lists (EIP-7702).

Returns

bigint

Implementation of

TransactionInterface.getIntrinsicGas


getMessageToSign()

getMessageToSign(): Uint8Array

Defined in: 7702/tx.ts:292

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

Implementation of

TransactionInterface.getMessageToSign


getMessageToVerifySignature()

getMessageToVerifySignature(): Uint8Array

Defined in: 7702/tx.ts:320

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

Returns

Uint8Array

Implementation of

TransactionInterface.getMessageToVerifySignature


getSenderAddress()

getSenderAddress(): Address

Defined in: 7702/tx.ts:389

Returns

Address

Implementation of

TransactionInterface.getSenderAddress


getSenderPublicKey()

getSenderPublicKey(): Uint8Array

Defined in: 7702/tx.ts:327

Returns the public key of the sender

Returns

Uint8Array

Implementation of

TransactionInterface.getSenderPublicKey


getUpfrontCost()

getUpfrontCost(baseFee): bigint

Defined in: 7702/tx.ts:214

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

Parameters

baseFee

bigint = BIGINT_0

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

Returns

bigint

Implementation of

TransactionInterface.getUpfrontCost


getValidationErrors()

getValidationErrors(): string[]

Defined in: 7702/tx.ts:377

Returns

string[]

Implementation of

TransactionInterface.getValidationErrors


hash()

hash(): Uint8Array

Defined in: 7702/tx.ts:313

Computes a sha3-256 hash of the serialized tx.

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

Returns

Uint8Array

Implementation of

TransactionInterface.hash


isSigned()

isSigned(): boolean

Defined in: 7702/tx.ts:397

Returns

boolean

Implementation of

TransactionInterface.isSigned


isValid()

isValid(): boolean

Defined in: 7702/tx.ts:381

Returns

boolean

Implementation of

TransactionInterface.isValid


raw()

raw(): EOACode7702TxValuesArray

Defined in: 7702/tx.ts:249

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

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

Use EOACode7702Transaction.serialize to add a transaction to a block with createBlockFromBytesArray.

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 EOACode7702Transaction.getMessageToSign.

Returns

EOACode7702TxValuesArray

Implementation of

TransactionInterface.raw


serialize()

serialize(): Uint8Array

Defined in: 7702/tx.ts:277

Returns the serialized encoding of the EIP-7702 transaction.

Format: 0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, authorizationList, 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

Implementation of

TransactionInterface.serialize


sign()

sign(privateKey, extraEntropy): EOACode7702Tx

Defined in: 7702/tx.ts:393

Parameters

privateKey

Uint8Array

extraEntropy
boolean Uint8Array<ArrayBufferLike>

Returns

EOACode7702Tx

Implementation of

TransactionInterface.sign


supports()

supports(capability): boolean

Defined in: 7702/tx.ts:191

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

capability

number

Returns

boolean

Implementation of

TransactionInterface.supports


toCreationAddress()

toCreationAddress(): boolean

Defined in: 7702/tx.ts:232

If the tx’s to is to the creation address

Returns

boolean

Implementation of

TransactionInterface.toCreationAddress


toJSON()

toJSON(): JSONTx

Defined in: 7702/tx.ts:359

Returns an object with the JSON representation of the transaction

Returns

JSONTx

Implementation of

TransactionInterface.toJSON


verifySignature()

verifySignature(): boolean

Defined in: 7702/tx.ts:385

Returns

boolean

Implementation of

TransactionInterface.verifySignature