How arka7777/crowdfunding-dapp works
Project Type and Purpose
• This is a full-stack decentralized application (“DApp”) for crowdfunding on the Avalanche Fuji Testnet.
• Frontend: React + Vite + Tailwind CSS, deployed on Vercel; blockchain interaction via Ethers.js and MetaMask.
• Smart Contracts: Solidity contracts (Crowdfunding.sol) tested in Remix IDE and deployed on Avalanche Fuji.
File Structure
Top-level:
• Client/ … (React app)
• smart Contracts/ … (Solidity source and any deployment scripts)
Inside Client/:
• public/, index.html – static assets and entry point
• src/
– App.jsx, main.jsx – React entry points
– components/ – UI components (Home, CreateCampaign, Explore, MyCampaigns, Navbar, Footer, Loading)
– context/contractContext.jsx – React Context for providing contract instance and wallet state
– abi/contractABI.json – the compiled contract interface used by Ethers.js
– assets/, index.css – styling and images
Config/Deployment files:
– package.json, vite.config.js, vercel.json – build and hosting settings
– eslint.config.js – lint rules
README for Additional Insights
The README confirms:
• Users connect MetaMask, create and fund campaigns, data lives on-chain.
• No off-chain database—state is managed by the Solidity contract.
• Smart contract maintains campaign structs, donor addresses, funding totals.
Main Components & Their Responsibilities
a. Client Browser & UI (React + Vite)
– Renders pages and components under src/components
– Loads configuration (contract address + ABI) from src/abi
– Uses contractContext to inject Web3 provider
b. Wallet / Web3 Provider
– MetaMask browser extension (user’s private key management)
– Injects window.ethereum API
c. Ethers.js Layer (in contractContext)
– Wraps Web3 provider, creates Contract instances via contract ABI & address
– Exposes methods: createCampaign, fundCampaign, fetchCampaigns
d. Avalanche Fuji Testnet (Blockchain Layer)
– Public RPC endpoints (e.g., https://api.avax-test.network/ext/bc/C/rpc)
– Hosts the deployed Crowdfunding.sol contract
– Persists state (campaign data, transactions)
e. Deployment & Development Tools
– Vercel (serves the static frontend)
– Remix IDE (contract authoring & testing)
Relationships & Data Flow
1. User opens the React app in browser (served by Vercel).
2. React UI calls methods from contractContext → Ethers.js
3. Ethers.js sends JSON-RPC requests via MetaMask to Avalanche Fuji.
4. Blockchain executes Crowdfunding.sol logic, updates state.
5. Event receipts and updated state propagate back to UI.
Essential Architectural Patterns
• DApp pattern: UI ↔ Web3 provider ↔ Blockchain
• React Context for dependency injection of the contract instance
• Component-based UI layering (Home, Explore, CreateCampaign, MyCampaigns)
Final Checklist
– All components (Frontend, Wallet, Ethers.js layer, Blockchain, Smart Contract) labeled
– Notes for external tools (Vercel, Remix) in supporting roles