useContractEvent
Hook for subscribing to Contract events.
import { useContractEvent } from 'wagmi'
Usage
The following examples use the ENS Registry Contract.
import { useContractEvent } from 'wagmi'
const App = () => { useContractEvent( { addressOrName: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', contractInterface: ensRegistryABI, }, 'NewOwner', (event) => console.log(event), )
return ...}
Configuration
contractConfig
See useContract
for more info.
eventName
Name of event to listen to.
import { useContractEvent } from 'wagmi'
const App = () => { useContractEvent( { addressOrName: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', contractInterface: ensRegistryABI, }, 'NewResolver', (event) => console.log(event), )
return ...}
listener
Callback that receives event.
import { useContractEvent } from 'wagmi'
const App = () => { useContractEvent( { addressOrName: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', contractInterface: ensRegistryABI, }, 'NewOwner', (event) => console.log(event), )
return ...}
config (optional)
Configuration object. Defaults to { watch: true }
.
import { useContractEvent } from 'wagmi'
const App = () => { useContractEvent( { addressOrName: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', contractInterface: ensRegistryABI, }, 'NewOwner', (event) => console.log(event), { watch: true }, )
return ...}