chain_getHeader - JSON-RPC Method
Description#
Returns the header for a given block hash or, if no parameter is supplied, the header of the latest block on Enjin Matrix. Headers include the parent hash, state root, extrinsics root, digest logs, and block number, which are key inputs for light clients and monitoring systems.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
blockHash | string | No | Hex-encoded block hash. When omitted, returns the best header |
Returns#
| Field | Type | Description |
|---|---|---|
parentHash | string | Hash of the parent block |
number | string | Block height encoded in hexadecimal |
stateRoot | string | Merkle root of the runtime state |
extrinsicsRoot | string | Root hash of extrinsics in the block |
digest | object | Consensus digest logs emitted for the block |
Request Example#
{
"jsonrpc": "2.0",
"method": "chain_getHeader",
"params": [
"0x1873093eade39aa409f64537dd972c27156e4691fc0fda227a06d50c52ad5fef"
],
"id": 1
}
Response Example#
{
"jsonrpc": "2.0",
"result": {
"parentHash": "0xa0ac758e5eb9d474245a06c00882946b5d98c8e1cb5873c5f8234da327fe6c47",
"number": "0x677b8e",
"stateRoot": "0x55105740c8eb8345869fd67d71865eb7db7ccb6c548a172d5232809f2ae77f36",
"extrinsicsRoot": "0x20ab30742968157af9eb59115f3f4e74bb67094ab771d9bd8236a7b237738308",
"digest": {
"logs": [
"0x0661757261201c957a1100000000",
"0x0452505352903348cf386b6588edc1bda1b86f19fc667872bba3d14813dc925dbedc414464190226ed02"
]
}
},
"id": 1
}
Code Examples#
- cURL
- Python
- JavaScript
curl https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "chain_getHeader",
"params": ["0x1873093eade39aa409f64537dd972c27156e4691fc0fda227a06d50c52ad5fef"],
"id": 1
}'
import json
import requests
payload = {
"jsonrpc": "2.0",
"method": "chain_getHeader",
"params": [], # omit to fetch the latest header
"id": 1,
}
latest_header = requests.post(
"https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY",
headers={"Content-Type": "application/json"},
data=json.dumps(payload),
timeout=10,
).json()["result"]
print(int(latest_header["number"], 16))
async function getHeader(blockHash) {
const body = {
jsonrpc: '2.0',
method: 'chain_getHeader',
params: blockHash ? [blockHash] : [],
id: 1
};
const response = await fetch('https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
const { result } = await response.json();
return result;
}
Usage Tips#
- Store the header hash and number together to cross-check finality versus heads from other nodes.
- Digest logs include Aura slot and GRANDPA justification hints—parse them when debugging consensus.
- Pair with
chain_getBlockto retrieve full extrinsic payloads when deeper inspection is required.