BlockHash

Storage Map v101 → current

Maps block numbers to their hashes.

Explore chain
Queried by: developersanalyticsvalidators

The Big Picture

Only keeps last BlockHashCount hashes. For older history, use archive nodes.

Use Cases

  • Verify transactions in specific blocks
  • Build historical proofs

From Chain Metadata

Map of block numbers to block hashes.

Purpose & Usage

Purpose

Historical block lookup within retention window.

Common Query Patterns

  • Query hash by block number
  • Verify block inclusion

Query Keys

#NameTypeDescription
1
blockNumber block
raw: key1
u32 Past block number to look up the hash for (u32). The block must already exist on chain.

Stored Value

32-byte block hash

Default Value

0x0000000000000000000000000000000000000000000000000000000000000000 (raw SCALE bytes)

Absent keys read as this value — querying a key that has never been written returns this default, not an error or empty result.

Code Examples

import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443

const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);

// Query BlockHash storage
const key1 = 0;

const result = await api.query.System.BlockHash.getValue(key1);
console.log("BlockHash:", result);

Runtime Info

Pallet
System
Storage Kind
Map
First Version
v101
Current Version
v472