⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

chain_getHeader

Retrieves the header for the best block or for a specific block hash. The header exposes parent linkage, state and extrinsic roots, and consensus digest logs needed for block verification.

Parameters

ParameterTypeRequiredDescription
hashstringNoHex-encoded block hash. When omitted, the header of the best block is returned.

Returns

FieldTypeDescription
resultobjectHeader object containing parentHash, number, stateRoot, extrinsicsRoot, and digest.logs.

Request Example (Latest Header)

{
"jsonrpc": "2.0",
"method": "chain_getHeader",
"params": [],
"id": 1
}

Response Snapshot

{
"jsonrpc": "2.0",
"result": {
"parentHash": "0xbec4859ed2032e0e046e7a78a3882c5ae8b7d51d16a083635d5b5ad309b30d12",
"number": "0x62726a",
"stateRoot": "0x84351d19940a55e597b6d8b95176bf0c900935fb7e268bad21c0ba1e91ea9eca",
"extrinsicsRoot": "0x6db96b60e428cd53e0453209ca50b5de7d592a18adfd4819c7ccb9afee0ab300",
"digest": {
"logs": [
"0x066e6d62738018fedf34063e6bf1cce87512dfbffdd560f2f45a0910b9e77f157b6b16ee1f4c",
"0x045250535290c08152936b6cc68ce4b7b680a3a5b5f45027688a33011b41c015b20b4b08999aaa49ae06"
]
}
},
"id": 1
}

Code Example (@polkadot/api)

import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });

const header = await api.rpc.chain.getHeader();
console.log('Best block number', header.number.toNumber());
console.log('Parent hash', header.parentHash.toHex());

Usage Notes

  • Digest entries include consensus messages such as Nimbus authoring slots and GRANDPA justifications.
  • Supply a finalized hash from chain_getFinalizedHead to ensure the header cannot be re-orged away.
  • For full block contents, follow up with chain_getBlock.