TriportRPC

eth_getTransactionByBlockHashAndIndex

Last updated:

`eth_getTransactionByBlockHashAndIndex` locates a block by its 32-byte hash and returns the single transaction sitting at the supplied zero-based index within that block. The transaction is returned as the standard Ethereum transaction object.

Use it when you already hold a block hash — from a log, a receipt, or an `eth_getBlockByHash` response — and want to walk that block's transactions one at a time without downloading the full block body. Pair it with [`eth_getBlockTransactionCountByHash`](eth_getBlockTransactionCountByHash.md): fetch the count, then iterate `0 … count-1`, requesting each transaction by index.

If the block hash is unknown (e.g. an orphaned/uncle block, or a block the node has not yet seen) or the index is out of range for the block, the method returns `null` instead of an error. Always check for `null` before reading fields off the result.

Parameters

This method takes no parameters.

Returns

eth_getTransactionByBlockHashAndIndex return value
FieldType
resultobject

Examples

curl https://<your-endpoint>/ \
  -X POST -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getTransactionByBlockHashAndIndex","params":[]}'
const res = await fetch("https://<your-endpoint>/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "id": 1,
  "method": "eth_getTransactionByBlockHashAndIndex",
  "params": [],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"eth_getTransactionByBlockHashAndIndex","params":[],"jsonrpc":"2.0"})
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet.
  3. Credit cost: 1 per call.

FAQ

What does eth_getTransactionByBlockHashAndIndex do?
Returns the transaction at a given position inside the block identified by its block hash.
How many credits does eth_getTransactionByBlockHashAndIndex cost?
eth_getTransactionByBlockHashAndIndex costs 1 credit(s) per call on Triport by default.
Is eth_getTransactionByBlockHashAndIndex available over WebSocket?
eth_getTransactionByBlockHashAndIndex is an HTTP JSON-RPC method.