OnFinality
New RPC users get 35% off their first monthView the offer
OnFinality Learn
Network & Protocol Guides4 min read

How to Read a Historical Bittensor Metagraph at a Specific Block

Read a Bittensor subnet metagraph at a fixed Finney block with Python. Verify the raw state against a recorded hash and diagnose a pruned-node response.

TL;DR

To reproduce a historical subnet snapshot on Finney, fix the netuid and block height, then read the metagraph through an archive endpoint. The block hash identifies the snapshot; a state query at that hash tests whether the node can serve it.

Choose the snapshot you want to reproduce

Suppose an indexer missed a day and needs the hotkeys registered in subnet 1 at block 9,000,000. Querying the current metagraph can include registrations that happened later. Record the network, netuid, finalized height and block hash alongside the result. A UID identifies a position within that subnet at that block; keep the hotkey when comparing membership across snapshots.

If your error contains “State already discarded”, rerun on the archive preset with the same netuid and block. This example gives a concrete check: the decoded snapshot should contain 256 hotkeys.

Historical subnet snapshots

Pin netuid and finalized block hash before comparing metagraph exports. Store hotkeys alongside UIDs so changes in subnet membership can be tracked across snapshots.

Network connection settings

Read the decoded snapshot with the Python SDK

This example uses the Bittensor v10 SDK and its archive network preset. Inspect graph.hotkeys for membership. The lite argument requests a smaller metagraph from the archive node; omit weights and bonds from comparisons made with this example. To calculate historical weights, request the full metagraph separately.

On 1 December 2026, Python SDK 10.5.0 printed “1 9000000 256”: subnet 1, block 9,000,000, and 256 hotkeys. This is a membership snapshot. To reconstruct a price series, you would also need pool state and a sampling schedule.

import bittensor as bt

with bt.Subtensor(network="archive") as chain:
    graph = chain.metagraph(netuid=1, block=9_000_000, lite=True)
    print(graph.netuid, int(graph.block), len(graph.hotkeys))

Verify the same historical read without the SDK

Run this Python 3 script with curl on your PATH. It resolves the height and calls the runtime API at that exact hash. For this runtime the subnet argument is a SCALE-encoded u16 in little-endian order. The output fingerprints the raw lite neuron records; the SDK above presents decoded fields. To test your own HTTP endpoint, set FINNEY_HTTP before running.

import hashlib
import json
import os
import subprocess

url = os.environ.get("FINNEY_HTTP", "https://archive.chain.opentensor.ai")

def rpc(method, params):
    body = json.dumps({"jsonrpc": "2.0", "id": 1, "method": method, "params": params})
    data = subprocess.check_output(["curl", "-fsS", "--max-time", "30", url,
                                   "-H", "Content-Type: application/json", "-d", body])
    reply = json.loads(data)
    if "error" in reply:
        raise RuntimeError(reply["error"])
    return reply["result"]

height, netuid = 9_000_000, 1
block_hash = rpc("chain_getBlockHash", [height])
if not block_hash:
    raise ValueError("Block hash unavailable")
subnet = "0x" + netuid.to_bytes(2, "little").hex()
encoded = rpc("state_call", ["NeuronInfoRuntimeApi_get_neurons_lite", subnet, block_hash])
payload = bytes.fromhex(encoded[2:])
print(block_hash, len(payload), hashlib.sha256(payload).hexdigest(), sep="\n")

Compare archive and lite results

On 1 December 2026, the public Finney archive returned the three lines below. The public lite endpoint at https://lite.chain.opentensor.ai returned JSON-RPC error 4003, “State already discarded”, for the same state_call and hash. Repeating that call on the same pruned node cannot recover discarded state.

0xb74e4c13c6de2089064079fdfc1f6b70f1e184e46339cf270e72722ce222b105
46973
f6ada57ed833b62c4f708566426d6406cb54e4e3577993054f176173eaf1036f

Diagnose a different result before starting a backfill

Check the block hash first. A different hash means you are comparing different inputs. If the node knows the hash but rejects state_call, keep the error message: discarded state calls for archive access; an unknown runtime method calls for checking the runtime API at that height. For an empty neuron list, verify the netuid existed then. For a timeout, repeat a small finalized-head read before retrying the larger query. Save successful snapshots by network, netuid and hash so a restart can resume from the last verified result.

For connection options, see Finney RPC endpoints. For field definitions, see metagraph weights and emissions. The Bittensor node guide documents v10 archive reads.

Never Worry about Infrastructure Again

OnFinality takes away the heavy lifting of DevOps so you can build smarter and faster.

Get Started