Skip to main content


Use this hook to subscribe to events emitted by your smart contract, and receive real-time updates when these events are emitted.

contractName: "YourContract",
eventName: "GreetingChange",
// The onLogs function is called whenever a GreetingChange event is emitted by the contract.
// Parameters emitted by the event can be destructed using the below example
// for this example: event GreetingChange(address greetingSetter, string newGreeting, bool premium, uint256 value);
onLogs: logs => { => {
const { greetingSetter, value, premium, newGreeting } = log.args;
console.log("๐Ÿ“ก GreetingChange event", greetingSetter, value, premium, newGreeting);

This example subscribes to the GreetingChange event emitted by the YourContract smart contract and logs the parameters from the event to the console when it's emitted.

This hook is a wrapper around wagmi's useWatchContractEvent.


contractNamestringName of the contract to read from.
eventNamestringName of the event to read.
onLogsfunctionCallback function to execute when the event is emitted. Accepts an array of logs that occurred during the pollingInterval set at scaffold.config.ts. Each array item contains an args property, which can be destructured to get the parameters emitted by the event. This function can customized according to your needs.

It is recommended to setState using updater function in the onLogs function to avoid problems due to caching.