Community Blockchain - Web3 Disaster Relief Fund

rushi

rushi kesh

๐ŸŒ Community Blockchain - Web3 Disaster Relief Fund

A decentralized disaster relief funding platform built with cutting-edge Web3 and privacy-preserving technologies. This project combines blockchain transparency with zero-knowledge privacy to create a secure, anonymous, and efficient disaster relief system.

๐Ÿš€ Advanced Technologies Used

๐Ÿ” Zero-Knowledge Proofs (ZKP)

Anon Aadhaar ZK-SNARKs: Privacy-preserving identity verification
Nullifier System: Prevents double-spending and duplicate claims
Identity Privacy: Verify eligibility without revealing personal data
Cryptographic Proofs: Mathematical verification without data exposure

๐ŸŒ Web3 & Blockchain Stack

Ethereum Blockchain: Decentralized infrastructure
Solidity Smart Contracts: Immutable business logic
Ethers.js v6: Advanced blockchain interactions
Wagmi v2: React hooks for Ethereum
Web3Modal v4: Multi-wallet connectivity
Viem v2: Type-safe Ethereum client
Hardhat: Smart contract development framework

๐Ÿ›ก๏ธ Privacy & Security Technologies

Zero-Knowledge Circuits: Anon Aadhaar verification circuits
Cryptographic Nullifiers: Unique proof identifiers
Groth16 Protocol: Efficient ZK-SNARK implementation
Merkle Tree Proofs: Efficient membership verification
Poseidon Hashing: ZK-friendly hash function

โš›๏ธ Frontend Technologies

Next.js 15: React meta-framework with SSR
React 18: Modern UI with concurrent features
TypeScript: Type-safe development
Tailwind CSS: Utility-first styling
React Query: Blockchain state management

๐Ÿ”— Blockchain Infrastructure

JSON-RPC Providers: Blockchain communication
Smart Contract ABIs: Contract interfaces
Transaction Management: State updates and events
Gas Optimization: Efficient contract execution
Multi-network Support: Testnet and mainnet deployment

๐Ÿ—๏ธ System Architecture

Frontend Layer

Next.js Application
โ”œโ”€โ”€ Components (UI/UX)
โ”œโ”€โ”€ Pages (Routes)
โ”œโ”€โ”€ Web3 Integration
โ””โ”€โ”€ State Management

Web3 Integration Layer

Wagmi Hooks
โ”œโ”€โ”€ Wallet Connection
โ”œโ”€โ”€ Contract Interactions
โ”œโ”€โ”€ Transaction Management
โ””โ”€โ”€ Network Switching

Privacy Layer

Anon Aadhaar System
โ”œโ”€โ”€ ZK Proof Generation
โ”œโ”€โ”€ Identity Verification
โ”œโ”€โ”€ Nullifier Management
โ””โ”€โ”€ Privacy Preservation

Blockchain Layer

Ethereum Network
โ”œโ”€โ”€ DisasterFundPool Contract
โ”œโ”€โ”€ AnonAadhaarVote Contract
โ”œโ”€โ”€ Verifier Contracts
โ””โ”€โ”€ Access Control

๐ŸŽฏ Core Features

๐Ÿ”’ Privacy-First Design

Anonymous Donations: Contribute without revealing identity
Private Claims: Claim funds with ZK proof verification
Identity Protection: Verify eligibility without data exposure
Nullifier Prevention: Stop duplicate claims cryptographically

๐Ÿ’ฐ Transparent Fund Management

On-chain Tracking: All transactions visible on blockchain
Real-time Updates: Live fund status and distributions
Immutable Records: Tamper-proof transaction history
Audit Trail: Complete funding lifecycle tracking

๐ŸŽ›๏ธ Admin Controls

Project Authorization: Admin approves community projects
Status Management: Activate/deactivate funding campaigns
Access Control: Role-based permissions system
Governance: Decentralized decision making

๐Ÿ” Advanced Security

Smart Contract Security: Audited contract logic
Access Modifiers: Function-level permissions
Reentrancy Protection: Attack prevention mechanisms
Input Validation: Comprehensive data verification

๐Ÿ› ๏ธ Development Setup

Prerequisites

Node.js 18+
npm or yarn
MetaMask wallet
Ethereum testnet ETH

Installation

# Clone repository
git clone https://github.com/rushikesh0022/community_blockchain.git
cd community_blockchain

