Skip to content

Latest commit

 

History

History
246 lines (180 loc) · 8.81 KB

File metadata and controls

246 lines (180 loc) · 8.81 KB

🔗 CharityChain

Transparent Decentralized Charity Platform on Ethereum

Live Demo Solidity Next.js License: MIT

CharityChain eliminates the trust problem in charitable giving. Every donation is recorded immutably on-chain — no intermediaries, no black boxes, full accountability.

🌐 Live App · 📄 Smart Contract · 🚀 Quick Start


🧩 The Problem It Solves

Traditional charity platforms suffer from:

  • Opacity — donors have no visibility into where their funds go
  • Intermediaries — multiple parties handle funds before reaching beneficiaries
  • Trust dependency — donors must trust the organization's internal processes

CharityChain replaces all of that with code you can verify.


✨ Key Features

Feature Description
🔐 Trustless Donations Smart contract enforces fund distribution rules — no human override
📊 On-Chain Transparency Every donation, campaign creation, and withdrawal is publicly verifiable
🏗️ Campaign Management Charity organizations can create and manage campaigns with defined goals
👛 MetaMask Integration Seamless wallet connection for donors and campaign managers
Real-time Updates UI reflects blockchain state live — no stale data
🌍 Permissionless Anyone with an Ethereum wallet can donate — no KYC, no gatekeeping

🏛️ Architecture

┌─────────────────────────────────────────────────────────────┐
│                        Frontend (Next.js)                   │
│   pages/  │  components/  │  styles/  │  lib/ (Web3 hooks) │
└─────────────────────────┬───────────────────────────────────┘
                          │  ethers.js / web3.js
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                  MetaMask (Browser Wallet)                   │
└─────────────────────────┬───────────────────────────────────┘
                          │  JSON-RPC
                          ▼
┌─────────────────────────────────────────────────────────────┐
│              Ethereum Network (Testnet / Mainnet)            │
│                                                             │
│   ┌─────────────────────────────────────────────────────┐  │
│   │           CharityChain Smart Contract               │  │
│   │   • createCampaign()   • donate()                   │  │
│   │   • withdrawFunds()    • getCampaigns()             │  │
│   └─────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────┘

🛠️ Tech Stack

Smart Contract

  • Solidity — smart contract logic
  • Hardhat / Truffle — compile, test, deploy
  • Ethereum — target blockchain

Frontend

  • Next.js — React framework with SSR/SSG
  • ethers.js / web3.js — blockchain interaction layer
  • MetaMask — wallet provider
  • CSS Modules — component-scoped styling

Infrastructure

  • Netlify — frontend deployment
  • IPFS / Alchemy / Infura — RPC node provider

🚀 Quick Start

Prerequisites

  • Node.js v16+
  • Yarn
  • MetaMask browser extension
  • An Ethereum testnet account with test ETH (Sepolia faucet)

1. Clone & Install

git clone https://github.com/ryzen-xp/Charity_Chain.git
cd Charity_Chain
yarn install

2. Configure Environment

cp .env.example .env.local

Edit .env.local:

NEXT_PUBLIC_CONTRACT_ADDRESS=your_deployed_contract_address
NEXT_PUBLIC_CHAIN_ID=11155111        # Sepolia testnet
NEXT_PUBLIC_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY

3. Deploy Smart Contract

cd smart-contract
yarn install
npx hardhat compile
npx hardhat run scripts/deploy.js --network sepolia

Copy the deployed contract address into your .env.local.

4. Run the Frontend

# Back in project root
yarn dev

Open http://localhost:3000 — connect MetaMask and start donating.


📁 Project Structure

Charity_Chain/
├── components/          # Reusable React components
│   ├── CampaignCard/    # Campaign display component
│   ├── DonateModal/     # Donation flow UI
│   └── Navbar/          # Wallet connection + navigation
├── pages/               # Next.js pages (routing)
│   ├── index.js         # Home — campaign listings
│   ├── create.js        # Create new campaign
│   └── campaign/[id].js # Individual campaign detail
├── lib/                 # Utilities & Web3 hooks
│   ├── contract.js      # Contract ABI + address config
│   └── web3.js          # Wallet connection helpers
├── smart-contract/      # Solidity contracts + deploy scripts
│   ├── contracts/       # CharityChain.sol
│   ├── scripts/         # Deployment scripts
│   └── test/            # Contract unit tests
├── public/              # Static assets
└── styles/              # Global & module CSS

📄 Smart Contract

The CharityChain contract is the heart of the platform. Key functions:

// Create a new charity campaign
function createCampaign(
    string memory title,
    string memory description,
    uint256 target,
    uint256 deadline,
    address beneficiary
) external returns (uint256 campaignId);

// Donate ETH to a campaign
function donate(uint256 campaignId) external payable;

// Withdraw raised funds (only beneficiary, only if goal met or deadline passed)
function withdrawFunds(uint256 campaignId) external;

// Query all campaigns
function getCampaigns() external view returns (Campaign[] memory);

All state changes emit events for off-chain indexing and UI reactivity.


🔒 Security Design

  • Access control — only campaign beneficiaries can withdraw funds
  • Deadline enforcement — withdrawals blocked before the campaign deadline unless target is reached
  • Reentrancy protection — fund transfers follow the checks-effects-interactions pattern
  • No admin keys — no privileged owner address that can drain funds

🗺️ Roadmap

  • Multi-token donations (ERC-20 support)
  • Campaign verification / KYC tier for trusted NGOs
  • Donor NFT receipts as proof of contribution
  • DAO-based governance for platform parameters
  • Subgraph (The Graph) integration for faster data indexing
  • Layer 2 deployment (Polygon / Arbitrum) for lower gas fees

🤝 Contributing

Contributions are welcome! Please open an issue first to discuss what you'd like to change.

# Fork the repo, then:
git checkout -b feature/your-feature-name
git commit -m "feat: add your feature"
git push origin feature/your-feature-name
# Open a Pull Request

👨‍💻 Author

Sandeep (@ryzen-xp)

Blockchain & Web3 developer with experience in Solidity, Rust, TypeScript, and Soroban/Stellar. Open to remote opportunities.

GitHub


📜 License

MIT © ryzen-xp


Built with ❤️ for transparent giving. If this project helped you, consider leaving a ⭐