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 sdk from "@onflow/sdk"_10_10sdk.getBlockHeader(isSealed)
Or import directly the specific function:
_10import { getBlockHeader } from "@onflow/sdk"_10_10getBlockHeader(isSealed)
Usage
_21import * as fcl from "@onflow/fcl";_21_21// Get latest sealed block header_21const sealedHeader = await fcl.send([_21 fcl.getBlockHeader(true)_21]).then(fcl.decode);_21_21console.log("Block height:", sealedHeader.height);_21console.log("Block timestamp:", sealedHeader.timestamp);_21console.log("Parent block ID:", sealedHeader.parentId);_21_21// Get header for specific block_21const blockHeader = await fcl.send([_21 fcl.getBlockHeader(),_21 fcl.atBlockHeight(12345)_21]).then(fcl.decode);_21_21// Get latest finalized block header_21const finalizedHeader = await fcl.send([_21 fcl.getBlockHeader(false)_21]).then(fcl.decode);
Parameters
isSealed
(optional)
- Type:
boolean
- Description: Block finality state, true for sealed blocks, false for finalized blocks, null for latest
Returns
InteractionBuilderFn
_10export type InteractionBuilderFn = (_10 ix: Interaction_10) => Interaction | Promise<Interaction>