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
_24import * as fcl from '@onflow/fcl';_24_24// Get latest executed block (soft finality)_24await fcl.send([fcl.getBlock(), fcl.atLatestBlock()]).then(fcl.decode);_24_24// Get latest sealed block (hard finality)_24await fcl.send([fcl.getBlock(), fcl.atLatestBlock(true)]).then(fcl.decode);_24_24// Get account from latest sealed block_24await fcl_24 .send([fcl.getAccount('0x1d007d755706c469'), fcl.atLatestBlock(true)])_24 .then(fcl.decode);_24_24// Execute script against latest executed block_24await fcl_24 .send([_24 fcl.script`_24 access(all) fun main(): UFix64 {_24 return getCurrentBlock().height_24 }_24 `,_24 fcl.atLatestBlock(),_24 ])_24 .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
_10export type InteractionBuilderFn = (_10 ix: Interaction,_10) => Interaction | Promise<Interaction>;
A function that processes a partial interaction object