Understanding the Transaction Object on Ethereum
This guide details each element in the response of the Transaction object returned by eth_getTransactionByHash
Transaction Object
The transaction object on Ethereum is made up of the following components:
blockHash
:DATA
, 32 Bytes - hash of the block where this transaction was in. null when it is pending.blockNumber
:QUANTITY
- block number where this transaction was in. null when it's pending.from
:DATA
, 20 Bytes - sender's address.gas
:QUANTITY
- gas provided by the sender.gasPrice
:QUANTITY
- gas price provided by the sender in Wei.hash
:DATA
, 32 Bytes - hash of the transaction.input
:DATA
- the data sent along with the transaction.nonce
:QUANTITY
- the number of transactions made by the sender prior to this one.to
:DATA
, 20 Bytes - address of the receiver. null when it's a contract creation transaction.transactionIndex
:QUANTITY
- integer of the transactions index position in the block. null when it's pending.value
:QUANTITY
- value transferred in Wei.v
:QUANTITY
- ECDSA recovery idr
:DATA
, 32 Bytes - ECDSA signature rs
:DATA
, 32 Bytes - ECDSA signature s
Below you will find more detailed explanations for each parameter on the transaction object.
Hash
Hash
Every transaction that has been verified and added to the blockchain will receive an assigned hash
. This creates a unique identifier for the transaction that can be used to locate and retrieve information about a specific transaction.
blockHash
blockHash
Each block has a corresponding cryptographic hash which includes all the data of that block. TheblockHash
is the hash of the block where this transaction has been included. In the case of a pending transaction that has not been added to a block, you will receive a null
value in return.
blockNumber
blockNumber
Once a block has been added to the blockchain, it is assigned the following available number in sequential order. Using the blockNumber
, you can tell when the transaction has been added to a block.
from
from
Ethereum transactions have both a sender and receiver. The from
field is the address of the sender and can be used to find out which address started the transaction.
gas
gas
For transactions to be completed and added to a block, the sender must provide an amount of gas in addition to the value of the transaction. Gas is used to cover the computation costs required to complete the transaction. This gas
field shows you the amount of gas that was provided by the sender.
gasPrice
gasPrice
Another way to show the gas price is in wei. Wei is the smallest denomination of ETH and is a better way to work with smaller transactions of ETH. 1 wei is the equivalent of 10^-18 ETH. This gasPrice
shows the amount of gas provided by the sender in WEI.
input
input
Data can be added to the data field of a transaction whenever a user deploys or makes a call to a function in a smart contract. This data is a message to the smart contract that points to the function that will be executed.
The input
field contains the data that is included in the transaction. If this field is empty, the transaction is a transfer between users and doesn't involve a smart contract.
nonce
nonce
To prevent any double-spend from a user and to ensure transactions occur in the correct order, each transaction from a given address has an assigned nonce
. The nonce is the number of transactions from that specific address. The nonce increases by 1 after every transaction. A transaction must but be completed before another one can begin.
to
to
Transactions have both a sender and receiver. The to
field is the address of the receiver and can be used to find out which address started the transaction.
transactionIndex
transactionIndex
When a transaction is added to a block, it is assigned a numbered position inside that block. The transactionIndex
returns the value of the position of the transaction in the block to which it has been added.
value
value
Every transaction has an attached value which is the amount that is being transferred from the sender to the receiver. The value
returns this quantity and is shown in Wei.
r,s
r,s
Ethereum uses ECDSA (Elliptic Curve Digital Signature Algorithm) to create digital signatures of a transaction. These signatures are used to verify that they are authentic and coming from the correct sender, much like a real signature.
A digital signature can be divided into two numbers - r
and s
. These numbers are generated by your private key. By sending s
through an algorithm, you should get the value of R
which is used to validate the signature.
v
v
ECDSA uses the v
value to recover the correct public key when performing validation on the signature of the transactions. It is a combination of:
- recovery_id - the position on the curve that is used by ECDSA to generate the keys.
- chain_id - the Ethereum Network ID (ex: 1 - Ethereum Mainnet).
Updated about 2 years ago