Skip to content

Latest commit

 

History

History
153 lines (92 loc) · 5.25 KB

TransactionFactory.md

File metadata and controls

153 lines (92 loc) · 5.25 KB

@ethereumjs/tx / TransactionFactory

Class: TransactionFactory

Table of contents

Methods

Methods

fromBlockBodyData

Static fromBlockBodyData(data, txOptions?): FeeMarketEIP1559Transaction | LegacyTransaction | AccessListEIP2930Transaction | BlobEIP4844Transaction

When decoding a BlockBody, in the transactions field, a field is either: A Uint8Array (a TypedTransaction - encoded as TransactionType || rlp(TransactionPayload)) A Uint8Array[] (Legacy Transaction) This method returns the right transaction.

Parameters

Name Type Description
data Uint8Array | Uint8Array[] A Uint8Array or Uint8Array[]
txOptions TxOptions The transaction options

Returns

FeeMarketEIP1559Transaction | LegacyTransaction | AccessListEIP2930Transaction | BlobEIP4844Transaction

Defined in

tx/src/transactionFactory.ts:87


fromJsonRpcProvider

Static fromJsonRpcProvider(provider, txHash, txOptions?): Promise<FeeMarketEIP1559Transaction | LegacyTransaction | AccessListEIP2930Transaction | BlobEIP4844Transaction>

Method to retrieve a transaction from the provider

Parameters

Name Type Description
provider string | EthersProvider a url string for a JSON-RPC provider or an Ethers JsonRPCProvider object
txHash string Transaction hash
txOptions? TxOptions The transaction options

Returns

Promise<FeeMarketEIP1559Transaction | LegacyTransaction | AccessListEIP2930Transaction | BlobEIP4844Transaction>

the transaction specified by txHash

Defined in

tx/src/transactionFactory.ts:105


fromRPC

Static fromRPC<T>(txData, txOptions?): Promise<Transaction[T]>

Method to decode data retrieved from RPC, such as eth_getTransactionByHash Note that this normalizes some of the parameters

Type parameters

Name Type
T extends TransactionType

Parameters

Name Type Description
txData TxData[T] The RPC-encoded data
txOptions TxOptions The transaction options

Returns

Promise<Transaction[T]>

Defined in

tx/src/transactionFactory.ts:128


fromSerializedData

Static fromSerializedData<T>(data, txOptions?): Transaction[T]

This method tries to decode serialized data.

Type parameters

Name Type
T extends TransactionType

Parameters

Name Type Description
data Uint8Array The data Uint8Array
txOptions TxOptions The transaction options

Returns

Transaction[T]

Defined in

tx/src/transactionFactory.ts:57


fromTxData

Static fromTxData<T>(txData, txOptions?): Transaction[T]

Create a transaction from a txData object

Type parameters

Name Type
T extends TransactionType

Parameters

Name Type Description
txData TypedTxData The transaction data. The type field will determine which transaction type is returned (if undefined, creates a legacy transaction)
txOptions TxOptions Options to pass on to the constructor of the transaction

Returns

Transaction[T]

Defined in

tx/src/transactionFactory.ts:29