JavaScript theorytheory 0/50 · 0%
Projects · hard

48. Building a small dApp

Connect, read, write, react.

A minimal dApp is four states: disconnected, wrong network, ready, and pending. Each needs a clear UI. Reads populate the view; writes go through connect, chain check, simulate, send, wait, refresh.

if (!account) return <Connect />;
if (chainId !== 84532) return <SwitchNetwork />;

Show the transaction hash immediately, link to the explorer, and refresh state only after the receipt.

Check your understanding

  1. 1. How many core states does the UI need?

  2. 2. When should displayed balances refresh?

  3. 3. What helps users trust a pending write?