Ethereum

Ethereum

eth_getTransactionByBlockNumberAndIndex

eth_getTransactionByBlockNumberAndIndex returns the transaction at a given position inside a block, with the block addressed by its height or by a tag like latest, finalized, or pending. It's the sibling of the by-hash lookup, but keyed on number instead of hash, which is what you usually want for scanning forward through Ethereum mainnet (chain ID 1, gas paid in ETH) where heights are simple to iterate. Give it a block number and a zero-based hex index, and the node returns the full transaction object sitting at that slot, the same shape eth_getTransactionByHash produces. Querying by number lets you reach symbolic tags like pending that no fixed hash exists for. The endpoint is https://ethereum.therpc.io/YOUR_API_KEY.

Use cases

  • March block by block pulling index 0x0 from each height to study top-of-block placement, the slot MEV researchers care about most.
  • Peek at the pending block's contents by index to see what a client expects to include next from the mempool before the slot is sealed.
  • Scan sequentially over a known height range when you have block numbers in hand and don't need to resolve a hash first — incrementing a counter is cheaper than tracking hashes.

Parameters

#NameTypeRequiredDescription
1blockTagstringYesThe block containing the transaction.
2transactionIndexstring (hex)YesZero-based position of the transaction within the block.

Response

TypeDescription
object | nullSame transaction object as eth_getTransactionByHash. Returns null if block or index not found.

Example request

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

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32602Invalid paramsBlock tag is malformed or transaction index is not a valid hex integer.

Common pitfalls

  • The index is hex-encoded: "0x0" for the first transaction, never a decimal 0. Same goes for higher positions — "0xf", not 15.
  • The pending block is a client's local guess, not a finalized fact. Its ordering and even which transactions appear differ between geth, erigon, nethermind and besu, so don't treat a pending-tag result as canonical.

Supported networks

  • Mainnet — Chain ID: 1
  • Sepolia — Chain ID: 11155111

See also

Parameters

hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"

0x-prefixed hex integer (e.g. "0x0" for the first transaction)

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

Ready to call this in production?

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