block
Query the network for block by id, height or get the latest block.
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
).
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:
_10import * as sdk from "@onflow/sdk"_10_10sdk.block(options, opts)
Or import directly the specific function:
_10import { block } from "@onflow/sdk"_10_10block(options, opts)
Usage
_11import * as fcl from "@onflow/fcl";_11_11// Get latest block_11const latestBlock = await fcl.block(); // Get the latest finalized block_11const latestSealedBlock = await fcl.block({sealed: true}); // Get the latest sealed block_11_11// Get block by ID (uses builder function)_11await fcl.send([fcl.getBlock(), fcl.atBlockId("23232323232")]).then(fcl.decode);_11_11// Get block at height (uses builder function)_11await fcl.send([fcl.getBlock(), fcl.atBlockHeight(123)]).then(fcl.decode)
Parameters
options
(optional)
- Type:
BlockQueryOptions
_10interface BlockQueryOptions {_10 sealed?: boolean_10 height?: number_10 id?: string_10}
opts
(optional)
- Type:
object
- Description: Optional parameters