@ethereumjs/tx / LegacyTx
Defined in: legacy/tx.ts:82
An Ethereum non-typed (legacy) transaction
TransactionInterface
<typeof Legacy
>new LegacyTx(
txData
,opts
):LegacyTx
Defined in: legacy/tx.ts:123
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.
TxOptions
= {}
LegacyTx
readonly
cache:TransactionCache
={}
Defined in: legacy/tx.ts:107
readonly
common:Common
Defined in: legacy/tx.ts:102
readonly
data:Uint8Array
Defined in: legacy/tx.ts:91
readonly
gasLimit:bigint
Defined in: legacy/tx.ts:89
readonly
gasPrice:bigint
Defined in: legacy/tx.ts:87
readonly
nonce:bigint
Defined in: legacy/tx.ts:88
readonly
optional
r:bigint
Defined in: legacy/tx.ts:96
readonly
optional
s:bigint
Defined in: legacy/tx.ts:97
readonly
optional
to:Address
Defined in: legacy/tx.ts:92
readonly
txOptions:TxOptions
Defined in: legacy/tx.ts:105
TransactionInterface
.txOptions
type:
0
=TransactionType.Legacy
Defined in: legacy/tx.ts:84
readonly
optional
v:bigint
Defined in: legacy/tx.ts:95
readonly
value:bigint
Defined in: legacy/tx.ts:90
addSignature(
v
,r
,s
,convertV
):LegacyTx
Defined in: legacy/tx.ts:335
bigint
bigint |
Uint8Array <ArrayBufferLike > |
bigint |
Uint8Array <ArrayBufferLike > |
boolean
= false
LegacyTx
TransactionInterface
.addSignature
errorStr():
string
Defined in: legacy/tx.ts:407
Return a compact error string representation of the object
string
getDataGas():
bigint
Defined in: legacy/tx.ts:279
The amount of gas paid for the data in this tx
bigint
TransactionInterface
.getDataGas
getEffectivePriorityFee(
baseFee?
):bigint
Defined in: legacy/tx.ts:191
bigint
bigint
getHashedMessageToSign():
Uint8Array
<ArrayBufferLike
>
Defined in: legacy/tx.ts:271
Returns the hashed serialized unsigned tx, which can be used to sign the transaction (e.g. for sending to a hardware wallet).
Uint8Array
<ArrayBufferLike
>
TransactionInterface
.getHashedMessageToSign
getIntrinsicGas():
bigint
Defined in: legacy/tx.ts:297
The minimum gas limit which the tx to have to be valid. This covers costs as the standard fee (21000 gas), the data fee (paid for each calldata byte), the optional creation fee (if the transaction creates a contract), and if relevant the gas to be paid for access lists (EIP-2930) and authority lists (EIP-7702).
bigint
TransactionInterface
.getIntrinsicGas
getMessageToSign():
Uint8Array
<ArrayBufferLike
>[]
Defined in: legacy/tx.ts:248
Returns the raw unsigned tx, which can be used to sign the transaction (e.g. for sending to a hardware wallet).
Note: the raw message message format for the legacy tx is not RLP encoded and you might need to do yourself with:
import { RLP } from '@ethereumjs/rlp'
const message = tx.getMessageToSign()
const serializedMessage = RLP.encode(message)) // use this for the HW wallet input
Uint8Array
<ArrayBufferLike
>[]
TransactionInterface
.getMessageToSign
getMessageToVerifySignature():
Uint8Array
<ArrayBufferLike
>
Defined in: legacy/tx.ts:320
Computes a sha3-256 hash which can be used to verify the signature
Uint8Array
<ArrayBufferLike
>
TransactionInterface
.getMessageToVerifySignature
getSenderAddress():
Address
Defined in: legacy/tx.ts:396
Address
TransactionInterface
.getSenderAddress
getSenderPublicKey():
Uint8Array
Defined in: legacy/tx.ts:331
Returns the public key of the sender
Uint8Array
TransactionInterface
.getSenderPublicKey
getUpfrontCost():
bigint
Defined in: legacy/tx.ts:303
The up front amount that an account must have for this transaction to be valid
bigint
TransactionInterface
.getUpfrontCost
getValidationErrors():
string
[]
Defined in: legacy/tx.ts:384
string
[]
TransactionInterface
.getValidationErrors
hash():
Uint8Array
Defined in: legacy/tx.ts:313
Computes a sha3-256 hash of the serialized tx.
This method can only be used for signed txs (it throws otherwise). Use Transaction.getMessageToSign to get a tx hash for the purpose of signing.
Uint8Array
isSigned():
boolean
Defined in: legacy/tx.ts:187
boolean
isValid():
boolean
Defined in: legacy/tx.ts:388
boolean
raw():
LegacyTxValuesArray
Defined in: legacy/tx.ts:208
Returns a Uint8Array Array of the raw Bytes of the legacy transaction, in order.
Format: [nonce, gasPrice, gasLimit, to, value, data, v, r, s]
For legacy txs this is also the correct format to add transactions
to a block with createBlockFromBytesArray (use the serialize()
method
for typed txs).
For an unsigned tx this method returns the empty Bytes values
for the signature parameters v
, r
and s
. For an EIP-155 compliant
representation have a look at Transaction.getMessageToSign.
LegacyTxValuesArray
serialize():
Uint8Array
Defined in: legacy/tx.ts:231
Returns the serialized encoding of the legacy transaction.
Format: rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s])
For an unsigned tx this method uses the empty Uint8Array values for the
signature parameters v
, r
and s
for encoding. For an EIP-155 compliant
representation for external signing use Transaction.getMessageToSign.
Uint8Array
TransactionInterface
.serialize
sign(
privateKey
,extraEntropy
):LegacyTx
Defined in: legacy/tx.ts:400
Uint8Array
boolean |
Uint8Array <ArrayBufferLike > |
LegacyTx
supports(
capability
):boolean
Defined in: legacy/tx.ts:183
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.
number
boolean
toCreationAddress():
boolean
Defined in: legacy/tx.ts:287
If the tx’s to
is to the creation address
boolean
TransactionInterface
.toCreationAddress
toJSON():
JSONTx
Defined in: legacy/tx.ts:375
Returns an object with the JSON representation of the transaction.
verifySignature():
boolean
Defined in: legacy/tx.ts:392
boolean