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

chain_getBlock

Description

Returns complete block information, including the header and SCALE-encoded extrinsics. Supplying a block hash lets you fetch historical blocks deterministically; omitting the parameter yields the latest block known to the node.

Parameters

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

Returns

FieldTypeDescription
block.headerobjectBlock header (parent hash, number, state root, extrinsics root, digest)
block.extrinsicsarrayArray of SCALE-encoded extrinsic payloads
justificationsarray | nullFinality justifications, if present

Request Example

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

Response Example

{
"jsonrpc": "2.0",
"result": {
"block": {
"header": {
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"number": "0x0",
"stateRoot": "0x2a9c5fae68d226bfef7830398114196416ca1799ebb0099fdfa8b7b7ef19adf4",
"extrinsicsRoot": "0x03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314",
"digest": {
"logs": []
}
},
"extrinsics": []
},
"justifications": null
},
"id": 1
}

The example above shows the Bifrost genesis block (#0), which contains no extrinsics.

Code Examples

cURL

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

JavaScript

const request = async (hash) => {
const params = hash ? [hash] : [];
const response = await fetch('https://api-bifrost-polkadot.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'chain_getBlock',
params,
id: 1
})
});
return (await response.json()).result;
};

const block = await request('0xd4b3a0e3b88b7c25215926bbf7c733f5c31e69c0c8c4b4a86d6ec3f3f086e95d');
console.log('Extrinsics count:', block.block.extrinsics.length);

Rust (subxt)

use subxt::{config::substrate::SubstrateConfig, OnlineClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api = OnlineClient::<SubstrateConfig>::from_url(
"wss://api-bifrost-polkadot.n.dwellir.com/YOUR_API_KEY"
).await?;

let hash = api.rpc().block_hash(None).await?.expect("best hash");
let block = api.rpc().block(Some(hash)).await?.expect("block");
println!("Block #{} has {} extrinsics", block.block.header.number, block.block.extrinsics.len());
Ok(())
}

Usage Notes

  • For production monitoring, pair chain_getBlock with chain_getFinalizedHead to avoid processing non-finalized blocks.
  • Extrinsics are returned as SCALE-encoded bytes. Decode them with the Bifrost metadata to extract calls such as timestamp.set, parachainsystem.set_validation_data, or SALP pallet operations.