@ethereumjs/tx / BlobEIP4844Transaction
Typed transaction with a new gas fee market mechanism for transactions that include “blobs” of data
BaseTransaction
<BlobEIP4844
>
↳ BlobEIP4844Transaction
• new BlobEIP4844Transaction(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 constructors or factory methods to assist in creating a Transaction object from varying data types.
Name | Type |
---|---|
txData |
BlobEIP4844TxData |
opts |
TxOptions |
BaseTransaction<TransactionType.BlobEIP4844\>.constructor
tx/src/eip4844Transaction.ts:104
• Readonly
AccessListJSON: AccessList
tx/src/eip4844Transaction.ts:86
• Readonly
accessList: AccessListBytes
tx/src/eip4844Transaction.ts:85
• blobVersionedHashes: Uint8Array
[]
tx/src/eip4844Transaction.ts:92
• Optional
blobs: Uint8Array
[]
tx/src/eip4844Transaction.ts:93
• cache: TransactionCache
BaseTransaction.cache
• Readonly
chainId: bigint
tx/src/eip4844Transaction.ts:84
• Readonly
common: Common
BaseTransaction.common
tx/src/eip4844Transaction.ts:91
• Readonly
data: Uint8Array
BaseTransaction.data
• Readonly
gasLimit: bigint
BaseTransaction.gasLimit
• Optional
kzgCommitments: Uint8Array
[]
tx/src/eip4844Transaction.ts:94
• Optional
kzgProofs: Uint8Array
[]
tx/src/eip4844Transaction.ts:95
• Readonly
maxFeePerBlobGas: bigint
tx/src/eip4844Transaction.ts:89
• Readonly
maxFeePerGas: bigint
tx/src/eip4844Transaction.ts:88
• Readonly
maxPriorityFeePerGas: bigint
tx/src/eip4844Transaction.ts:87
• 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?
): BlobEIP4844Transaction
Name | Type | Default value |
---|---|---|
v |
bigint |
undefined |
r |
bigint | Uint8Array |
undefined |
s |
bigint | Uint8Array |
undefined |
convertV |
boolean |
false |
BaseTransaction.addSignature
tx/src/eip4844Transaction.ts:558
▸ errorStr(): string
Return a compact error string representation of the object
string
BaseTransaction.errorStr
tx/src/eip4844Transaction.ts:594
▸ 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/eip4844Transaction.ts:421
▸ getEffectivePriorityFee(baseFee
): bigint
Returns the minimum of calculated priority fee (from maxFeePerGas and baseFee) and maxPriorityFeePerGas
Name | Type | Description |
---|---|---|
baseFee |
bigint |
Base fee retrieved from block |
bigint
BaseTransaction.getEffectivePriorityFee
tx/src/eip4844Transaction.ts:224
▸ 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/eip4844Transaction.ts:518
▸ 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/eip4844Transaction.ts:507
▸ getMessageToVerifySignature(): Uint8Array
Uint8Array
BaseTransaction.getMessageToVerifySignature
tx/src/eip4844Transaction.ts:532
▸ getSenderAddress(): Address
Returns the sender’s address
Address
BaseTransaction.getSenderAddress
▸ getSenderPublicKey(): Uint8Array
Returns the public key of the sender
Uint8Array
BaseTransaction.getSenderPublicKey
tx/src/eip4844Transaction.ts:539
▸ getUpfrontCost(baseFee?
): bigint
The up front amount that an account must have for this transaction to be valid
Name | Type | Default value | Description |
---|---|---|---|
baseFee |
bigint |
BIGINT_0 |
The base fee of the block (will be set to 0 if not provided) |
bigint
BaseTransaction.getUpfrontCost
tx/src/eip4844Transaction.ts:429
▸ 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/eip4844Transaction.ts:528
▸ 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
▸ numBlobs(): number
number
the number of blobs included with this transaction
tx/src/eip4844Transaction.ts:613
▸ raw(): BlobEIP4844TxValuesArray
Returns a Uint8Array Array of the raw Bytes of the EIP-4844 transaction, in order.
Format: [chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data, access_list, max_fee_per_data_gas, blob_versioned_hashes, y_parity, r, s]`.
Use {@link BlobEIP4844Transaction.serialize} to add a transaction to a block with {@link 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.
BlobEIP4844TxValuesArray
BaseTransaction.raw
tx/src/eip4844Transaction.ts:446
▸ serialize(): Uint8Array
Returns the serialized encoding of the EIP-4844 transaction.
Format: 0x03 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
access_list, max_fee_per_data_gas, blob_versioned_hashes, y_parity, r, 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/eip4844Transaction.ts:475
▸ serializeNetworkWrapper(): Uint8Array
Uint8Array
the serialized form of a blob transaction in the network wrapper format (used for gossipping mempool transactions over devp2p)
tx/src/eip4844Transaction.ts:482
▸ sign(privateKey
): BlobEIP4844Transaction
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
BaseTransaction.toJSON
tx/src/eip4844Transaction.ts:543
▸ verifySignature(): boolean
Determines if the signature is valid
boolean
BaseTransaction.verifySignature
▸ Static
fromSerializedBlobTxNetworkWrapper(serialized
, opts?
): BlobEIP4844Transaction
Creates a transaction from the network encoding of a blob transaction (with blobs/commitments/proof)
Name | Type | Description |
---|---|---|
serialized |
Uint8Array |
a buffer representing a serialized BlobTransactionNetworkWrapper |
opts? |
TxOptions |
any TxOptions defined |
a BlobEIP4844Transaction
tx/src/eip4844Transaction.ts:358
▸ Static
fromSerializedTx(serialized
, opts?
): BlobEIP4844Transaction
Instantiate a transaction from the serialized tx.
Format: 0x03 || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, to, value, data,
access_list, max_fee_per_data_gas, blob_versioned_hashes, y_parity, r, s])
Name | Type |
---|---|
serialized |
Uint8Array |
opts |
TxOptions |
tx/src/eip4844Transaction.ts:259
▸ Static
fromTxData(txData
, opts?
): BlobEIP4844Transaction
Name | Type |
---|---|
txData |
BlobEIP4844TxData |
opts? |
TxOptions |
tx/src/eip4844Transaction.ts:192
▸ Static
fromValuesArray(values
, opts?
): BlobEIP4844Transaction
Create a transaction from a values array.
Format: [chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
accessList, signatureYParity, signatureR, signatureS]
Name | Type |
---|---|
values |
BlobEIP4844TxValuesArray |
opts |
TxOptions |
tx/src/eip4844Transaction.ts:289
▸ Static
minimalFromNetworkWrapper(txData
, opts?
): BlobEIP4844Transaction
Creates the minimal representation of a blob transaction from the network wrapper version. The minimal representation is used when adding transactions to an execution payload/block
Name | Type | Description |
---|---|---|
txData |
BlobEIP4844Transaction |
a BlobEIP4844Transaction containing optional blobs/kzg commitments |
opts? |
TxOptions |
dictionary of TxOptions |
the “minimal” representation of a BlobEIP4844Transaction (i.e. transaction object minus blobs and kzg commitments)