eth_getTransactionByBlockNumberAndIndex — Ethereum JSON-RPC

Status: Available

Returns the transaction at a given position within the block identified by its number or a block tag.

POSThttps://triport.io/eth
Network
Ethereum
Scope
eth_read_rpc
Auth
x-token: $TRIPORT_API_KEY (or Authorization: Bearer)
Rate limit
free 10 RPS sustained · up to 20 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: Ethereum RPC endpoint.

eth_getTransactionByBlockNumberAndIndex returns a single transaction object selected by two coordinates: the block (by number or block tag) and the transaction's zero-based index within that block. Both the block number and the index are 0x-prefixed hexadecimal strings.

Use it when you already know a transaction's position in a block — for example when iterating a block's transactions one at a time, when you have the index from a prior eth_getBlockByNumber call, or when reconstructing a block body without fetching every transaction at once. If you have the block hash rather than its number, use the sibling method eth_getTransactionByBlockHashAndIndex. If you have the transaction hash directly, use eth_getTransactionByHash.

If the block does not exist, or the index is out of range for that block, the result is null rather than an error.

Parameters

Pass a two-element positional array.

blockParameterstringrequired
Either a 0x-prefixed hex block number (e.g. 0x149e2c1) or a block 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 contains the standard Ethereum fields:

FieldTypeDescription
blockHashstringHash of the containing block, or null if pending.
blockNumberstringBlock number as 0x-prefixed hex, or null if pending.
fromstringSender address.
tostring | nullRecipient address; null for contract-creation transactions.
gasstringGas supplied, hex.
gasPricestringEffective gas price, hex (in wei).
maxFeePerGasstringMax fee per gas, hex — present on EIP-1559 (type 0x2) transactions.
maxPriorityFeePerGasstringMax priority fee per gas, hex — present on EIP-1559 transactions.
hashstringTransaction hash.
inputstringCall data, hex.
noncestringSender nonce, hex.
transactionIndexstringIndex of the transaction in the block, hex.
valuestringValue transferred in wei, hex.
typestringTransaction type (0x0 legacy, 0x1 access-list, 0x2 EIP-1559).
chainIdstringChain ID, hex (0x1 for Ethereum mainnet).
v, r, sstringECDSA signature components, hex.

Errors

CodeMeaningWhen it happens
401trial_expiredThe account's trial period has ended.
429rate_limitedThe per-tier RPS limit was exceeded. Back off and retry.
-32602invalid_paramsThe block parameter or index is missing, or not a valid hex value / tag.

See errors.md for the full error envelope and handling guidance.

Examples

JavaScript (fetch)

const res = await fetch("https://triport.io/eth", {
  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 } = await res.json();
console.log(result === null ? "no such transaction" : result.hash);

Notes

  • The index is zero-based: 0x0 is the first transaction in the block.
  • An out-of-range index or a non-existent block returns result: null, not an error — check for null before reading fields.
  • Numeric fields (value, gas, gasPrice, nonce, …) are hex strings; convert with base 16 before arithmetic.
  • eth_getTransactionByBlockNumberAndIndex is available on the Free trial (eth_read_rpc category).
  • Rate limiting is RPS-per-tier with burst; there is no daily quota. An HTTP 429 rate_limited error means you should back off and retry shortly.
  • To select by block hash instead, use eth_getTransactionByBlockHashAndIndex. To look up a transaction by its own hash, use eth_getTransactionByHash. To count a block's transactions first, use eth_getBlockTransactionCountByNumber.