chain_getBlockHash
Returns the canonical hash for a given block number. When called without parameters, the node responds with the best (latest) block hash seen by the RPC service.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
blockNumber | string or number | No | Block number in hex (0x1e240) or unsigned integer (123456). When omitted, the latest block hash is returned. |
Returns#
| Field | Type | Description |
|---|---|---|
result | string | Hex-encoded hash of the requested block. |
Request Example#
{
"jsonrpc": "2.0",
"method": "chain_getBlockHash",
"params": [123456],
"id": 1
}
Response Example#
{
"jsonrpc": "2.0",
"result": "0x4643a67ecc587f4ba00aa6fa2b77deab6c4ab46dde1bd8b7701acce2048f8615",
"id": 1
}
Code Examples#
- cURL
- TypeScript (@polkadot/api)
curl https://api-manta-atlantic-mainnet.n.dwellir.com/YOUR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "chain_getBlockHash",
"params": [123456],
"id": 1
}'
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 hash = await api.rpc.chain.getBlockHash(123456);
console.log('Block hash:', hash.toHex());
Usage Notes#
- Combine this method with
chain_getBlockto fetch the full block body for analytics or zkSBT indexing. - Requesting historical hashes is lightweight; archival storage is required only when you subsequently fetch the block contents.
- Use finalized block numbers when you need deterministic state (e.g., for compliance snapshots).