Skip to content

ryzen-xp/Charity_Chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— 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 ⭐

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors