TriportRPC

eth_getTransactionByBlockNumberAndIndex

POSThttps://api.triport.io/v1/ethereum

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

Ethereumeth_read_rpcfree 10 RPS · basic 20 RPS · pro 100 RPS · business 250 RPS

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
-32001trial_expiredThe account's trial period has ended.
-32003rate_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://api.triport.io/v1/ethereum", {
  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);

TypeScript SDK (@triport/sdk)

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


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


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


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

Python (triport-sdk)

import os
from triport import Triport


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


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

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 tier (eth_read_rpc category).
  • Rate limiting is RPS-per-tier with burst; there is no daily quota. A -32003 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.