Skip to main content

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:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.getLatestBlock(isSealed)

Or import directly the specific function:


_10
import { getLatestBlock } from "@onflow/sdk"
_10
_10
getLatestBlock(isSealed)

Usage


_17
import * as fcl from "@onflow/fcl";
_17
_17
// Get the latest executed block (soft finality)
_17
const latestBlock = await fcl.send([fcl.getLatestBlock()]).then(fcl.decode);
_17
console.log("Latest block height:", latestBlock.height);
_17
console.log("Block ID:", latestBlock.id);
_17
console.log("Block timestamp:", latestBlock.timestamp);
_17
_17
// Get the latest sealed block (hard finality)
_17
const sealedBlock = await fcl.send([fcl.getLatestBlock(true)]).then(fcl.decode);
_17
console.log("Latest sealed block height:", sealedBlock.height);
_17
_17
// Use in combination with other builders
_17
const 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


_10
export type InteractionBuilderFn = (
_10
ix: Interaction
_10
) => Interaction | Promise<Interaction>


Rate this page