# Install dependencies
npm install --legacy-peer-deps

# Setup environment variables
cp .env.local.example .env.local
# Add your contract addresses and keys

Smart Contract Development

# Navigate to contracts directory
cd contracts

# Compile contracts
npx hardhat compile

# Run tests
npx hardhat test

# Deploy to local network
npx hardhat node
npx hardhat run scripts/deploy.cjs --network localhost

# Deploy to testnet
npx hardhat run scripts/deploy.cjs --network sepolia

Frontend Development

# Start development server
npm run dev

# Build for production
npm run build

# Start production server
npm start

๐Ÿงช Zero-Knowledge Implementation

Anon Aadhaar Integration

// ZK Proof Generation
const proof = await generateAnonAadhaarProof({
aadhaarData: userData,
signal: walletAddress,
fieldsToReveal: ["pincode"],
});

// Proof Verification
const isValid = await verifyAnonAadhaarProof(proof);

Privacy Workflow

Identity Verification: Generate ZK proof from Aadhaar data
Nullifier Creation: Unique identifier prevents reuse
Proof Submission: Submit proof to smart contract
Cryptographic Verification: Contract verifies without data access
Action Authorization: Execute claim/vote if proof valid

๐Ÿ“‹ Smart Contract Functions

DisasterFundPool.sol

// Project Management
function registerDisaster(string memory name, string memory description,
uint256 pincode, uint256 initialFunding) external onlyOwner

// Funding
function addFundsToDisaster(uint256 disasterId) external payable

// Claims with ZK Verification
function claimFunds(uint256 disasterId, uint256 nullifierSeed,
uint256 nullifier, uint256 timestamp,
address signal, uint256[4] calldata revealArray,
uint256[8] calldata groth16Proof) external

// Data Retrieval
function getDisasterDetails(uint256 disasterId) external view returns (...)

Zero-Knowledge Verification

// Verify Anon Aadhaar proof
modifier verifyAnonAadhaarProof(uint256 nullifierSeed, uint256 nullifier,
uint256 timestamp, address signal,
uint256[4] calldata revealArray,
uint256[8] calldata groth16Proof) {
require(anonAadhaarVerifierAddr.verifyAnonAadhaarProof(
nullifierSeed, nullifier, timestamp, signal, revealArray, groth16Proof
), "Invalid proof");
_;
}

๐ŸŒ Network Configuration

Supported Networks

Local Development: Hardhat Network
Testing: Ethereum Sepolia Testnet
Production: Ethereum Mainnet

Contract Addresses

# Test Environment
DISASTER_FUND_POOL_TEST=0xB7696E510113C3F3063f869de7e5Ed49Bc1E8b5C
ANON_AADHAAR_VERIFIER=0x6bE8Cec7a06BA19c39ef328e8c8940cEfeF7E281

# Production Environment
DISASTER_FUND_POOL_PROD=0x...

๐Ÿ”„ Data Flow

Donation Flow

User โ†’ Connect Wallet โ†’ Select Project โ†’ Enter Amount โ†’
Sign Transaction โ†’ Blockchain Update โ†’ UI Refresh

Claim Flow

User โ†’ Generate ZK Proof โ†’ Submit Claim โ†’ Contract Verification โ†’
Nullifier Check โ†’ Fund Transfer โ†’ Event Emission

Admin Flow

Admin โ†’ Create Project โ†’ Set Parameters โ†’ Deploy to Blockchain โ†’
Community Access โ†’ Fund Collection โ†’ Distribution Management

๐Ÿ“š Additional Documentation

Architecture Diagram - Complete system architecture
Blockchain Concepts - Detailed blockchain explanations
Smart Contracts - Contract documentation

๐Ÿค Contributing

Fork the repository
Create feature branch (git checkout -b feature/amazing-feature)
Commit changes (git commit -m 'Add amazing feature')
Push to branch (git push origin feature/amazing-feature)
Open Pull Request

๐Ÿ“„ License

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

๐Ÿš€ Deployment

Frontend Deployment

Vercel: Optimized for Next.js applications
Netlify: Alternative hosting platform
IPFS: Decentralized hosting option

Smart Contract Deployment

# Deploy to testnet
npx hardhat run scripts/deploy.cjs --network sepolia

# Verify on Etherscan
npx hardhat verify --network sepolia CONTRACT_ADDRESS

