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 a specific event on a contract.

Signature:

export declare function useContractEvents(
contract: RequiredParam<ReturnType<typeof useContract>["contract"]>,
eventName: string,
options?: {
queryFilter?: EventQueryFilter;
subscribe?: boolean;
},
): import("@tanstack/react-query").UseQueryResult<ContractEvent[], unknown>;

Parameters

ParameterTypeDescription
contractRequiredParam<ReturnType<typeof useContract>["contract"]>the contract instance of the contract to call a function on
eventNamestring
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:

import("@tanstack/react-query").UseQueryResult<ContractEvent[], unknown>

a response object that includes the contract events