chain_getBlock - JSON-RPC Method
Description#
Retrieves complete block data from the Acala blockchain, including both the block header and all extrinsics (transactions) contained within that block. The block header contains metadata such as parent hash, state root, extrinsics root, block number, and consensus-related information. The extrinsics array includes all state-changing operations that were executed in this block. When called without parameters, returns the latest known block. With a block hash parameter, retrieves a specific historical block.
Request Examples#
# Get latest block
curl -s https://api-acala.n.dwellir.com/YOUR_API_KEY \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"chain_getBlock","params":[]}'
# Get specific block by hash
curl -s https://api-acala.n.dwellir.com/YOUR_API_KEY \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"chain_getBlock","params":["0x1234..."]}'
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
| block_hash | string | No | 32-byte block hash in hexadecimal format. Omit for latest block |
Response Structure#
The response contains two main components:
- Header: Block metadata including parent hash, number, state root, extrinsics root, and digest logs
- Extrinsics: Array of SCALE-encoded extrinsics in hexadecimal format representing all transactions in the block
Each extrinsic includes the signed data, call information, and any events emitted during execution. The header's extrinsics root is a Merkle root committing to all extrinsics in the block.
Use Cases#
- Block Explorers: Display complete block information including all transactions and metadata
- Transaction History: Retrieve historical transactions for specific accounts or contract interactions
- Data Analysis: Analyze network activity patterns by examining block contents over time
- Verification: Verify transaction inclusion in specific blocks by examining extrinsics array
- Event Parsing: Extract and process events emitted by extrinsics in the block
- Archival: Build local archives of blockchain data for analysis or backup purposes
Best Practices#
Always use Substrate client libraries to decode the SCALE-encoded extrinsics and header data. The raw response requires runtime metadata for proper interpretation. For applications that only need block headers without extrinsic details, consider using chain_getHeader for more efficient data transfer. Cache frequently accessed blocks to reduce API load and improve application performance.
Performance Considerations#
Retrieving full blocks can return large amounts of data, especially for blocks containing many extrinsics or complex smart contract interactions. Consider implementing pagination or filtering strategies when processing multiple blocks sequentially. Recent blocks are typically served faster than historical blocks requiring archive node access.
Related Methods#
chain_getHeader- Get only the block header without extrinsicschain_getBlockHash- Get block hash by number to use with this methodchain_getFinalizedHead- Get the latest finalized block hash