getLatestBlock
A builder function that returns the interaction to get the latest block This...
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.getLatestBlock(isSealed)
Or import directly the specific function:
_10import { getLatestBlock } from "@onflow/sdk"_10_10getLatestBlock(isSealed)
Usage
_17import * as fcl from "@onflow/fcl";_17_17// Get the latest executed block (soft finality)_17const latestBlock = await fcl.send([fcl.getLatestBlock()]).then(fcl.decode);_17console.log("Latest block height:", latestBlock.height);_17console.log("Block ID:", latestBlock.id);_17console.log("Block timestamp:", latestBlock.timestamp);_17_17// Get the latest sealed block (hard finality)_17const sealedBlock = await fcl.send([fcl.getLatestBlock(true)]).then(fcl.decode);_17console.log("Latest sealed block height:", sealedBlock.height);_17_17// Use in combination with other builders_17const blockInfo = await fcl.send([_17 fcl.getLatestBlock(),_17 // Additional builders can be added here_17]).then(fcl.decode);
Parameters
isSealed
(optional)
- Type:
boolean
- Description: Whether or not the block should be sealed (defaults to false for executed blocks)
Returns
InteractionBuilderFn
_10export type InteractionBuilderFn = (_10 ix: Interaction_10) => Interaction | Promise<Interaction>