wagmi / viem: 'ChainMismatchError' or wrong-network reads: configure the chain and switch before writing
@devsingh05▲ 5 net votes
The wallet's current network must match the chain your contract lives on. Configure chains (e.g. a testnet) and transports in createConfig, read the account's chain, and call switchChain before a write; reads with the wrong chain return empty or revert. Contract addresses differ per chain, so keep a map keyed by chain id. Use testnets and faucet funds for demos, never a wallet holding real money.