eth_getTransactionByBlockNumberAndIndex — Polygon JSON-RPC
Returns a single Polygon transaction selected by its block (number or tag) and its zero-based position within that block.
https://triport.io/polygon- Network
- Polygon
- Scope
- polygon_read_rpc
- Auth
- x-token: $TRIPORT_API_KEY (or Authorization: Bearer) (the x-token: $TRIPORT_API_KEY header is also accepted)
- Rate limit
- free (and up) — 15 rps (free) · 20 rps (basic) · 100 rps (pro) · 250 rps (business); burst = 2 × the sustained rps
Endpoint and plans: Polygon RPC endpoint.
eth_getTransactionByBlockNumberAndIndex returns one transaction identified by
two coordinates: the block (given as a hex-encoded block number or one of the
tags latest, earliest, pending, safe, finalized) and the transaction's
zero-based index within that block. Both parameters are passed as 0x-prefixed
hex strings.
Reach for it when you already know a transaction's slot in a block — for example
while iterating a Polygon block transaction-by-transaction, or when you have an
index from a prior eth_getBlockByNumber call and
want only that one body rather than the whole block. This is the by-number
counterpart of eth_getTransactionByBlockHashAndIndex; use that sibling when you
hold the block hash instead, or eth_getTransactionByHash
when you already have the transaction's own hash.
Polygon runs Bor consensus with a ~2.1 s block time, so a typical block carries
roughly 50–150 transactions. If the block does not exist, or the index is out of
range for that block, result is null rather than an error — check for null
before reading fields.
Parameters
Positional params array: [blockNumber, transactionIndex].
blockNumberstringrequired"0x3b9aca00") or a tag: latest, earliest, pending, safe, or finalized.transactionIndexstringrequired0x-prefixed hex integer (e.g. "0x0" for the first transaction).Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC version, always "2.0". |
id | number | Echoes the request id. |
result | object | null | The transaction object, or null if the block was not found or the index is out of range. |
The transaction object carries the standard EVM fields:
| Field | Type | Description |
|---|---|---|
blockHash | string | Hash of the containing block; null if pending. |
blockNumber | string (hex) | Block number; null if pending. |
from | string | Sender address. |
to | string | null | Recipient address; null for contract-creation transactions. |
gas | string (hex) | Gas supplied by the sender. |
gasPrice | string (hex) | Effective gas price, in wei. |
maxFeePerGas | string (hex) | Max fee per gas — present on EIP-1559 (type 0x2) transactions. |
maxPriorityFeePerGas | string (hex) | Max priority fee per gas — present on EIP-1559 transactions. |
hash | string | Transaction hash. |
input | string | Call data, hex. |
nonce | string (hex) | Sender nonce. |
transactionIndex | string (hex) | Index of the transaction in the block. |
value | string (hex) | Value transferred, in wei. |
type | string | Transaction type (0x0 legacy, 0x1 access-list, 0x2 EIP-1559). |
chainId | string (hex) | Chain ID — 0x89 (137) for Polygon mainnet. |
v, r, s | string (hex) | ECDSA signature components. |
Errors
Errors arrive in the standard JSON-RPC error object; the extra fields move
into error.data.
| Code | Meaning | When it happens |
|---|---|---|
401 | trial_expired | The free 7-day trial has ended. |
403 | tier_insufficient | Your tier is below what the method requires. (Not expected here — this method is included in the Free trial.) |
429 | rate_limited | You exceeded the sustained rps for your tier; respect Retry-After / data.retry_after_sec. |
401 | subscription_expired | A previously active paid subscription has lapsed. |
401 | unauthorized | Missing, invalid, or revoked credentials. |
HTTP 403 | method_unknown | The method name was not recognised on the polygon chain. |
A missing block or an out-of-range index is not an error — it returns
result: null. See the shared Errors reference for the full
envelope, the HTTP-status mapping, and error.data field definitions.
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_getTransactionByBlockNumberAndIndex",
params: ["latest", "0x0"],
}),
});
const { result, error } = await res.json();
if (error) throw new Error(`${error.code}: ${error.message}`);
console.log(result === null ? "no such transaction" : result.hash);Notes
- Zero-based index.
0x0is the first transaction in the block. Useeth_getBlockTransactionCountByNumberto learn the valid index range first. - Null on miss. An out-of-range index or a non-existent block returns
result: null, not an error — guard fornullbefore reading fields. - Hex numerics.
value,gas,gasPrice,nonce, … are hex strings; convert with base 16 before doing arithmetic. Values are in wei. - Polygon chain ID.
chainIdis0x89(137) for Polygon mainnet. - No daily cap. Rate limiting is sustained-rps-per-tier with a 2× burst allowance — there is no daily quota. See Rate limits.
- Related:
eth_getTransactionByBlockHashAndIndex(same lookup, by block hash) ·eth_getTransactionByHash(by transaction hash) ·eth_getBlockByNumber(the whole block at once).