TriportRPC

eth_getTransactionByBlockNumberAndIndex

POSThttps://api.triport.io/polygon

Returns a single Polygon transaction selected by its block (number or tag) and its zero-based position within that block.

Polygonpolygon_read_rpcfree (and up) — 15 rps (free) · 20 rps (basic) · 100 rps (pro) · 250 rps (business); burst = 2 × the sustained rps

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
A hex-encoded block number (e.g. "0x3b9aca00") or a tag: latest, earliest, pending, safe, or finalized.
transactionIndexstringrequired
The zero-based position of the transaction in the block, as a 0x-prefixed hex integer (e.g. "0x0" for the first transaction).

Response

Response fields

FieldTypeDescription
jsonrpcstringJSON-RPC version, always "2.0".
idnumberEchoes the request id.
resultobject | nullThe 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:

FieldTypeDescription
blockHashstringHash of the containing block; null if pending.
blockNumberstring (hex)Block number; null if pending.
fromstringSender address.
tostring | nullRecipient address; null for contract-creation transactions.
gasstring (hex)Gas supplied by the sender.
gasPricestring (hex)Effective gas price, in wei.
maxFeePerGasstring (hex)Max fee per gas — present on EIP-1559 (type 0x2) transactions.
maxPriorityFeePerGasstring (hex)Max priority fee per gas — present on EIP-1559 transactions.
hashstringTransaction hash.
inputstringCall data, hex.
noncestring (hex)Sender nonce.
transactionIndexstring (hex)Index of the transaction in the block.
valuestring (hex)Value transferred, in wei.
typestringTransaction 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

Errors arrive in the standard JSON-RPC error object; the extra fields move into error.data.

CodeMeaningWhen it happens
-32001trial_expiredThe free 7-day trial has ended.
-32002tier_insufficientYour tier is below what the method requires. (Not expected here — this method is free-tier.)
-32003rate_limitedYou exceeded the sustained rps for your tier; respect Retry-After / data.retry_after_sec.
-32004subscription_expiredA previously active paid subscription has lapsed.
-32005unauthorizedMissing, invalid, or revoked credentials.
-32601method_unknownThe 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://api.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);

TypeScript SDK (@triport/sdk)

import { Triport } from "@triport/sdk";


const client = new Triport({ token: process.env.TRIPORT_API_KEY! });


type Transaction = { hash: string; from: string; to: string | null; value: string };


const tx = await client.polygon.rpc<Transaction | null>(
  "eth_getTransactionByBlockNumberAndIndex",
  ["0x3b9aca00", "0x0"],
);
console.log(tx?.hash ?? "no such transaction");

Python (triport-sdk)

import os
from triport import Triport


client = Triport(token=os.environ["TRIPORT_API_KEY"])


tx = client.polygon.rpc(
    "eth_getTransactionByBlockNumberAndIndex",
    ["latest", "0x0"],
)
print(tx["hash"] if tx else "no such transaction")

Notes

  • Zero-based index. 0x0 is the first transaction in the block. Use eth_getBlockTransactionCountByNumber to 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 for null before 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. chainId is 0x89 (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).