eth_getTransactionByBlockHashAndIndex — Polygon JSON-RPC

Status: Available

Returns a single Polygon transaction by the hash of its block and its zero-based position within that block.

POSThttps://triport.io/polygon
Network
Polygon
Scope
polygon_read_rpc
Auth
x-token: $TRIPORT_API_KEY (or Authorization: Bearer)
Rate limit
free — 15 RPS sustained · up to 30 burst · basic — 20 RPS sustained · up to 40 burst · pro — 100 RPS sustained · up to 200 burst · business — 250 RPS sustained · up to 500 burst; Burst capacity

Endpoint and plans: Polygon RPC endpoint.

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

Positional params array: [blockHash, index].

blockHashstring (32-byte hex)required
Hash of the block, 0x-prefixed (66 characters total).
indexstring (hex)required
Zero-based transaction position within the block, as a 0x-prefixed hexadecimal integer (e.g. 0x0 for the first transaction).

Response

When the block hash is unknown or the index is out of range, the result is null:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}
hashstring (hex)
32-byte transaction hash.
blockHashstring (hex)
Hash of the block containing the transaction (echoes the request).
blockNumberstring (hex)
Block height, 0x-prefixed.
transactionIndexstring (hex)
Position of the transaction in the block (echoes the request index).
noncestring (hex)
Sender's transaction count prior to this transaction.
fromstring (hex)
20-byte sender address.
tostring (hex) | null
20-byte recipient address, or null for a contract-creation transaction.
valuestring (hex)
Value transferred in wei.
gasstring (hex)
Gas supplied by the sender.
gasPricestring (hex)
Effective gas price in wei.
maxFeePerGasstring (hex)
EIP-1559 max fee per gas in wei (type 0x2 transactions).
maxPriorityFeePerGasstring (hex)
EIP-1559 max priority fee per gas in wei (type 0x2 transactions).
inputstring (hex)
Call data sent with the transaction.
typestring (hex)
Transaction type — 0x0 legacy, 0x1 access-list, 0x2 EIP-1559.
chainIdstring (hex)
Chain ID — 0x89 (137) for Polygon mainnet.
v, r, sstring (hex)
ECDSA signature components.

Errors

CodeMeaningWhen it happens
401trial_expiredThe API key's trial period has ended; upgrade to a paid tier to continue.
403tier_insufficientThe key's tier is below the level required for this method.
429rate_limitedPer-tier RPS limit exceeded (15 / 20 / 100 / 250 RPS sustained · short burst 30 / 40 / 200 / 500 for free / basic / pro / business). Back off and retry.
401subscription_expiredThe subscription tied to the key has lapsed.
401unauthorizedMissing, malformed, or invalid API key.
HTTP 403method_unknownThe method name is not recognized on this path.

An unknown block hash or an out-of-range index is not an error — it is reported as result: null (see above). Every error follows the shared JSON-RPC error envelope — see Errors for the full structure and handling guidance.

Examples

JavaScript (fetch)

const res = await fetch("https://triport.io/polygon", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "eth_getTransactionByBlockHashAndIndex",
    params: [
      "0x9b7f2a3c1d4e5f60718293a4b5c6d7e8f90123456789abcdef0123456789abcd",
      "0x0",
    ],
  }),
});


const { result } = await res.json();
console.log(result === null ? "no transaction at that index" : result.hash);

Notes

  • index is hex, not decimal. Pass 0x0, 0x1, … — not 0, 1.
  • Always handle null. An unknown block hash or an out-of-range index returns result: null rather than an error. Guard for it before reading any field.
  • Indexer iteration pattern. Read the transaction count with eth_getBlockTransactionCountByHash, then request indices 0x0 through count-1. When you need every transaction in a block at once, fetching the full block with eth_getBlockByHash (fullTxBodies = true) is cheaper than many per-index calls.
  • EIP-1559 fee fields. maxFeePerGas and maxPriorityFeePerGas appear only on type 0x2 transactions; legacy transactions expose gasPrice only.
  • Rate limiting is RPS-per-tier with a burst allowance; there is no daily quota. An HTTP 429 rate_limited response means you should back off and retry shortly.
  • Related methods: eth_getTransactionByBlockNumberAndIndex (same lookup by block number), eth_getTransactionByHash (look up directly by transaction hash), eth_getBlockTransactionCountByHash.