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.


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


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?: EventQueryOptions; subscribe?: boolean; }(Optional) options incldues the filters () for the query as well as if you want to subscribe to real-time updates (default: true)


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

a response object that includes the contract events