TriportRPC

eth_getUncleByBlockHashAndIndex

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

Returns the uncle (ommer) block at a given index within a block addressed by its 32-byte hash, or `null` if there is no uncle at that position.

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

eth_getUncleByBlockHashAndIndex looks up an uncle block (also called an ommer) by the hash of the block that references it and the uncle's position in that block's uncles array. It returns a block header object describing the uncle, or null when the index is out of range or the referencing block is unknown to the node.

Uncles only exist on the pre-Merge, proof-of-work chain. Before the Merge, two miners could produce a valid block at the same height; the canonical chain included one and could reward the other as an uncle. After the Merge (September 2022), Ethereum's proof-of-stake consensus produces exactly one block per slot, so post-Merge blocks have no uncles. For any block at or after the Merge this method returns null, and the uncles array on such blocks is always empty.

The returned object is a block header — it carries the uncle's own hash, number, miner, and roots, but it does not include the uncle's transactions (uncle transactions are never executed or rewarded).

Parameters

Positional params array: [blockHash, uncleIndex].

blockHashstring (32-byte hex)required
Hash of the block whose uncle you want, 0x-prefixed (66 characters total).
uncleIndexstring (hex)required
Zero-based index into the referencing block's uncles array, encoded as a 0x-prefixed hex quantity (e.g. "0x0" for the first uncle).

Response

For a pre-Merge block that has an uncle at the requested index, result is the uncle's block-header object:

For a post-Merge block, an out-of-range index, or an unknown block hash, the call succeeds with result: null:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}
numberstring (hex)
Block number of the uncle.
hashstring (hex)
Hash of the uncle block.
parentHashstring (hex)
Hash of the uncle's parent block.
noncestring (hex)
Proof-of-work nonce of the uncle.
sha3Unclesstring (hex)
Keccak-256 of the uncle's own uncles data.
logsBloomstring (hex)
Bloom filter for the uncle's logs.
transactionsRootstring (hex)
Root of the uncle's transaction trie.
stateRootstring (hex)
Root of the uncle's final state trie.
receiptsRootstring (hex)
Root of the uncle's receipts trie.
minerstring (hex)
Address that mined the uncle.
difficultystring (hex)
Difficulty of the uncle block.
totalDifficultystring (hex)
Total chain difficulty up to the uncle.
extraDatastring (hex)
Arbitrary extra data field of the uncle.
sizestring (hex)
Uncle header size in bytes.
gasLimitstring (hex)
Maximum gas that was allowed in the uncle.
gasUsedstring (hex)
Gas used in the uncle.
timestampstring (hex)
Unix timestamp of when the uncle was collated.

Errors

CodeMeaningWhen it happens
-32001trial_expiredThe API key's trial period has ended; upgrade to a paid tier to continue.
-32003rate_limitedPer-tier RPS limit exceeded (10 / 20 / 100 / 250 RPS for free / basic / pro / business). Back off and retry after retry_after_sec.
-32602Invalid paramsblockHash is not a 32-byte hex string, or uncleIndex is missing or not a hex quantity.

A missing uncle, an out-of-range index, and a post-Merge block are not errors — the call returns result: null. Every error follows the shared JSON-RPC error envelope — see Errors for the full structure 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_getUncleByBlockHashAndIndex",
    params: [
      "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
      "0x0",
    ],
  }),
});


const { result: uncle } = await res.json();
if (uncle === null) {
  console.log("no uncle at that index (post-Merge blocks never have uncles)");
} else {
  console.log(`uncle #${BigInt(uncle.number)} mined by ${uncle.miner}`);
}

TypeScript SDK (@triport/sdk)

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


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


const uncle = await triport.ethereum.getUncleByBlockHashAndIndex(
  "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
  0, // uncle index — encoded as the hex quantity "0x0" on the wire
);


if (uncle) {
  console.log(`uncle #${BigInt(uncle.number)} mined by ${uncle.miner}`);
}

Python (triport-sdk)

import os
from triport import Triport


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


uncle = triport.ethereum.get_uncle_by_block_hash_and_index(
    "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
    0,
)


if uncle is not None:
    print(f"uncle #{int(uncle['number'], 16)} mined by {uncle['miner']}")

Notes

  • Post-Merge blocks have no uncles. Proof-of-stake produces one block per slot, so for any block at or after the Merge this method always returns null. Uncles are only present on the historical proof-of-work chain.
  • null is not an error. An out-of-range index or an unknown block hash returns result: null. Guard for it before reading any field.
  • Header only, no transactions. The returned object is the uncle's header; it has no transaction list because uncle transactions are never executed.
  • Find the count first. Use eth_getUncleCountByBlockHash to learn how many uncles a block has before indexing into them.
  • Related methods: eth_getUncleByBlockNumberAndIndex, eth_getBlockByHash, eth_getUncleCountByBlockHash.