Onlife/node_modules/@ethereumjs/tx/dist/cjs/eip4844Transaction.d.ts
2025-04-19 15:38:48 +08:00

165 lines
7.5 KiB
TypeScript

import { BaseTransaction } from './baseTransaction.js';
import { TransactionType } from './types.js';
import type { AccessList, AccessListBytes, TxData as AllTypesTxData, TxValuesArray as AllTypesTxValuesArray, JsonBlobTxNetworkWrapper, JsonTx, TxOptions } from './types.js';
import type { Common } from '@ethereumjs/common';
declare type TxData = AllTypesTxData[TransactionType.BlobEIP4844];
declare type TxValuesArray = AllTypesTxValuesArray[TransactionType.BlobEIP4844];
/**
* Typed transaction with a new gas fee market mechanism for transactions that include "blobs" of data
*
* - TransactionType: 3
* - EIP: [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
*/
export declare class BlobEIP4844Transaction extends BaseTransaction<TransactionType.BlobEIP4844> {
readonly chainId: bigint;
readonly accessList: AccessListBytes;
readonly AccessListJSON: AccessList;
readonly maxPriorityFeePerGas: bigint;
readonly maxFeePerGas: bigint;
readonly maxFeePerBlobGas: bigint;
readonly common: Common;
blobVersionedHashes: Uint8Array[];
blobs?: Uint8Array[];
kzgCommitments?: Uint8Array[];
kzgProofs?: Uint8Array[];
/**
* 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.
*/
constructor(txData: TxData, opts?: TxOptions);
static fromTxData(txData: TxData, opts?: TxOptions): BlobEIP4844Transaction;
/**
* Returns the minimum of calculated priority fee (from maxFeePerGas and baseFee) and maxPriorityFeePerGas
* @param baseFee Base fee retrieved from block
*/
getEffectivePriorityFee(baseFee: bigint): bigint;
/**
* 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
* @param txData a {@link BlobEIP4844Transaction} containing optional blobs/kzg commitments
* @param opts - dictionary of {@link TxOptions}
* @returns the "minimal" representation of a BlobEIP4844Transaction (i.e. transaction object minus blobs and kzg commitments)
*/
static minimalFromNetworkWrapper(txData: BlobEIP4844Transaction, opts?: TxOptions): 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])`
*/
static fromSerializedTx(serialized: Uint8Array, opts?: TxOptions): BlobEIP4844Transaction;
/**
* Create a transaction from a values array.
*
* Format: `[chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data,
* accessList, signatureYParity, signatureR, signatureS]`
*/
static fromValuesArray(values: TxValuesArray, opts?: TxOptions): BlobEIP4844Transaction;
/**
* Creates a transaction from the network encoding of a blob transaction (with blobs/commitments/proof)
* @param serialized a buffer representing a serialized BlobTransactionNetworkWrapper
* @param opts any TxOptions defined
* @returns a BlobEIP4844Transaction
*/
static fromSerializedBlobTxNetworkWrapper(serialized: Uint8Array, opts?: TxOptions): BlobEIP4844Transaction;
/**
* The amount of gas paid for the data in this tx
*/
getDataFee(): bigint;
/**
* The up front amount that an account must have for this transaction to be valid
* @param baseFee The base fee of the block (will be set to 0 if not provided)
*/
getUpfrontCost(baseFee?: bigint): bigint;
/**
* 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 {@link BlobEIP4844Transaction.getMessageToSign}.
*/
raw(): TxValuesArray;
/**
* 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.
*/
serialize(): Uint8Array;
/**
* @returns the serialized form of a blob transaction in the network wrapper format (used for gossipping mempool transactions over devp2p)
*/
serializeNetworkWrapper(): 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.
*
* ```javascript
* const serializedMessage = tx.getMessageToSign() // use this for the HW wallet input
* ```
*/
getMessageToSign(): 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.
*/
getHashedMessageToSign(): Uint8Array;
/**
* Computes a sha3-256 hash of the serialized tx.
*
* This method can only be used for signed txs (it throws otherwise).
* Use {@link BlobEIP4844Transaction.getMessageToSign} to get a tx hash for the purpose of signing.
*/
hash(): Uint8Array;
getMessageToVerifySignature(): Uint8Array;
/**
* Returns the public key of the sender
*/
getSenderPublicKey(): Uint8Array;
/**
* Returns the EIP 4844 transaction network wrapper in JSON format similar to toJSON, including
* blobs, commitments, and proofs fields
* @param serialized a buffer representing a serialized BlobTransactionNetworkWrapper
* @param opts any TxOptions defined
* @returns JsonBlobTxNetworkWrapper with blobs, KZG commitments, and KZG proofs fields
*/
static networkWrapperToJson(serialized: Uint8Array, opts?: TxOptions): JsonBlobTxNetworkWrapper;
toJSON(): JsonTx;
addSignature(v: bigint, r: Uint8Array | bigint, s: Uint8Array | bigint, convertV?: boolean): BlobEIP4844Transaction;
/**
* Return a compact error string representation of the object
*/
errorStr(): string;
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string): string;
/**
* @returns the number of blobs included with this transaction
*/
numBlobs(): number;
}
export {};
//# sourceMappingURL=eip4844Transaction.d.ts.map