I'd like to know the detail of the Ethereum transaction data structure. What data is stored in transaction?
4 Answers
An Ethereum transaction - as in, what you pass to sendRawTransaction() - consists of the following fields, in order and RLP-encoded (note that the field names are not part of the encoded data):
- nonce - transaction sequence number fr the sending account
- gasprice - price you are offering to pay
- startgas - maximum amount of gas allowed for the transaction
- to - destination address (account or contract address)
- value - eth to transfer to the destination, if any
- data - all of the interesting stuff goes here
- v - along with r and s makes up the ECDSA signature
- r
- s
Any payload, whether raw data or a contract function signature and parameters, is encoded into the data field.
Some references:
you can check a transsaction by its hash, for instance in eth :
> web3.eth.getTransaction('0xc5eee3ae9cf10fbee05325e3a25c3b19489783612e36cb55b054c2cb4f82fc28')
{
blockHash: '0xdb85c62ef50103f08e9220b59d6c08cbfb52e61d84926dedb3fe9b6940e6bbea',
blockNumber: 290081,
from: '0x1dcb8d1f0fcc8cbc8c2d76528e877f915e299fbe',
gas: 90000,
gasPrice: 50000000000',
hash: '0xc5eee3ae9cf10fbee05325e3a25c3b19489783612e36cb55b054c2cb4f82fc28',
input: '0x',
nonce: 34344,
to: '0x702bd0d370bbf0b97b66fe95578c62697c583393',
transactionIndex: 0,
value: 5000111390000000000'
}
which you can see in a blockchain scanner here
- 4,640
- 5
- 24
- 55
As of London fork, a new EIP-2718 transaction is introduced with TransactionType 2, as described in ethereum/EIPs/eip-1559.
The new payload structure -
rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, amount, data, access_list, signature_y_parity, signature_r, signature_s])
Specification
Block validity is defined in the reference implementation below.
The GASPRICE (0x3a) opcode MUST return the effective_gas_price as defined in the reference implementation below.
The intrinsic cost of the new transaction is inherited from EIP-2930, specifically 21000 + 16 * non-zero calldata bytes + 4 * zero calldata bytes + 1900 * access list storage key count + 2400 * access list address count.
The EIP-2718 TransactionPayload for this transaction is rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, amount, data, access_list, signature_y_parity, signature_r, signature_s]).
The signature_y_parity, signature_r, signature_s elements of this transaction represent a secp256k1 signature over keccak256(0x02 || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, amount, data, access_list])).
The EIP-2718 ReceiptPayload for this transaction is rlp([status, cumulative_transaction_gas_used, logs_bloom, logs]).
- 2,954
- 6
- 23
Transaction consists of following field while validating it into the block:
Status
Block
TimeStamp
From
To
Value
Transaction fees
Gas Price
Gas Limit & Usage by Txn
Gas Fees
Burnt & Txn Savings Fees
Input Data
Others (Tx type, Nonce, Position)
You can track all this when you create and deploy the contract on etherscan.io
- 11
- 2
-
The status is not part of the transaction, it is in the transaction receipt. Etherscan shows several fields that are useful for their users, but they aren't part of the transaction. – Ismael Jun 29 '22 at 16:57
-
Ahh got it, thanks for clarifying. I just started learning about Blockchain and Ethereum. – Abhishek Jha Jun 29 '22 at 17:27
geth,ethandpyethappuse - or even could use - the exact same internal data structure to represent a transaction. – jimkberry Jun 13 '16 at 19:44