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

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

ParameterTypeRequiredDescription
blockNumberstring or numberNoBlock number in hex (0x1e240) or unsigned integer (123456). When omitted, the latest block hash is returned.

Returns

FieldTypeDescription
resultstringHex-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

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
}'

TypeScript (@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 hash = await api.rpc.chain.getBlockHash(123456);
console.log('Block hash:', hash.toHex());

Usage Notes

  • Combine this method with chain_getBlock to 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).