For the complete documentation index, see llms.txt. This page is also available as Markdown.

chain_getBlock - Kusama

Example code for the chain_getBlock JSON-RPC method. Complete guide on how to use chain_getBlock JSON-RPC in GetBlock Web3 documentation.

Returns the full block (header and extrinsics) for a given block hash, or the latest block when the hash is omitted.

Available over both the JSON-RPC (HTTP) and WebSocket interfaces.

Parameters

Parameter
Type
Required
Description

hash

string

Optional

Block hash; omit for the latest block

Request

curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "chain_getBlock",
    "params": [
    "0x8a1e6d2f0b7c4a9e3d5f1b8c2a6e4d0f9b3c7a5e1d8f2b6c4a0e9d3f7b1c5a2e6"
]
}'
example.js
const axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    id: 'getblock.io',
    method: 'chain_getBlock',
    params: [
    "0x8a1e6d2f0b7c4a9e3d5f1b8c2a6e4d0f9b3c7a5e1d8f2b6c4a0e9d3f7b1c5a2e6"
]
}, { headers: { 'Content-Type': 'application/json' } });

console.log(response.data.result);

Response

Response Fields

Field
Type
Description

block.header

object

Block header (parentHash, number, roots, digest)

block.extrinsics

array

SCALE-encoded extrinsics (hex) in the block

justifications

array

null

Use Cases

  • Block Inspection: Read a block's extrinsics and header

  • Indexing: Decode extrinsics for an indexer

  • Explorers: Render block detail pages

Error Handling

Error
Message
Description

-32603 / Internal error

Unknown block

No block matches the supplied hash

403 / RBAC: access denied

Access denied

The GetBlock access token is missing or incorrect

Last updated

Was this helpful?