Frontend Integration
Now connect the React app to the deployed contracts using wagmi hooks.1. Contract addresses & ABIs
Keep addresses and minimal ABIs in one place:src/lib/contracts.ts
2. Read balances
useReadContract reads on-chain view functions. Enable each only when a wallet
is connected:
3. Write transactions
useWriteContract sends a transaction; useWaitForTransactionReceipt watches it.
After success, refetch the reads so balances update:
writeContract:
wei is the amount parsed to 18 decimals with parseUnits(amount, 18).
4. Friendly numbers
Balances and the input are easier to read with thousand separators:src/lib/helpers.ts
5. Loading & transaction status
While a tx is in flight, show the clicked button asLoading…, and after it
settles show a link to Etherscan:
6. Guard deposit on allowance
deposit reverts if you haven’t approved enough — and a failed gas estimate
surfaces as a confusing “gas limit too high”. Catch it before sending: if the
allowance is too low, show a hint instead of a doomed transaction.
allowance refetches → needApprove becomes false →
Deposit works.
The full flow
1
Connect
Connect MetaMask on Sepolia.
2
Mint
Click Mint to get IDRT (open faucet).
3
Approve
Enter an amount, click Approve.
4
Deposit
Click Deposit — tokens move into the Vault.
5
Withdraw
Click Withdraw to pull them back out.
That’s the full loop: a neo-brutalism dApp reading and writing real contracts on
Sepolia. 🎉
Full Source
Copy every file in full from one page.
