Skip to content

AbishekRaj2007/CertiChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ DApp Frontend - Decentralized Application Interface

A modern, user-friendly frontend interface for interacting with blockchain smart contracts. This decentralized application (DApp) enables users to seamlessly connect their MetaMask wallet and interact with smart contracts deployed on Ethereum testnets.


๐Ÿ“– Project Description

This is a frontend-only repository for a blockchain-based decentralized application. The DApp provides an intuitive web interface that allows users to:

  • Connect their crypto wallet (MetaMask)
  • Interact with deployed smart contracts
  • View real-time blockchain data
  • Execute transactions on Ethereum testnets

Note: This project is built for educational purposes and operates exclusively on testnets (no real money involved).


๐Ÿ› ๏ธ Tech Stack

Core Technologies

  • React.js - UI component library
  • Vite - Fast build tool and dev server
  • Tailwind CSS - Utility-first CSS framework

Blockchain Integration

  • ethers.js - Ethereum wallet implementation and contract interaction
  • MetaMask - Browser wallet for authentication and transaction signing

Additional Tools

  • React Hooks - State management
  • React Router - Client-side routing
  • Axios - HTTP requests (if applicable)

โœจ Features

  • โœ… MetaMask Wallet Integration - Seamless wallet connection and disconnection
  • โœ… Network Detection - Automatic testnet detection and switching
  • โœ… Smart Contract Interaction - Read and write operations to deployed contracts
  • โœ… Real-time Updates - Live blockchain data synchronization
  • โœ… Transaction History - View past transactions
  • โœ… Responsive Design - Mobile-friendly interface
  • โœ… Error Handling - User-friendly error messages and notifications
  • โœ… Loading States - Transaction pending indicators

๐Ÿ—๏ธ Application Architecture

Frontend Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          React Application              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚      UI Components (React)        โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                  โ†•                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚    Blockchain Service Layer       โ”‚  โ”‚
โ”‚  โ”‚         (ethers.js)               โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                  โ†•                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚      MetaMask Provider            โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ†•
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚       Ethereum Testnet Network          โ”‚
โ”‚         (Smart Contracts)               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Components:

  • UI Layer: React components for user interaction
  • Service Layer: Blockchain interaction logic using ethers.js
  • Wallet Layer: MetaMask integration for transaction signing
  • Smart Contract Layer: ABI-based contract communication

๐Ÿ“‹ Prerequisites

Before running this application, ensure you have the following installed:

Required Software

  • Node.js (v16.x or higher) - Download here
  • npm or yarn - Package manager (comes with Node.js)
  • MetaMask - Browser extension Install here

Blockchain Requirements

Knowledge Prerequisites

  • Basic understanding of blockchain and wallets
  • Familiarity with React.js (helpful but not required)

๐Ÿ” Environment Variables

Create a .env file in the root directory of the project:

# Contract Configuration
VITE_CONTRACT_ADDRESS=0xYourContractAddressHere

# Network Configuration
VITE_NETWORK_NAME=sepolia
VITE_CHAIN_ID=11155111

# RPC URL (optional - MetaMask provides this)
VITE_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY

# Application Settings
VITE_APP_NAME=My DApp
VITE_APP_ENV=development

Important Notes:

  • Replace placeholder values with your actual contract address
  • Never commit .env files to version control
  • Use .env.example for documentation purposes

๐Ÿ“ฆ Installation & Setup

Follow these steps to set up the project locally:

Step 1: Clone the Repository

git clone https://github.com/yourusername/dapp-frontend.git
cd dapp-frontend

Step 2: Install Dependencies

npm install
# or
yarn install

Step 3: Configure Environment Variables

# Copy the example environment file
cp .env.example .env

# Edit .env file with your contract details
nano .env  # or use your preferred editor

Step 4: Verify Installation

npm run dev
# or
yarn dev

