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

chain_subscribeFinalizedHeads

Description

Creates a subscription that pushes every newly finalized block header. Useful for indexers that only act on finalized data.

Parameters

This method does not require parameters.

Notification Payload

FieldTypeDescription
numberstringBlock number in hex
hashstringBlock hash
parentHashstringParent block hash
stateRootstringState root
digestobjectConsensus digest items

JavaScript Example

import { ApiPromise, WsProvider } from '@polkadot/api';

const provider = new WsProvider('wss://api-astar.n.dwellir.com/YOUR_API_KEY');
const api = await ApiPromise.create({ provider });

api.rpc.chain.subscribeFinalizedHeads((header) => {
console.log(`Finalized block #${header.number.toString()} (${header.hash.toHex()})`);
});

WebSocket JSON-RPC Example

{
"jsonrpc": "2.0",
"id": 1,
"method": "chain_subscribeFinalizedHeads",
"params": []
}

A notification payload will arrive on the same connection with method: "chain_finalizedHead" and the header data in params.result.