@ethereumjs/tx / AccessListEIP2930Transaction
Typed transaction with optional access lists
BaseTransaction
<AccessListEIP2930
>
↳ AccessListEIP2930Transaction
• new AccessListEIP2930Transaction(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.
Name | Type |
---|---|
txData |
AccessListEIP2930TxData |
opts |
TxOptions |
BaseTransaction<TransactionType.AccessListEIP2930\>.constructor
tx/src/eip2930Transaction.ts:134
• Readonly
AccessListJSON: AccessList
tx/src/eip2930Transaction.ts:43
• Readonly
accessList: AccessListBytes
tx/src/eip2930Transaction.ts:42
• cache: TransactionCache
BaseTransaction.cache
• Readonly
chainId: bigint
tx/src/eip2930Transaction.ts:41
• Readonly
common: Common
BaseTransaction.common
tx/src/eip2930Transaction.ts:46
• Readonly
data: Uint8Array
BaseTransaction.data
• Readonly
gasLimit: bigint
BaseTransaction.gasLimit
• Readonly
gasPrice: bigint
tx/src/eip2930Transaction.ts:44
• Readonly
nonce: bigint
BaseTransaction.nonce
• Optional
Readonly
r: bigint
BaseTransaction.r
• Optional
Readonly
s: bigint
BaseTransaction.s
• Optional
Readonly
to: Address
BaseTransaction.to
• Optional
Readonly
v: bigint
BaseTransaction.v
• Readonly
value: bigint
BaseTransaction.value
• get
type(): TransactionType
Returns the transaction type.
Note: legacy txs will return tx type 0
.
BaseTransaction.type
▸ addSignature(v
, r
, s
, convertV?
): AccessListEIP2930Transaction
Name | Type | Default value |
---|---|---|
v |
bigint |
undefined |
r |
bigint | Uint8Array |
undefined |
s |
bigint | Uint8Array |
undefined |
convertV |
boolean |
false |
BaseTransaction.addSignature
tx/src/eip2930Transaction.ts:287
▸ errorStr(): string
Return a compact error string representation of the object
string
BaseTransaction.errorStr
tx/src/eip2930Transaction.ts:333
▸ getBaseFee(): bigint
The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)
bigint
BaseTransaction.getBaseFee
▸ getDataFee(): bigint
The amount of gas paid for the data in this tx
bigint
BaseTransaction.getDataFee
tx/src/eip2930Transaction.ts:183
▸ getEffectivePriorityFee(baseFee?
): bigint
Name | Type |
---|---|
baseFee? |
bigint |
bigint
BaseTransaction.getEffectivePriorityFee
tx/src/eip2930Transaction.ts:176
▸ 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.
Uint8Array
BaseTransaction.getHashedMessageToSign
tx/src/eip2930Transaction.ts:259
▸ 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
Uint8Array
BaseTransaction.getMessageToSign
tx/src/eip2930Transaction.ts:248
▸ getMessageToVerifySignature(): Uint8Array
Computes a sha3-256 hash which can be used to verify the signature
Uint8Array
BaseTransaction.getMessageToVerifySignature
tx/src/eip2930Transaction.ts:276
▸ getSenderAddress(): Address
Returns the sender’s address
Address
BaseTransaction.getSenderAddress
▸ getSenderPublicKey(): Uint8Array
Returns the public key of the sender
Uint8Array
BaseTransaction.getSenderPublicKey
tx/src/eip2930Transaction.ts:283
▸ getUpfrontCost(): bigint
The up front amount that an account must have for this transaction to be valid
bigint
BaseTransaction.getUpfrontCost
tx/src/eip2930Transaction.ts:190
▸ getValidationErrors(): string
[]
Validates the transaction signature and minimum gas requirements.
string
[]
an array of error strings
BaseTransaction.getValidationErrors
▸ 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.
Uint8Array
BaseTransaction.hash
tx/src/eip2930Transaction.ts:269
▸ isSigned(): boolean
boolean
BaseTransaction.isSigned
▸ isValid(): boolean
Validates the transaction signature and minimum gas requirements.
boolean
true if the transaction is valid, false otherwise
BaseTransaction.isValid
▸ raw(): AccessListEIP2930TxValuesArray
Returns a Uint8Array Array of the raw Bytess of the EIP-2930 transaction, in order.
Format: [chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
signatureYParity (v), signatureR (r), signatureS (s)]
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.
AccessListEIP2930TxValuesArray
BaseTransaction.raw
tx/src/eip2930Transaction.ts:207
▸ serialize(): Uint8Array
Returns the serialized encoding of the EIP-2930 transaction.
Format: 0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
signatureYParity (v), signatureR (r), signatureS (s)])
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.
Uint8Array
BaseTransaction.serialize
tx/src/eip2930Transaction.ts:233
▸ sign(privateKey
): AccessListEIP2930Transaction
Signs a transaction.
Note that the signed tx is returned as a new object, use as follows:
const signedTx = tx.sign(privateKey)
Name | Type |
---|---|
privateKey |
Uint8Array |
BaseTransaction.sign
▸ 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.
Name | Type |
---|---|
capability |
Capability |
boolean
BaseTransaction.supports
▸ toCreationAddress(): boolean
If the tx’s to
is to the creation address
boolean
BaseTransaction.toCreationAddress
▸ toJSON(): JsonTx
Returns an object with the JSON representation of the transaction
BaseTransaction.toJSON
tx/src/eip2930Transaction.ts:318
▸ verifySignature(): boolean
Determines if the signature is valid
boolean
BaseTransaction.verifySignature
▸ Static
fromSerializedTx(serialized
, opts?
): AccessListEIP2930Transaction
Instantiate a transaction from the serialized tx.
Format: 0x01 || rlp([chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
signatureYParity (v), signatureR (r), signatureS (s)])
Name | Type |
---|---|
serialized |
Uint8Array |
opts |
TxOptions |
tx/src/eip2930Transaction.ts:68
▸ Static
fromTxData(txData
, opts?
): AccessListEIP2930Transaction
Instantiate a transaction from a data dictionary.
Format: { chainId, nonce, gasPrice, gasLimit, to, value, data, accessList, v, r, s }
Notes:
chainId
will be set automatically if not providedName | Type |
---|---|
txData |
AccessListEIP2930TxData |
opts |
TxOptions |
tx/src/eip2930Transaction.ts:58
▸ Static
fromValuesArray(values
, opts?
): AccessListEIP2930Transaction
Create a transaction from a values array.
Format: [chainId, nonce, gasPrice, gasLimit, to, value, data, accessList,
signatureYParity (v), signatureR (r), signatureS (s)]
Name | Type |
---|---|
values |
AccessListEIP2930TxValuesArray |
opts |
TxOptions |