39

I'd like to know the detail of the Ethereum transaction data structure. What data is stored in transaction?

4 Answers 4

41

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:

Transaction (python)

LegacyTx (go)

rlp.Serializable (python)

ECDSA parameters

4
  • Is a message structure same as a transaction structure? Jun 11, 2016 at 7:13
  • 2
    The message structure is the only thing that is formally specified. The "data structure" representing a transaction is a construct of the application in which it exists (and therefore to some extent the programming language.) For instance, it is very unlikely that geth, eth and pyethapp use - or even could use - the exact same internal data structure to represent a transaction.
    – jimkberry
    Jun 13, 2016 at 19:44
  • but what is 'data' field? what sort of interesting stuff goes there? Could you provide any example for the data part? Feb 10, 2017 at 22:13
  • @AbhishekDeb "interesting" here means arguments to a smart contract. If you're calling a smart contract function, or creating a smart contract, all of that code gets lumped into the data field.
    – ohsully
    Mar 6, 2019 at 16:24
4

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

1
  • 1
    Does raw transaction data have signature in it? Mar 12, 2016 at 2:17
3
+200

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]).

0

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

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, 2022 at 16:57
  • Ahh got it, thanks for clarifying. I just started learning about Blockchain and Ethereum. Jun 29, 2022 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.