Skip to content

Latest commit

 

History

History
979 lines (542 loc) · 21.5 KB

FeeMarketEIP1559Transaction.md

File metadata and controls

979 lines (542 loc) · 21.5 KB

@ethereumjs/tx / FeeMarketEIP1559Transaction

Class: FeeMarketEIP1559Transaction

Typed transaction with a new gas fee market mechanism

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new FeeMarketEIP1559Transaction(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.

Parameters

Name Type
txData FeeMarketEIP1559TxData
opts TxOptions

Overrides

BaseTransaction<FeeMarketEIP1559Transaction&gt;.constructor

Defined in

eip1559Transaction.ts:185

Properties

AccessListJSON

Readonly AccessListJSON: AccessList

Defined in

eip1559Transaction.ts:37


accessList

Readonly accessList: AccessListBuffer

Defined in

eip1559Transaction.ts:36


chainId

Readonly chainId: BN

Defined in

eip1559Transaction.ts:35


common

Readonly common: default

Overrides

BaseTransaction.common

Defined in

eip1559Transaction.ts:41


data

Readonly data: Buffer

Inherited from

BaseTransaction.data

Defined in

baseTransaction.ts:47


gasLimit

Readonly gasLimit: BN

Inherited from

BaseTransaction.gasLimit

Defined in

baseTransaction.ts:44


maxFeePerGas

Readonly maxFeePerGas: BN

Defined in

eip1559Transaction.ts:39


maxPriorityFeePerGas

Readonly maxPriorityFeePerGas: BN

Defined in

eip1559Transaction.ts:38


nonce

Readonly nonce: BN

Inherited from

BaseTransaction.nonce

Defined in

baseTransaction.ts:43


r

Optional Readonly r: BN

Inherited from

BaseTransaction.r

Defined in

baseTransaction.ts:50


s

Optional Readonly s: BN

Inherited from

BaseTransaction.s

Defined in

baseTransaction.ts:51


to

Optional Readonly to: Address

Inherited from

BaseTransaction.to

Defined in

baseTransaction.ts:45


v

Optional Readonly v: BN

Inherited from

BaseTransaction.v

Defined in

baseTransaction.ts:49


value

Readonly value: BN

Inherited from

BaseTransaction.value

Defined in

baseTransaction.ts:46

Accessors

senderR

get senderR(): undefined | BN

EIP-2930 alias for r

deprecated use r instead

Returns

undefined | BN

Defined in

eip1559Transaction.ts:56


senderS

get senderS(): undefined | BN

EIP-2930 alias for s

deprecated use s instead

Returns

undefined | BN

Defined in

eip1559Transaction.ts:65


transactionType

get transactionType(): number

Alias for {@link BaseTransaction.type}

deprecated Use type instead

Returns

number

Inherited from

BaseTransaction.transactionType

Defined in

baseTransaction.ts:118


type

get type(): number

Returns the transaction type.

Note: legacy txs will return tx type 0.

Returns

number

Inherited from

BaseTransaction.type

Defined in

baseTransaction.ts:127


yParity

get yParity(): undefined | BN

EIP-2930 alias for v

deprecated use v instead

Returns

undefined | BN

Defined in

eip1559Transaction.ts:74

Methods

_processSignature

_processSignature(v, r, s): FeeMarketEIP1559Transaction

Parameters

Name Type
v number
r Buffer
s Buffer

Returns

FeeMarketEIP1559Transaction

Overrides

BaseTransaction._processSignature

Defined in

eip1559Transaction.ts:406


errorStr

errorStr(): string

Return a compact error string representation of the object

Returns

string

Overrides

BaseTransaction.errorStr

Defined in

eip1559Transaction.ts:455


getBaseFee

getBaseFee(): BN

The minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)

Returns

BN

Inherited from

BaseTransaction.getBaseFee

Defined in

baseTransaction.ts:175


getDataFee

getDataFee(): BN

The amount of gas paid for the data in this tx

Returns

BN

Overrides

BaseTransaction.getDataFee

Defined in

eip1559Transaction.ts:247


getMessageToSign

getMessageToSign(hashMessage?): Buffer

Returns the serialized unsigned tx (hashed or raw), 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(false) // use this for the HW wallet input

Parameters

Name Type Default value Description
hashMessage boolean true Return hashed message if set to true (default: true)

Returns

Buffer

Overrides

BaseTransaction.getMessageToSign

Defined in

eip1559Transaction.ts:333


getMessageToVerifySignature

getMessageToVerifySignature(): Buffer

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

Returns

Buffer

Overrides

BaseTransaction.getMessageToVerifySignature

Defined in

eip1559Transaction.ts:368


getSenderAddress

getSenderAddress(): Address

Returns the sender's address

Returns

Address

Inherited from

BaseTransaction.getSenderAddress

Defined in

baseTransaction.ts:271


getSenderPublicKey

getSenderPublicKey(): Buffer

Returns the public key of the sender

Returns

Buffer

Overrides

BaseTransaction.getSenderPublicKey

Defined in

