Skip to main content

atLatestBlock

A builder function that returns a partial interaction to query the latest block with the given finality state.

Use with other interactions like 'fcl.getBlock()' to get the latest block information. Block finality determines whether you get the latest executed block or the latest sealed block.

  • Executed blocks (soft-finality): Latest block that has been executed but may not be final
  • Sealed blocks (hard-finality): Latest block that has been sealed and is considered final

Import

You can import the entire package and access the function:


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

Or import directly the specific function:


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

Usage


_23
import * as fcl from "@onflow/fcl";
_23
_23
// Get latest executed block (soft finality)
_23
await fcl.send([fcl.getBlock(), fcl.atLatestBlock()]).then(fcl.decode);
_23
_23
// Get latest sealed block (hard finality)
_23
await fcl.send([fcl.getBlock(), fcl.atLatestBlock(true)]).then(fcl.decode);
_23
_23
// Get account from latest sealed block
_23
await fcl.send([
_23
fcl.getAccount("0x1d007d755706c469"),
_23
fcl.atLatestBlock(true)
_23
]).then(fcl.decode);
_23
_23
// Execute script against latest executed block
_23
await fcl.send([
_23
fcl.script`
_23
access(all) fun main(): UFix64 {
_23
return getCurrentBlock().height
_23
}
_23
`,
_23
fcl.atLatestBlock()
_23
]).then(fcl.decode);

Parameters

isSealed (optional)

  • Type: boolean
  • Description: Block finality state, defaults to latest executed block ("soft-finality"), set to true for sealed blocks ("hard-finality")

Returns

InteractionBuilderFn


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


Rate this page