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?: EventQueryOptions;
subscribe?: boolean;
},
): UseQueryResult<ContractEvent<Record<string, any>>[], unknown>;
Parameters
Parameter | Type | Description |
---|---|---|
contract | RequiredParam<ValidContractInstance> | the instance of the contract to listen to events for |
eventName | string | (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) |
Returns:
UseQueryResult<ContractEvent<Record<string, any>>[], unknown>
a response object that includes the contract events