Skip to main content

atBlockHeight

A builder function that returns a partial interaction to a block at a specific height.

Use with other interactions like 'fcl.getBlock()' to get a full interaction at the specified block height.

Block height expresses the height of the block on the chain. The latest block height increases by one for every valid block produced.

Import

You can import the entire package and access the function:


_10
import * as sdk from '@onflow/sdk';
_10
_10
sdk.atBlockHeight(height);

Or import directly the specific function:


_10
import { atBlockHeight } from '@onflow/sdk';
_10
_10
atBlockHeight(height);

Usage


_21
import * as fcl from '@onflow/fcl';
_21
_21
// Get block at specific height
_21
await fcl.send([fcl.getBlock(), fcl.atBlockHeight(123)]).then(fcl.decode);
_21
_21
// Get account at specific block height
_21
await fcl
_21
.send([fcl.getAccount('0x1d007d755706c469'), fcl.atBlockHeight(12345)])
_21
.then(fcl.decode);
_21
_21
// Execute script at specific block height
_21
await fcl
_21
.send([
_21
fcl.script`
_21
access(all) fun main(): UFix64 {
_21
return getCurrentBlock().height
_21
}
_21
`,
_21
fcl.atBlockHeight(100),
_21
])
_21
.then(fcl.decode);

Parameters

height

  • Type: number
  • Description: The height of the block to execute the interaction at

Returns


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

A partial interaction to be paired with another interaction such as 'fcl.getBlock()' or 'fcl.getAccount()'


Rate this page