Unichain

Unichain

eth_getTransactionByBlockNumberAndIndex

The eth_getTransactionByBlockNumberAndIndex method returns detailed information about a transaction by specifying its position (index) within a block identified by the block's number or tag. This method is particularly useful for retrieving transactions from known block heights or special blocks like "latest".

Use Cases

  • Real-time transaction monitoring
  • Block explorer functionality
  • Specific transaction analysis
  • Historical data extraction
  • Transaction verification
  • Sequential transaction processing
  • Smart contract interaction analysis
  • Mempool investigation (using "pending" tag)

Method Details

This method locates a transaction using both a block number (or tag) and the transaction's index within that block.

Response Example

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x0f2c90d18695045ede8b52476bba47db4c99ad8e9c748dd64147dcb698e88d5f",
"blockNumber": "0x1194bb0",
"from": "0xef3a770aec2e5e97994c8f0e283e7992e2c39a2a",
"gas": "0x2b13c",
"gasPrice": "0x342770c00",
"maxFeePerGas": "0x342770c00",
"maxPriorityFeePerGas": "0x3b9aca00",
"hash": "0xa1c2c6b23cec00cdfa10a2bc30357c4250a2efb3cdf3c4d5c71e8b90ccb9071d",
"input": "0x095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"nonce": "0x1a8",
"to": "0x6982508145454ce325ddbe47a25d4ec3d2311933",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x2",
"accessList": [],
"chainId": "0x1",
"v": "0x1",
"r": "0xea5232855738e1c0d1a6695f0a0c76de2db3c6c84eec9d7b7f4523d8dc0db1d5",
"s": "0x2fd0b585c8e8df25e2e95ca8afe94b2d84a4c298d1e526f9afa0c2f1d492cd0d"
}
}

Block Tag Meanings

  • latest: The most recently mined block
  • earliest: Genesis block (block 0)
  • pending: Currently pending block (transactions in mempool)
  • safe: Latest block considered safe by network
  • finalized: Latest block that has achieved finality

See also

Parameters

Block number in hex format or tags: latest, earliest, pending, safe, finalized

The transaction's index position in the block (hexadecimal)

curl https://unichain.therpc.io \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_getTransactionByBlockNumberAndIndex","params":["0x1194BB0","0x0"]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.