getEvents
A builder function that returns the interaction to get events.
Events are emitted by Cadence code during transaction execution and provide insights into what happened during execution. This function queries for events of a specific type within a range of block heights.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.getEvents(eventType, start, end)
Or import directly the specific function:
_10import { getEvents } from "@onflow/sdk"_10_10getEvents(eventType, start, end)
Usage
_12import * as fcl from "@onflow/fcl";_12_12// Get FlowToken transfer events from blocks 1000 to 2000_12const events = await fcl.send([_12 fcl.getEvents("A.1654653399040a61.FlowToken.TokensDeposited", 1000, 2000)_12]).then(fcl.decode);_12_12console.log("Found events:", events.length);_12events.forEach(event => {_12 console.log("Event data:", event.data);_12 console.log("Transaction ID:", event.transactionId);_12});
Parameters
eventType
- Type:
string
- Description: The type of event to get (e.g., "A.1654653399040a61.FlowToken.TokensWithdrawn")
start
- Type:
number
- Description: The start block height to query from
end
- Type:
number
- Description: The end block height to query to
Returns
InteractionBuilderFn
_10export type InteractionBuilderFn = (_10 ix: Interaction_10) => Interaction | Promise<Interaction>