Labs ICT
⭐ Pro Login

DApp Development

Building decentralized applications with Web3 stack

DApp Development

A Decentralized Application (DApp) combines a smart contract backend with a traditional frontend. The frontend talks to the blockchain through a provider (like MetaMask), sending transactions and reading state from smart contracts.

DApp Architecture


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚               DAPP ARCHITECTURE               β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚                                              β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
  β”‚  β”‚   Frontend   β”‚     β”‚   Smart Contract  β”‚   β”‚
  β”‚  β”‚  React/Vue/  │────►│   (Solidity on    β”‚   β”‚
  β”‚  β”‚  vanilla JS  │◄────│    Blockchain)    β”‚   β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
  β”‚         β”‚                                     β”‚
  β”‚         β–Ό                                     β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                              β”‚
  β”‚  β”‚  Web3 Libraryβ”‚  (ethers.js / web3.js)      β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                              β”‚
  β”‚         β”‚                                     β”‚
  β”‚         β–Ό                                     β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                              β”‚
  β”‚  β”‚  Provider    β”‚  (MetaMask, WalletConnect)  β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                              β”‚
  β”‚         β”‚                                     β”‚
  β”‚         β–Ό                                     β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                              β”‚
  β”‚  β”‚  Blockchain  β”‚  (Ethereum / Polygon / ...) β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                              β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Frontend with ethers.js


  import { ethers } from "ethers";
  import contractABI from "./abi.json";

  const CONTRACT_ADDRESS = "0x1234...abcd";

  async function connectWallet() {
    if (!window.ethereum) {
      alert("Install MetaMask!");
      return;
    }

    const provider = new ethers.BrowserProvider(window.ethereum);
    await provider.send("eth_requestAccounts", []);
    const signer = await provider.getSigner();

    const contract = new ethers.Contract(
      CONTRACT_ADDRESS,
      contractABI,
      signer
    );

    return { provider, signer, contract };
  }

  async function getCount() {
    const { contract } = await connectWallet();
    const count = await contract.getCount();
    console.log("Count:", count.toString());
  }

  async function increment() {
    const { contract } = await connectWallet();
    const tx = await contract.increment();
    await tx.wait();  // Wait for confirmation
    console.log("Incremented!");
  }

Project Structure


  my-dapp/
  β”œβ”€β”€ contracts/
  β”‚   └── MyContract.sol
  β”œβ”€β”€ src/
  β”‚   β”œβ”€β”€ App.jsx
  β”‚   β”œβ”€β”€ components/
  β”‚   β”œβ”€β”€ hooks/
  β”‚   └── abi.json
  β”œβ”€β”€ test/
  β”‚   └── MyContract.test.js
  β”œβ”€β”€ hardhat.config.js
  β”œβ”€β”€ package.json
  └── .env

Development Tools

Hardhat: Development environment for compiling, testing, and deploying contracts.

Foundry: Fast, Rust-based toolkit for smart contract development.

Remix: Browser-based IDE for writing and deploying Solidity.

MetaMask: Browser wallet that provides the provider interface for DApps.

IPFS: Decentralized storage for frontend assets and NFT metadata.

πŸ§ͺ Quick Quiz

What is a DApp (Decentralized Application)?