Skip to main content

useContractEvents() function

This feature is currently in beta and may change based on feedback that we receive.

Use this to query (and subscribe) to events or a specific event on a contract.

Signature:

export declare function useContractEvents(
contract: RequiredParam<ValidContractInstance>,
eventName?: string,
options?: {
queryFilter?: EventQueryFilter;
subscribe?: boolean;
},
): UseQueryResult<ContractEvent<Record<string, any>>[], unknown>;

Parameters

ParameterTypeDescription
contractRequiredParam<ValidContractInstance>the instance of the contract to listen to events for
eventNamestring(Optional) the name of the event to query for (omit this or pass undefined to query for all events)
options{ queryFilter?: EventQueryFilter; subscribe?: boolean; }(Optional) options incldues the filters () for the query as well as if you want to subscribe to real-time updates (default: true)

Returns:

UseQueryResult<ContractEvent<Record<string, any>>[], unknown>

a response object that includes the contract events