useContractEvents
Hook for reading events emitted by a smart contract, including new events as they are emitted (optional).
import { useContractEvents } from "@thirdweb-dev/react";
const { data, isLoading, error } = useContractEvents(contract);
Usage
Provide your smart contract instance from useContract
hook as the argument.
By default, reads all events emitted by the smart contract.
import { useContractEvents, useContract } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useContractEvents(contract);
}