Defines the window for referencing recent blocks in transactions.
Current Value
2400Relevant for: developersvalidatorsanalytics
The Big Picture
Transactions can reference recent blocks for mortality (expiry). This constant defines how far back you can reference. Also used for light clients verifying block ancestry.
Why This Matters
When signing a transaction, you specify a 'mortality' block - the transaction expires if not included by then. This constant limits how far ahead you can set that.
Example
BlockHashCount is 2400. You can set transaction mortality up to 2400 blocks from now. With ~12 second blocks, that's about 8 hours before the transaction expires.
Common Questions
- What if I need older block hashes?
- Query an archive node. They keep all history.
From Chain Metadata
Maximum number of block number to block hash mappings to keep (oldest pruned first).
Use Cases
- Block hash queries
- Transaction mortality calculation
- Light client verification
Code Examples
import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";
const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });
// Query BlockHashCount constant
const value = api.consts[stringCamelCase("System")][stringCamelCase("BlockHashCount")];
console.log("BlockHashCount:", value.toHuman());Type Information
- Type
- u32
- Byte Size
- 4 bytes
- Encoding
- fixed
- Raw Hex
- 0x60090000
Runtime Info
- Pallet
- System
- First Version
- v101
- Latest Version
- v101
- Current Runtime
- v393