Ethereum

Ethereum

eth_getTransactionByBlockHashAndIndex

eth_getTransactionByBlockHashAndIndex fetches a single transaction by where it sits, not by what it is. You name a block by its hash and a zero-based position within that block, and Ethereum mainnet (chain ID 1, fees denominated in ETH) returns the full transaction object at that slot. The order matters here: a validator fixes the transaction ordering when it seals the block, and that order is exactly what this index walks. It's the same transaction object you'd get from eth_getTransactionByHash, just addressed positionally. Querying by block hash rather than number means you're pinned to one specific block even across a reorg. Send the call to https://ethereum.therpc.io/YOUR_API_KEY.

Use cases

  • Walk a block's transactions in order by incrementing the index from 0x0 until you hit null, when you already have the block hash but not the individual tx hashes.
  • Pull the first transaction in a block to study ordering — the top slot is where MEV searchers and builders fight to land arbitrage and liquidation bundles.
  • Resolve a transaction by its position reference (block hash plus index) when that's how it was cited, instead of needing its hash up front.

Parameters

#NameTypeRequiredDescription
1blockHashstring (hex)YesThe hash of the 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_getTransactionByBlockHashAndIndex",
"params": [
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0"
],
"id": 1
}'

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32602Invalid paramsBlock hash or transaction index is malformed.

Common pitfalls

  • The index is hex, not decimal. The first transaction is "0x0", the eleventh is "0xa" — passing a bare 0 or a decimal 10 will misfire.
  • Run the index past the block's last transaction and you get null, not an error. Pair this with eth_getBlockTransactionCountByNumber, or just treat null as your stop condition when enumerating.

Supported networks

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

See also

Parameters

0x-prefixed 32-byte block hash

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_getTransactionByBlockHashAndIndex","params":["0x0000000000000000000000000000000000000000000000000000000000000000","0x0"]}'

Ready to call this in production?

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