TriportRPC

eth_getTransactionByBlockHashAndIndex

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

Returns the transaction at a given position inside the block identified by its block hash.

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

eth_getTransactionByBlockHashAndIndex locates a block by its 32-byte hash and returns the single transaction sitting at the supplied zero-based index within that block. The transaction is returned as the standard Ethereum transaction object.

Use it when you already hold a block hash — from a log, a receipt, or an eth_getBlockByHash response — and want to walk that block's transactions one at a time without downloading the full block body. Pair it with eth_getBlockTransactionCountByHash: fetch the count, then iterate 0 … count-1, requesting each transaction by index.

If the block hash is unknown (e.g. an orphaned/uncle block, or a block the node has not yet seen) or the index is out of range for the block, the method returns null instead of an error. Always check for null before reading fields off the result.

Parameters

Two positional parameters, in order.

blockHashstringrequired
32-byte block hash, 0x-prefixed (66 characters total).
indexstringrequired
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
32-byte transaction hash.
blockHashstring
Hash of the block containing the transaction (echoes the request).
blockNumberstring
Block height as 0x-prefixed hex.
transactionIndexstring
Position of the transaction in the block, as 0x-prefixed hex (echoes the request index).
noncestring
Sender's transaction count prior to this transaction, hex.
fromstring
20-byte sender address.
tostring | null
20-byte recipient address, or null for a contract-creation transaction.
valuestring
Value transferred in wei, 0x-prefixed hex.
gasstring
Gas supplied by the sender, hex.
gasPricestring
Effective gas price in wei, hex.
maxFeePerGasstring
EIP-1559 max fee per gas in wei, hex (type 0x2 transactions).
maxPriorityFeePerGasstring
EIP-1559 max priority fee per gas in wei, hex (type 0x2 transactions).
inputstring
Call data sent with the transaction.
typestring
Transaction type — 0x0 legacy, 0x1 access-list, 0x2 EIP-1559.
chainIdstring
Chain ID, hex (0x1 for Ethereum mainnet).
v, r, sstring
ECDSA signature components.

Errors

CodeMeaningWhen it happens
-32001trial_expiredThe account's trial period has ended.
-32003rate_limitedThe per-tier RPS limit was exceeded. Back off and retry.

A missing block or out-of-range index is not an error — it is reported as result: null (see above). A -32003 response carries Retry-After and X-RateLimit-Reset headers plus a data object with limit_rps, burst_capacity, and retry_after_sec. 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_getTransactionByBlockHashAndIndex",
    params: [
      "0xb9b8b8b1b0c9e6a0f3d4c5b6a7988e9d0c1b2a3948576f5e4d3c2b1a09876543",
      "0x0",
    ],
  }),
});


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

TypeScript SDK (@triport/sdk)

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


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


const tx = await client.ethereum.request<Record<string, unknown> | null>(
  "eth_getTransactionByBlockHashAndIndex",
  [
    "0xb9b8b8b1b0c9e6a0f3d4c5b6a7988e9d0c1b2a3948576f5e4d3c2b1a09876543",
    "0x0",
  ],
);
console.log(tx === null ? "no transaction at that index" : tx.hash);

Python (triport-sdk)

import os
from triport import Triport


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


tx = client.ethereum.request(
    "eth_getTransactionByBlockHashAndIndex",
    [
        "0xb9b8b8b1b0c9e6a0f3d4c5b6a7988e9d0c1b2a3948576f5e4d3c2b1a09876543",
        "0x0",
    ],
)
print("no transaction at that index" if tx is None else tx["hash"])

Notes

  • The index is a hex string (0x0, 0x1, …), not a decimal number.
  • Always handle the null case: an unknown block hash or an out-of-range index returns result: null rather than an error.
  • EIP-1559 fee fields (maxFeePerGas, maxPriorityFeePerGas) appear only on type 0x2 transactions; legacy transactions expose gasPrice only.
  • 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 fetch the same transaction by block height instead of hash, use eth_getTransactionByBlockNumberAndIndex. To look a transaction up directly by its hash, use eth_getTransactionByHash. To learn how many transactions a block holds, use eth_getBlockTransactionCountByHash.