If successful, you should see a message indicating the dev server is running (typically at http://localhost:5173).


๐Ÿš€ Running the Application Locally

Development Mode

npm run dev
# or
yarn dev
  • Opens at: http://localhost:5173
  • Hot reload enabled
  • Development tools accessible

Production Build

npm run build
# or
yarn build

Preview Production Build

npm run preview
# or
yarn preview

๐ŸฆŠ Connecting Wallet & Using Testnet

Step 1: Install MetaMask

  1. Install the MetaMask browser extension
  2. Create a new wallet or import an existing one
  3. Save your seed phrase securely (never share it!)

Step 2: Switch to Testnet

  1. Open MetaMask
  2. Click the network dropdown (top center)
  3. Enable "Show test networks" in Settings โ†’ Advanced
  4. Select Sepolia Test Network (or your preferred testnet)

Step 3: Get Testnet ETH

  1. Copy your wallet address from MetaMask
  2. Visit a faucet:
  3. Paste your address and request testnet ETH
  4. Wait for confirmation (usually 1-2 minutes)

Step 4: Connect to DApp

  1. Open the DApp in your browser
  2. Click "Connect Wallet" button
  3. Approve the connection in MetaMask popup
  4. Your wallet address should appear in the UI

Step 5: Interact with Smart Contracts

  1. Ensure you're on the correct network
  2. Perform actions through the UI
  3. Confirm transactions in MetaMask
  4. Wait for transaction confirmation

๐Ÿ“ธ Screenshots

Home Page

Home Page Main landing page with wallet connection

Wallet Connected

Wallet Connected Dashboard after successful wallet connection

Transaction Flow

Transaction Transaction confirmation interface

Mobile View

Mobile Responsive Mobile-responsive design

Note: Add your actual screenshots to the /screenshots directory


๐Ÿ“ Folder Structure

dapp-frontend/
โ”œโ”€โ”€ public/                  # Static assets
โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ””โ”€โ”€ assets/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/          # React components
โ”‚   โ”‚   โ”œโ”€โ”€ Navbar.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ WalletConnect.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ ContractInteraction.jsx
โ”‚   โ”‚   โ””โ”€โ”€ TransactionList.jsx
โ”‚   โ”œโ”€โ”€ services/            # Blockchain service layer
โ”‚   โ”‚   โ”œโ”€โ”€ contract.js      # Contract interaction logic
โ”‚   โ”‚   โ””โ”€โ”€ wallet.js        # Wallet connection logic
โ”‚   โ”œโ”€โ”€ utils/               # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ helpers.js
โ”‚   โ”‚   โ””โ”€โ”€ constants.js
โ”‚   โ”œโ”€โ”€ hooks/               # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ useWallet.js
โ”‚   โ”‚   โ””โ”€โ”€ useContract.js
โ”‚   โ”œโ”€โ”€ pages/               # Page components
โ”‚   โ”‚   โ”œโ”€โ”€ Home.jsx
โ”‚   โ”‚   โ””โ”€โ”€ Dashboard.jsx
โ”‚   โ”œโ”€โ”€ abi/                 # Contract ABIs
โ”‚   โ”‚   โ””โ”€โ”€ contractABI.json
โ”‚   โ”œโ”€โ”€ App.jsx              # Root component
โ”‚   โ”œโ”€โ”€ main.jsx             # Entry point
โ”‚   โ””โ”€โ”€ index.css            # Global styles
โ”œโ”€โ”€ .env.example             # Environment variables template
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ vite.config.js           # Vite configuration
โ”œโ”€โ”€ tailwind.config.js       # Tailwind CSS configuration
โ””โ”€โ”€ README.md

โš ๏ธ Common Issues & Troubleshooting

MetaMask Issues

Problem: MetaMask not detected

Solution:
1. Ensure MetaMask extension is installed
2. Refresh the page
3. Check if MetaMask is unlocked
4. Try a different browser

Problem: Wrong network connected

Solution:
1. Open MetaMask
2. Click network dropdown
3. Select the correct testnet (e.g., Sepolia)
4. Refresh the DApp

Problem: Transaction failed

Solution:
1. Check if you have enough testnet ETH
2. Verify gas price settings
3. Ensure you're on the correct network
4. Check contract address in .env file

RPC Errors

Problem: "Error: could not detect network"

Solution:
1. Check your internet connection
2. Verify RPC URL in .env file
3. Try switching to a different RPC provider
4. Check if the testnet is operational

Problem: RPC rate limiting

Solution:
1. Use your own Infura/Alchemy API key
2. Add delays between requests
3. Implement request caching

Build Errors

Problem: "Module not found" errors

Solution:
1. Delete node_modules folder
2. Delete package-lock.json
3. Run: npm install
4. Restart dev server

Problem: Environment variables not loading

Solution:
1. Ensure .env file is in root directory
2. Variables must start with VITE_
3. Restart the dev server after changes
4. Check for typos in variable names

Contract Interaction Issues

Problem: Contract functions not working

Solution:
1. Verify contract address in .env
2. Check if ABI file is up to date
3. Ensure contract is deployed on the connected network
4. Verify function signatures match the ABI

๐Ÿ”ฎ Future Improvements

  • Multi-wallet support (WalletConnect, Coinbase Wallet)
  • Dark mode / Light mode toggle
  • Transaction history with filtering
  • ENS (Ethereum Name Service) integration
  • Internationalization (i18n) support
  • Advanced error logging and analytics
  • Unit and integration tests
  • Performance optimization with React.memo
  • Web3 onboarding tutorial for new users
  • Support for multiple networks (Polygon, Arbitrum)
  • Gasless transactions using meta-transactions
  • IPFS integration for decentralized storage
  • Subgraph integration for better data querying

โš–๏ธ Disclaimer

IMPORTANT: This project is for educational and testing purposes only.

  • This DApp operates exclusively on Ethereum testnets
  • No real money or mainnet assets are involved
  • Testnet ETH has no monetary value
  • Do not use this application with mainnet or real funds
  • The developers are not responsible for any loss of funds
  • Always verify smart contract addresses before interaction
  • This is not financial advice

Security Notice:

  • Never share your private keys or seed phrase
  • Always verify transaction details before signing
  • Use testnets for learning and development
  • Conduct thorough security audits before mainnet deployment

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ง Contact

For questions or feedback, please reach out:


๐Ÿ™ Acknowledgments


Built with โค๏ธ for the blockchain community

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors