Skip to main content

chain_getBlock - JSON-RPC Method

Description#

Retrieves complete block information from the xx Network 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": [
"0x35a20ecfdb86bc6479ebe895c802ff1639ebd5821c9faa48b89fac8ddb169e87"
],
"id": 1
}

Response Example#

{
"jsonrpc": "2.0",
"result": {
"block": {
"header": {
"parentHash": "0xd0252f476d1b71dd4a724eb6d931adadb357806e80fa8dd21cb6e5ff88bf334c",
"number": "0x135d640",
"stateRoot": "0x86605e69f65e00b50f502469ddf1e0d0cf03c58718856b22899758a7211c56ab",
"extrinsicsRoot": "0xb1e40f23736f72a95e44c66df11c43f3d3d3e90e22e4f3a71dde8de0020d67c9",
"digest": {
"logs": [
"0x0642414245b501013c0000009d2ef70f00000000",
"0x054241424501019e7b3c4e1f8a2d5c6b9e4f3a7d2c5e8b1f4a6d9c3e2b5f8a7c4d"
]
}
},
"extrinsics": [
"0x280402000b50cd548d8501",
"0x450284008eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48"
]
},
"justifications": null
},
"id": 1
}

Tip: The example references finalized xx network block 0x135d640 (decimal 20305472). Substitute a fresh hash when you need recent data.

Code Examples#

# Get latest block
curl https://api-xxnetwork.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-xxnetwork.n.dwellir.com/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "chain_getBlock",
"params": ["0x35a20ecfdb86bc6479ebe895c802ff1639ebd5821c9faa48b89fac8ddb169e87"],
"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