chain_getHeader - JSON-RPC Method
Description
Retrieves the header of a specific block without the body (extrinsics). More efficient than chain_getBlock
when you only need header information.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
blockHash | string | No | Hex-encoded block hash. If omitted, returns the latest block header |
Request Example
{ "jsonrpc": "2.0", "method": "chain_getHeader", "params": [], "id": 1 }
Code Examples
- Python
- JavaScript
import requests, json
url = "https://api-acala.n.dwellir.com/YOUR_API_KEY"
payload = {"jsonrpc":"2.0","method":"chain_getHeader","params":[],"id":1}
print(requests.post(url, headers={"Content-Type":"application/json"}, data=json.dumps(payload)).json()["result"])
const res = await fetch('https://api-acala.n.dwellir.com/YOUR_API_KEY', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', method: 'chain_getHeader', params: [], id: 1 }) });
const header = (await res.json()).result;
console.log('Latest block:', parseInt(header.number, 16));