Skip to main content

atBlockId

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

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

Block ID is SHA3-256 hash of the entire block payload. This hash is stored as an ID field on any block response object (ie. response from 'GetLatestBlock').

Import

You can import the entire package and access the function:


_10
import * as fcl from '@onflow/fcl';
_10
_10
fcl.atBlockId(id);

Or import directly the specific function:


_10
import { atBlockId } from '@onflow/fcl';
_10
_10
atBlockId(id);

Usage


_26
import * as fcl from '@onflow/fcl';
_26
_26
// Get block by ID
_26
await fcl.send([fcl.getBlock(), fcl.atBlockId('23232323232')]).then(fcl.decode);
_26
_26
// Get account at specific block ID
_26
await fcl
_26
.send([
_26
fcl.getAccount('0x1d007d755706c469'),
_26
fcl.atBlockId(
_26
'9dda5f281897389b99f103a1c6b180eec9dac870de846449a302103ce38453f3',
_26
),
_26
])
_26
.then(fcl.decode);
_26
_26
// Execute script at specific block
_26
await fcl
_26
.send([
_26
fcl.script`
_26
access(all) fun main(): UFix64 {
_26
return getCurrentBlock().timestamp
_26
}
_26
`,
_26
fcl.atBlockId('a1b2c3d4e5f6'),
_26
])
_26
.then(fcl.decode);

Parameters

id

  • Type: string
  • Description: The ID 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