getBlockHeader
A builder function that returns the interaction to get a block header.
A block header contains metadata about a block without the full transaction details, making it more lightweight than fetching the entire block. This is useful when you only need block metadata like timestamp, height, parent hash, etc.
Use with 'fcl.atBlockId()' and 'fcl.atBlockHeight()' when building the interaction to get headers for specific blocks.
Import
You can import the entire package and access the function:
_10import * as fcl from '@onflow/fcl';_10_10fcl.getBlockHeader(isSealed);
Or import directly the specific function:
_10import { getBlockHeader } from '@onflow/fcl';_10_10getBlockHeader(isSealed);
Usage
_20import * as fcl from '@onflow/fcl';_20_20// Get latest sealed block header_20const sealedHeader = await fcl_20 .send([fcl.getBlockHeader(true)])_20 .then(fcl.decode);_20_20console.log('Block height:', sealedHeader.height);_20console.log('Block timestamp:', sealedHeader.timestamp);_20console.log('Parent block ID:', sealedHeader.parentId);_20_20// Get header for specific block_20const blockHeader = await fcl_20 .send([fcl.getBlockHeader(), fcl.atBlockHeight(12345)])_20 .then(fcl.decode);_20_20// Get latest finalized block header_20const finalizedHeader = await fcl_20 .send([fcl.getBlockHeader(false)])_20 .then(fcl.decode);
Parameters
isSealed
(optional)
- Type:
boolean
- Description: Block finality state, true for sealed blocks, false for finalized blocks, null for latest
Returns
_10export type InteractionBuilderFn = (_10 ix: Interaction,_10) => Interaction | Promise<Interaction>;
A function that processes an interaction object