Docs
Supported ChainsAstarSubstrate APIChain Methods

chain_getBlockHash - Astar RPC Method

Get block hash by number on Astar. Essential for historical queries on Polkadot's leading dApp hub supporting EVM, WASM, and upcoming PolkaVM environments.

Returns the block hash for a given block number on Astar.

Use Cases

  • Historical queries - Convert block numbers to hashes
  • Block navigation - Navigate blockchain history for cross-chain DeFi, multi-VM smart contracts, and XCM-enabled interoperability with Ethereum and Cosmos
  • Data indexing - Build block number to hash mappings

Request Parameters

Request
blockNumberNumber

Block number. If omitted, returns latest block hash

Response Body

Response

Code Examples

Bash
curl https://api-astar.n.dwellir.com/YOUR_API_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "chain_getBlockHash",
    "params": [1000000],
    "id": 1
  }'
JavaScript
import { ApiPromise, WsProvider } from '@polkadot/api';

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

// Get hash for specific block number
const blockNumber = 1000000;
const blockHash = await api.rpc.chain.getBlockHash(blockNumber);
console.log(`Block ${blockNumber} hash:`, blockHash.toHex());

await api.disconnect();
Python
import requests

def get_block_hash(block_number=None):
    url = 'https://api-astar.n.dwellir.com/YOUR_API_KEY'
    params = [block_number] if block_number is not None else []

    payload = {
        'jsonrpc': '2.0',
        'method': 'chain_getBlockHash',
        'params': params,
        'id': 1
    }

    response = requests.post(url, json=payload)
    return response.json()['result']

block_hash = get_block_hash(1000000)
print(f'Block hash: {block_hash}')

On this page