Skip to main content

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:


_10
import * as fcl from '@onflow/fcl';
_10
_10
fcl.getEvents(eventType, start, end);

Or import directly the specific function:


_10
import { getEvents } from '@onflow/fcl';
_10
_10
getEvents(eventType, start, end);

Usage


_14
import * as fcl from '@onflow/fcl';
_14
_14
// Get FlowToken transfer events from blocks 1000 to 2000
_14
const events = await fcl
_14
.send([
_14
fcl.getEvents('A.1654653399040a61.FlowToken.TokensDeposited', 1000, 2000),
_14
])
_14
.then(fcl.decode);
_14
_14
console.log('Found events:', events.length);
_14
events.forEach((event) => {
_14
console.log('Event data:', event.data);
_14
console.log('Transaction ID:', event.transactionId);
_14
});

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


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

A function that processes an interaction object


Rate this page