TriportRPC

eth_getTransactionByBlockHashAndIndex

Polygon / https://triport.io/polygon

Minimum tier: Free

Polygon method guide

Last updated:

eth_getTransactionByBlockHashAndIndex looks up a Polygon block by its 32-byte hash and returns the one transaction sitting at the supplied zero-based index within that block. The transaction comes back as the standard Ethereum/Bor transaction object.

Use it when you already hold a block hash — from a log, a receipt's blockHash, or a prior eth_getBlockByHash response — and want to walk that block's transactions one at a time without downloading the full block body. It is a common primitive for block-by-block indexers: pair it with eth_getBlockTransactionCountByHash to read the transaction count, then iterate 0x0 … count-1, fetching each transaction by index. Addressing by hash (rather than by number) is unambiguous — a hash pins exactly one block even across a reorganization.

If the block hash is unknown to the node (for example a block it has not yet seen, or one orphaned by a reorg) or the index is out of range for the block, the method succeeds and returns null rather than 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://triport.io/polygon \
  -X POST -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <api-key>' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getTransactionByBlockHashAndIndex","params":[]}'
const res = await fetch("https://triport.io/polygon", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
  body: JSON.stringify({
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getTransactionByBlockHashAndIndex",
  "params": []
}),
});
const data = await res.json();
import requests
resp = requests.post(
    "https://triport.io/polygon",
    headers={"Authorization": "Bearer <api-key>"},
    json={"jsonrpc":"2.0","id":1,"method":"eth_getTransactionByBlockHashAndIndex","params":[]},
)
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Chain: Polygon.
  3. Clusters: mainnet.
  4. Credit cost: 1 per call.

FAQ

What does eth_getTransactionByBlockHashAndIndex do?
Returns a single Polygon transaction by the hash of its block and its zero-based position within that block.
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.