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

chain_getBlockHash - JSON-RPC Method

Description​

Returns the block hash for a given block number on Enjin Matrix. When called without parameters it returns the hash of the latest block. Hashes are required for deterministic storage reads and verifying block inclusion proofs.

Parameters​

ParameterTypeRequiredDescription
blockNumbernumberNoBlock height as a decimal integer. If omitted, returns the best block hash

Returns​

FieldTypeDescription
resultstringHex-encoded block hash

Request Examples​

{
"jsonrpc": "2.0",
"method": "chain_getBlockHash",
"params": [],
"id": 1
}
{
"jsonrpc": "2.0",
"method": "chain_getBlockHash",
"params": [6781838],
"id": 42
}

Response Example​

{
"jsonrpc": "2.0",
"result": "0x1873093eade39aa409f64537dd972c27156e4691fc0fda227a06d50c52ad5fef",
"id": 42
}

Code Examples​

cURL​

# Latest block hash
curl https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "chain_getBlockHash",
"params": [],
"id": 1
}'

# Hash for block 6,781,838
curl https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "chain_getBlockHash",
"params": [6781838],
"id": 42
}'

JavaScript​

async function getBlockHash(height) {
const response = await fetch('https://api-enjin-matrixchain.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'chain_getBlockHash',
params: typeof height === 'number' ? [height] : [],
id: 1
})
});

return (await response.json()).result;
}

Python​

import json
import requests

def block_hash(height=None):
payload = {
"jsonrpc": "2.0",
"method": "chain_getBlockHash",
"params": [] if height is None else [height],
"id": 1,
}
return 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(block_hash(6781838))

Notes​

  • Provide the returned hash to chain_getBlock or state_getStorage for deterministic reads.
  • Supply decimal heights when querying by number; JSON-RPC clients perform conversion to hex automatically.
  • For archival queries across Matrix and the Enjin Relaychain, track hashes per networkβ€”they are distinct consensus layers.