Skip to main content

๐Ÿ›  Interacting with Your Smart Contracts

Scaffold-ETH 2 provides a collection of custom React hooks designed to simplify interactions with your deployed smart contracts. These hooks are wrappers around Wagmi, an easy-to-use interface with typescript autocompletions for reading from, writing to, and monitoring events emitted by your smart contracts.

To ensure autocompletions function correctly, always update the targetNetworks in scaffold.config.ts to include the relevant network/chain whenever you deploy your contract using yarn deploy --network.

info

The custom hooks rely on three main files for their functionality and TypeScript autocompletion:

The deployedContracts.ts file is auto-generated/updated whenever you run yarn deploy --network. It organizes contract addresses and abi's based on chainId.

note

When having multiple chains configured in targetNetworks, make sure to have same contractName's on other chains as targetNetworks[0].id.This ensures proper functionality and autocompletion of custom hooks, as the current setup and types assumes that same contract's are present on other chains as targetNetworks[0].