1. How a Wallet Dapp Works
5 min
Core idea
A dapp does not hold the user’s wallet. It asks the wallet for permission, then asks it to sign or send specific requests.
Your React app is the screen. The wallet is the signer. The blockchain is the source of truth.
The three parts
A wallet dapp has three moving parts. Your React UI shows buttons, data, loading states, and errors. Wagmi gives React hooks for Ethereum work. Viem handles Ethereum requests and data under the hood.
TanStack Query manages async state and caching. Since current Wagmi setup uses it directly, you should think in states: idle, loading, success, error, pending transaction, confirmed.
User flow
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 6 done
Mental model
This is not full code for the repo yet. Use it as a map for what each screen state must show later.
User opens dapp
-> sees Connect Wallet
User connects wallet
-> dapp shows address and chain
Dapp reads contract
-> UI shows current value
User clicks write action
-> wallet opens with signing or transaction details
User confirms
-> dapp gets transaction hash
-> dapp shows Pending
-> dapp waits for receipt
-> dapp shows Confirmed or Failed
User rejects
-> dapp shows Request rejected
User already has wallet popup open
-> dapp shows Check your wallet, request already pending