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:
_10import * as sdk from "@onflow/sdk"_10_10sdk.atLatestBlock(isSealed)
Or import directly the specific function:
_10import { atLatestBlock } from "@onflow/sdk"_10_10atLatestBlock(isSealed)
Usage
_23import * as fcl from "@onflow/fcl";_23_23// Get latest executed block (soft finality)_23await fcl.send([fcl.getBlock(), fcl.atLatestBlock()]).then(fcl.decode);_23_23// Get latest sealed block (hard finality)_23await fcl.send([fcl.getBlock(), fcl.atLatestBlock(true)]).then(fcl.decode);_23_23// Get account from latest sealed block_23await fcl.send([_23 fcl.getAccount("0x1d007d755706c469"),_23 fcl.atLatestBlock(true)_23]).then(fcl.decode);_23_23// Execute script against latest executed block_23await 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
_10export type InteractionBuilderFn = (_10 ix: Interaction_10) => Interaction | Promise<Interaction>