DEV Community

Cover image for I Built My First dApp with React and Ethers.js — Here’s What I Learned
Increase Akinwole
Increase Akinwole

Posted on

I Built My First dApp with React and Ethers.js — Here’s What I Learned

When I decided to build my first decentralized application (dApp), I honestly didn’t know what I was walking into.

I had worked with React for a while, but integrating blockchain functionality? That was completely new territory. My goal was simple, connect a wallet, read data from a smart contract, and display it on the frontend.

Simple on paper… not so simple in reality.

Step 1: Connecting MetaMask

The first challenge was wallet connection — without it, a dApp is just another web app.

Using Ethers.js, I connected MetaMask and requested access to the user’s account. Here’s the basic structure I used:

import { ethers } from "ethers";

async function connectWallet() {
  if (window.ethereum) {
    try {
      const provider = new ethers.BrowserProvider(window.ethereum);
      const accounts = await provider.send("eth_requestAccounts", []);
      console.log("Connected:", accounts[0]);
    } catch (error) {
      console.error("User rejected connection:", error);
    }
  } else {
    alert("Please install MetaMask!");
  }
}

Enter fullscreen mode Exit fullscreen mode

Seeing that first wallet connection happen in the browser felt magical.

But of course, I quickly learned the next rule of Web3 development — always handle errors.
Users might reject the request, switch networks, or close the modal. Your UI should always respond gracefully.

Lesson learned: Web3 apps need to expect the unexpected.

Step 2: Reading Data from a Smart Contract

Next, I wanted to display some on-chain data, like a token name, symbol or balance.

I used an existing smart contract’s ABI and **address **to fetch data directly from the blockchain:

const contractAddress = "0xYourContractAddress";
const abi = [ "function name() view returns (string)", "function symbol() view returns (string)" ];

async function getTokenData() {
  const provider = new ethers.BrowserProvider(window.ethereum);
  const contract = new ethers.Contract(contractAddress, abi, provider);

  const name = await contract.name();
  const symbol = await contract.symbol();

  console.log(`Token: ${name} (${symbol})`);
}
Enter fullscreen mode Exit fullscreen mode

That first moment when I saw real on-chain data load on my screen, I won’t lie, it felt like magic.

But it also taught me something deeper:

Blockchain development isn’t about new syntax, it’s about a new mindset.
You’re not calling a centralized API anymore, you’re talking directly to the blockchain.

Step 3: UX in the Web3 World

Building the logic was one thing; designing the user experience was another.

In Web2 apps, actions happen instantly. In Web3, every interaction can take time, transactions need to confirm, networks can lag and users might get confused.

So I added loaders, transaction statuses and simple toast messages like:

“Transaction sent! Waiting for confirmation…”

These small touches completely changed the feel of the app.
It made it more human, and that’s when I realized:

Good UX is just as important as good code in Web3.

Step 4: My Biggest Lessons

Here’s what I learned from building my first dApp:

  • You don’t need to be a blockchain expert to start.
  • Even connecting a wallet is a dApp — start small.
  • Handle every possible user scenario.
  • Always test on testnets before mainnet.
  • A clean, responsive UI makes everything better.

And most importantly, experiment fearlessly.

Conclusion

Building my first dApp was more than a coding challenge, it was an eye-opener.

I finally understood how Web3 apps communicate directly with the blockchain. No backend, no database, just smart contracts, wallets and user ownership.

If you’re a frontend developer wondering where to start with Web3, this is it.
Start small. Connect a wallet. Read some data. Then build from there.

Because the best way to learn Web3 development is by building something real, no matter how small.

Top comments (0)