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

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​

ParameterTypeRequiredDescription
blockHashstringNoHex-encoded block hash. When omitted, returns the best header

Returns​

FieldTypeDescription
parentHashstringHash of the parent block
numberstringBlock height encoded in hexadecimal
stateRootstringMerkle root of the runtime state
extrinsicsRootstringRoot hash of extrinsics in the block
digestobjectConsensus 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​

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

JavaScript​

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

Python​

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))

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_getBlock to retrieve full extrinsic payloads when deeper inspection is required.