eip1559Transaction.ts:375


getUpfrontCost

getUpfrontCost(baseFee?): BN

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

Parameters

Name Type Description
baseFee BN The base fee of the block (will be set to 0 if not provided)

Returns

BN

Overrides

BaseTransaction.getUpfrontCost

Defined in

eip1559Transaction.ts:269


hash

hash(): Buffer

Computes a sha3-256 hash of the serialized tx.

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

Returns

Buffer

Overrides

BaseTransaction.hash

Defined in

eip1559Transaction.ts:349


isSigned

isSigned(): boolean

Returns

boolean

Inherited from

BaseTransaction.isSigned

Defined in

baseTransaction.ts:238


raw

raw(): FeeMarketEIP1559ValuesArray

Returns a Buffer Array of the raw Buffers of the EIP-1559 transaction, in order.

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

Use FeeMarketEIP1559Transaction.serialize to add a transaction to a block with {@link Block.fromValuesArray}.

For an unsigned tx this method uses the empty Buffer values for the signature parameters v, r and s for encoding. For an EIP-155 compliant representation for external signing use FeeMarketEIP1559Transaction.getMessageToSign.

Returns

FeeMarketEIP1559ValuesArray

Overrides

BaseTransaction.raw

Defined in

eip1559Transaction.ts:288


serialize

serialize(): Buffer

Returns the serialized encoding of the EIP-1559 transaction.

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

Buffer

Overrides

BaseTransaction.serialize

Defined in

eip1559Transaction.ts:315


sign

sign(privateKey): FeeMarketEIP1559Transaction

Signs a transaction.

Note that the signed tx is returned as a new object, use as follows:

const signedTx = tx.sign(privateKey)

Parameters

Name Type
privateKey Buffer

Returns

FeeMarketEIP1559Transaction

Inherited from

BaseTransaction.sign

Defined in

baseTransaction.ts:289


supports

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 Capabilites in the types module for a reference on all supported capabilities.

Parameters

Name Type
capability Capability

Returns

boolean

Inherited from

BaseTransaction.supports

Defined in

baseTransaction.ts:147


toCreationAddress

toCreationAddress(): boolean

If the tx's to is to the creation address

Returns

boolean

Inherited from

BaseTransaction.toCreationAddress

Defined in

baseTransaction.ts:206


toJSON

toJSON(): JsonTx

Returns an object with the JSON representation of the transaction

Returns

JsonTx

Overrides

BaseTransaction.toJSON

Defined in

eip1559Transaction.ts:433


validate

validate(): boolean

Checks if the transaction has the minimum amount of gas required (DataFee + TxFee + Creation Fee).

Returns

boolean

Inherited from

BaseTransaction.validate

Defined in

baseTransaction.ts:155

validate(stringError): boolean

Parameters

Name Type
stringError false

Returns

boolean

Inherited from

BaseTransaction.validate

Defined in

baseTransaction.ts:156

validate(stringError): string[]

Parameters

Name Type
stringError true

Returns

string[]

Inherited from

BaseTransaction.validate

Defined in

baseTransaction.ts:157


verifySignature

verifySignature(): boolean

Determines if the signature is valid

Returns

boolean

Inherited from

BaseTransaction.verifySignature

Defined in

baseTransaction.ts:258


fromRlpSerializedTx

Static fromRlpSerializedTx(serialized, opts?): FeeMarketEIP1559Transaction

Instantiate a transaction from the serialized tx. (alias of FeeMarketEIP1559Transaction.fromSerializedTx)

Note: This means that the Buffer should start with 0x01.

deprecated this constructor alias is deprecated and will be removed in favor of the FeeMarketEIP1559Transaction.fromSerializedTx constructor

Parameters

Name Type
serialized Buffer
opts TxOptions

Returns

FeeMarketEIP1559Transaction

Defined in

eip1559Transaction.ts:125


fromSerializedTx

Static fromSerializedTx(serialized, opts?): FeeMarketEIP1559Transaction

Instantiate a transaction from the serialized tx.

Format: 0x02 || rlp([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, signatureYParity, signatureR, signatureS])

Parameters

Name Type
serialized Buffer
opts TxOptions

Returns

FeeMarketEIP1559Transaction

Defined in

eip1559Transaction.ts:98


fromTxData

Static fromTxData(txData, opts?): FeeMarketEIP1559Transaction

Instantiate a transaction from a data dictionary.

Format: { chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, v, r, s }

Notes:

  • chainId will be set automatically if not provided
  • All parameters are optional and have some basic default values

Parameters

Name Type
txData FeeMarketEIP1559TxData
opts TxOptions

Returns

FeeMarketEIP1559Transaction

Defined in

eip1559Transaction.ts:88


fromValuesArray

Static fromValuesArray(values, opts?): FeeMarketEIP1559Transaction

Create a transaction from a values array.

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

Parameters

Name Type
values FeeMarketEIP1559ValuesArray
opts TxOptions

Returns

FeeMarketEIP1559Transaction

Defined in

eip1559Transaction.ts:135