๐Ÿ”ฎ Future Enhancements

Multi-chain Support: Deploy on Polygon, BSC, etc.
DAO Governance: Community-driven project approval
Advanced Analytics: ML-powered fraud detection
Mobile App: React Native implementation
Layer 2 Integration: Lower transaction costs

๐Ÿ›Ÿ Support

Discussions: GitHub Discussions
Documentation: Check the docs folder for detailed guides
Built with โค๏ธ using cutting-edge Web3 and Zero-Knowledge technologies # or yarn install

## Environment Setup

This project requires environment variables for configuration.

1. **Root Directory (`.env`):**
Create a `.env` file in the project root by copying the example:

```bash
cp .env.local.example .env
```

Update the following variables in the `.env` file:

- `NEXT_PUBLIC_ANON_AADHAAR_CONTRACT_ADDRESS`: The deployed Anon Aadhaar Verifier contract address (often a standard one, check Anon Aadhaar docs). The example uses `6bE8Cec7a06BA19c39ef328e8c8940cEfeF7E281`.
- `NEXT_PUBLIC_VOTE_CONTRACT_ADDRESS_PROD`/`_TEST`: The deployed `AnonAadhaarVote` contract address. You will get this after deployment.
- `NEXT_PUBLIC_DISASTER_FUND_POOL_ADDRESS_PROD`/`_TEST`: The deployed `DisasterFundPool` contract address. You will get this after deployment.
- `NEXT_PUBLIC_PROJECT_ID`: Your WalletConnect Cloud project ID. Get one from [cloud.walletconnect.com](https://cloud.walletconnect.com/).
- `NEXT_PUBLIC_RPC_URL`: The RPC URL for the network you are deploying to (e.g., Sepolia, Holesky).
- `PRIVATE_KEY`: The private key of the wallet you will use for _deployment only_. **Handle with extreme care.**

2. **Contracts Directory (`contracts/.env`):**
Create a `.env` file within the `contracts` directory:
```bash
cp contracts/.env.example contracts/.env # Assuming you create an example file there
# or manually create contracts/.env
```
Add the following variables:
- `PRIVATE_KEY`: The private key of the account you'll use to deploy the contracts. **This is critical and should be kept secret.**
- `NEXT_PUBLIC_RPC_URL`: The RPC URL for the network (e.g., Holesky, Sepolia).
- Optionally, add API keys if needed for block explorers (e.g., `ETHERSCAN_API_KEY`).

## Contract Deployment

The smart contracts (`AnonAadhaarVote`, `DisasterFundPool`) are managed using Hardhat.

1. **Navigate to the contracts directory:**

```bash
cd contracts
```

2. **Install contract dependencies (if not already done by root `npm install`):**

```bash
npm install
# or
yarn install
```

3. **Compile the contracts:**

```bash
npx hardhat compile
```

4. **Deploy the contracts:**
Ensure your `contracts/.env` file is correctly set up with your `PRIVATE_KEY` and `NEXT_PUBLIC_RPC_URL`.
Run the deployment script:

```bash
npx hardhat run scripts/deploy.cjs --network <your_network_name>
```

Replace `<your_network_name>` with the network defined in your [`hardhat.config.js`](contracts/hardhat.config.js) (e.g., `sepolia`, `holesky`, `localhost`).

5. **Update `.env`:**
After successful deployment, the script ([`contracts/scripts/deploy.cjs`](contracts/scripts/deploy.cjs)) will output the addresses of the deployed `DisasterFundPool` and `AnonAadhaarVote` contracts. Copy these addresses and paste them into the corresponding `NEXT_PUBLIC_VOTE_CONTRACT_ADDRESS_...` and `NEXT_PUBLIC_DISASTER_FUND_POOL_ADDRESS_...` variables in the root `.env` file.

## Running the Application

1. **Navigate back to the root directory:**

```bash
cd ..
```

2. **Run in development mode:**

```bash
npm run dev
# or
yarn dev
```

Open [http://localhost:3000](http://localhost:3000) in your browser.

3. **Build for production:**

```bash
npm run build
# or
yarn build
```

4. **Start the production server:**
```bash
npm run start
# or
yarn start
```

## Linting

To check code style:

```bash
npm run lint
# or
yarn lint

Like this project

Posted Oct 24, 2025

Decentralized disaster relief platform using Web3 and privacy technologies.