Skip to main content

chain_getBlock - JSON-RPC Method

Description#

Retrieves complete block information from the Neuroweb blockchain, including the block header, extrinsics, and justifications. When called without parameters, returns the latest block.

Parameters#

ParameterTypeRequiredDescription
blockHashstringNoHex-encoded block hash. If omitted, returns the latest block

Returns#

FieldTypeDescription
blockobjectComplete block data
block.headerobjectBlock header information
block.header.parentHashstringHash of the parent block
block.header.numberstringBlock number (hex-encoded)
block.header.stateRootstringRoot of the state trie
block.header.extrinsicsRootstringRoot of the extrinsics trie
block.header.digestobjectBlock digest items
block.extrinsicsarrayArray of extrinsics in the block
justificationsarrayBlock justifications (if available)

Request Example#

{
"jsonrpc": "2.0",
"method": "chain_getBlock",
"params": [
"0xdb5ba07c79dcbe0cdce65a3f5f01e353222547194baf172b0ff1a491b99f42da"
],
"id": 1
}

Response Example#

{
"jsonrpc": "2.0",
"result": {
"block": {
"header": {
"parentHash": "0x57551b5f44bae4f9966255c9f28b956a83846825e16c6998bf58825a00848922",
"number": "0xac066a",
"stateRoot": "0xb4b19f1b9aff7ab52ed1fca0e85dbb1f9a0887c0eef639b6c5c2245e4f5b48e3",
"extrinsicsRoot": "0xe34eb749b6201e53256777c308201f70108d69d05bfc7e889918bd5af9b3b99f",
"digest": {
"logs": [
"0x0642414245b501013c0000009d2ef70f00000000",
"0x054241424501019e7b3c4e1f8a2d5c6b9e4f3a7d2c5e8b1f4a6d9c3e2b5f8a7c4d"
]
}
},
"extrinsics": [
"0x280402000b50cd548d8501",
"0x450284008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48"
]
},
"justifications": null
},
"id": 1
}

Tip: The example references finalized NeuroWeb block 0xac066a (decimal 11273834). Replace the hash with a newer finalized head when needed.

Code Examples#

# Get latest block
curl https://api-neuroweb.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "chain_getBlock",
"params": [],
"id": 1
}'

# Get specific block
curl https://api-neuroweb.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "chain_getBlock",
"params": ["0xdb5ba07c79dcbe0cdce65a3f5f01e353222547194baf172b0ff1a491b99f42da"],
"id": 1
}'

Use Cases#

  1. Block Explorers: Display block details and transaction history
  2. Chain Analysis: Analyze block production patterns and extrinsic distribution
  3. Transaction Verification: Confirm transaction inclusion in specific blocks
  4. Network Monitoring: Track block production and finalization
  5. Data Indexing: Build databases of historical blockchain data

Block Structure Details#

Header Fields#

  • parentHash: Links blocks in the chain
  • number: Sequential block identifier
  • stateRoot: Merkle root of all account states
  • extrinsicsRoot: Merkle root of all extrinsics
  • digest: Contains consensus-related data (BABE, GRANDPA)

Extrinsics#

Each extrinsic in the array is hex-encoded and contains:

  • Signature (for signed extrinsics)
  • Method call data
  • Additional parameters (nonce, tip, mortality)

Notes#

  • Block numbers are hex-encoded in responses
  • Extrinsics are returned as hex-encoded SCALE data
  • Justifications are only present for finalized blocks with GRANDPA proofs
  • Latest block may not be finalized - use chain_getFinalizedHead for finalized blocks
  • Block data can be large - consider using chain_getHeader if only header is needed