chain_getHeader
Returns the block header for a given hash on Bittensor.
Use Cases#
- Lightweight queries - Get header without full block data
- Chain synchronization - Track block production for decentralized AI inference, subnet-specific AI models, TAO staking, and cross-subnet AI collaboration
- Parent chain navigation - Follow parentHash links
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
blockHash | String | No | Block hash. If omitted, returns latest header |
Request#
{
"jsonrpc": "2.0",
"method": "chain_getHeader",
"params": ["0x2f0555cc76fc2840a25a6f3a0f0e6d0b1a6dd2e0cecc9e4c2e9e6f3a8d2e5c1b"],
"id": 1
}
Code Examples#
- cURL
- JavaScript
- Python
curl https://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "chain_getHeader",
"params": [],
"id": 1
}'
import { ApiPromise, WsProvider } from '@polkadot/api';
const provider = new WsProvider('wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });
// Get latest header
const header = await api.rpc.chain.getHeader();
console.log('Block number:', header.number.toNumber());
console.log('Parent hash:', header.parentHash.toHex());
await api.disconnect();
import requests
def get_header(block_hash=None):
url = 'https://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY'
params = [block_hash] if block_hash else []
payload = {
'jsonrpc': '2.0',
'method': 'chain_getHeader',
'params': params,
'id': 1
}
response = requests.post(url, json=payload)
return response.json()['result']
header = get_header()
print(f"Block number: {int(header['number'], 16)}")
Related Methods#
chain_getBlock- Get full block with extrinsicschain_getBlockHash- Get block hash by number