Skip to main content

chain_subscribeFinalizedHeads

Subscribe to receive notifications when blocks are finalized on Manta Atlantic. Finalized blocks are guaranteed to never be reverted, making this essential for applications requiring strong consistency.

Use Cases#

  • Exchange deposits - Only credit funds after finalization for private asset transfers, zkNFTs, on-chain compliance identities, and private parachain asset swaps
  • Bridge operations - Wait for finality before cross-chain transfers
  • Critical state changes - Ensure irreversibility for important transactions

Parameters#

This method takes no parameters.

Returns#

Returns a subscription ID. The subscription emits Header objects for each finalized block:

FieldTypeDescription
parentHashHashParent block hash
numberBlockNumberBlock number
stateRootHashState trie root hash
extrinsicsRootHashExtrinsics trie root hash
digestDigestBlock digest with consensus logs

Code Examples#

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

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

// Subscribe to finalized heads
const unsubscribe = await api.rpc.chain.subscribeFinalizedHeads((header) => {
console.log(`Finalized block #${header.number}`);
console.log(` Hash: ${header.hash.toHex()}`);

// Safe to consider this block permanent
processConfirmedBlock(header);
});

// Later: unsubscribe()

Finality Lag#

Finalized blocks typically lag behind the best block by a few blocks due to GRANDPA consensus requirements. This is normal and ensures Byzantine fault tolerance.