Skip to content
RED SAGSkills
mediumBlockchain Developer interview question

How do you build a reliable dApp frontend that reads and writes contracts with viem and wagmi?

What the interviewer wants to hear

  • Wallet connection and handling chain and account changes
  • Reads via public client or multicall, cached with React Query
  • Simulate before writing, then wait for the receipt
  • Show clear pending, success and error states, decode revert reasons
  • Type-safe ABIs and correct decimal handling

Model answer

I use wagmi for wallet connection and React hooks, with viem underneath. Connectors cover browser wallets, WalletConnect and smart wallets, and I handle account and chain changes, prompting the user to switch if they are on the wrong network. For reads I use useReadContract or batched multicall reads, cached through TanStack Query, and I refetch after relevant transactions or events. For writes I first simulate the call, which catches reverts and gives a decoded error before the user signs. Then I send it, show a pending state with the hash, and wait for the receipt before showing success. I import ABIs as const so viem gives full type safety, and I always format amounts with each token's decimals using formatUnits and parseUnits. I also use my own RPC provider with fallbacks instead of relying only on the wallet's.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Blockchain Developer questions