Skip to content

anumukul/ROSCA-Guard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ROSCA-Guard πŸ›‘οΈ

Backend License Self Protocol PYUSD

Privacy-preserving identity verification for decentralized Rotating Savings and Credit Associations (ROSCAs) powered by Self Protocol and PYUSD.

🌟 Overview

ROSCA-Guard revolutionizes traditional rotating savings circles by combining blockchain technology with zero-knowledge identity verification. Built for the Self Protocol hackathon, this platform enables verified users to participate in automated savings circles while maintaining complete privacy.

Key Features

  • πŸ” Zero-Knowledge KYC: Identity verification using Self Protocol (Passport & Aadhaar support)
  • πŸ’° PYUSD Integration: Stablecoin-based automated payments and payouts
  • ⛓️ Cross-Chain Architecture: KYC on Celo, ROSCA operations on Ethereum
  • πŸ“Š Smart Contract Automation: No manual coordination required
  • 🎯 Reputation System: Merit-based payout selection
  • πŸ“ˆ DeFi Yield: Earn additional returns on pooled funds
  • 🌍 Global Access: Support for region-specific and international circles

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Frontend (React)                      β”‚
β”‚  - RainbowKit Wallet Connection                         β”‚
β”‚  - Self Protocol QR Code Integration                    β”‚
β”‚  - ROSCA Circle Management UI                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Backend (Express.js + TypeScript)           β”‚
β”‚  - Self Protocol Backend Verifier                       β”‚
β”‚  - Cross-Chain Bridge Service                           β”‚
β”‚  - API Gateway                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                             β”‚
       β–Ό                             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Celo Testnet  β”‚          β”‚ Ethereum Sepoliaβ”‚
β”‚                 β”‚          β”‚                 β”‚
β”‚  KYC Verifier   β”‚          β”‚  ROSCA Factory  β”‚
β”‚  (Self Protocol)β”‚          β”‚  ROSCA Circles  β”‚
β”‚                 β”‚          β”‚  PYUSD Token    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js >= 18.0.0
  • npm >= 8.0.0
  • MetaMask or compatible Web3 wallet
  • Self Protocol mobile app (iOS / Android)

Installation

  1. Clone the repository
git clone https://github.com/anumukul/ROSCA-Guard.git
cd ROSCA-Guard
  1. Install Backend Dependencies
cd backend
npm install
  1. Configure Backend Environment
cp .env.example .env

Edit .env with your configuration:

NODE_ENV=development
PORT=3001

# Blockchain RPCs
CELO_RPC_URL=https://alfajores-forno.celo-testnet.org
ETHEREUM_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY

# Contract Addresses
KYC_VERIFIER_ADDRESS=0xAE8d27497451A252815B86898CDAd029be1417e9
ROSCA_FACTORY_ADDRESS=0x9F01d0beE74AC0aF15a390cF5bd54E28EF4BbBac

# Self Protocol
SELF_CONFIG_ID=0x766466f264a44af31cd388cd05801bcc5dfff4980ee97503579db8b3d0742a7e

# Frontend URL
FRONTEND_URL=http://localhost:3000
  1. Start Backend
npm run dev
  1. Install Frontend Dependencies
cd ../frontend
npm install --legacy-peer-deps
  1. Configure Frontend Environment
cp .env.example .env

Edit .env:

VITE_API_URL=http://localhost:3001
VITE_SELF_CONFIG_ID=0x766466f264a44af31cd388cd05801bcc5dfff4980ee97503579db8b3d0742a7e
  1. Start Frontend
npm run dev

Visit http://localhost:3000 πŸŽ‰

πŸ“± Usage

For Users

  1. Verify Identity

    • Connect your Web3 wallet
    • Choose verification method (Passport or Aadhaar)
    • Scan QR code with Self Protocol app
    • Complete zero-knowledge verification
  2. Create or Join ROSCA Circle

    • Browse available circles or create new one
    • Set monthly contribution amount in PYUSD
    • Define circle parameters (size, duration, eligibility)
  3. Participate in Circles

    • Make monthly PYUSD contributions automatically
    • Receive payouts when it's your turn
    • Earn yield on pooled funds
    • Build reputation through consistent participation

For Developers

Deploy Smart Contracts

cd contracts

# Install dependencies
npm install
forge install

# Configure deployment
cp .env.example .env
# Edit .env with your private key and RPC URLs

# Deploy KYC Verifier on Celo
forge script script/DeployKYC.s.sol --rpc-url $CELO_RPC_URL --broadcast --verify

# Deploy ROSCA Factory on Ethereum
forge script script/DeployFactory.s.sol --rpc-url $ETHEREUM_RPC_URL --broadcast --verify

Run Tests

# Backend tests
cd backend
npm test

# Smart contract tests
cd contracts
forge test

# Frontend tests
cd frontend
npm test

πŸ”§ Technology Stack

Frontend

  • Framework: React 18 + TypeScript
  • Build Tool: Vite
  • Styling: Tailwind CSS
  • Web3: RainbowKit + wagmi + viem
  • Identity: Self Protocol SDK (@selfxyz/core, @selfxyz/qrcode)
  • State Management: React Query
  • Routing: React Router v6

Backend

  • Runtime: Node.js + Express.js
  • Language: TypeScript
  • Identity Verification: Self Protocol Backend Verifier
  • Blockchain Interaction: ethers.js v5
  • Security: Helmet, CORS, Rate Limiting
  • Validation: express-validator

Smart Contracts

  • Language: Solidity 0.8.28
  • Framework: Foundry
  • Identity: Self Protocol Verification Root
  • Standards: ERC-20 (PYUSD), Custom ROSCA logic
  • Networks: Celo (KYC), Ethereum (ROSCAs)

DevOps

  • Backend Hosting: Render
  • Frontend Hosting: Vercel
  • Version Control: Git + GitHub
  • CI/CD: GitHub Actions (optional)

πŸ“Š Smart Contracts

Deployed Contracts

Celo Alfajores Testnet

  • KYC Verifier: 0xAE8d27497451A252815B86898CDAd029be1417e9
  • Network: Celo Alfajores
  • Explorer: View on CeloScan

Ethereum Sepolia Testnet

  • ROSCA Factory: 0x9F01d0beE74AC0aF15a390cF5bd54E28EF4BbBac
  • ROSCA Analytics: 0x45Fdf95185922b91627F0B340AFA3DF0fED650E7
  • Mock PYUSD: 0x1e4e7e50E176A66BBEFC61331898F5ffdE49DBd6
  • Network: Ethereum Sepolia
  • Explorer: View on Etherscan

Key Contracts

KYCVerifier.sol

Extends Self Protocol's SelfVerificationRoot for on-chain identity verification.

function isEligibleForROSCA(
    address user,
    string memory requiredCountry,
    uint256 circleMinAge,
    uint256 circleMaxAge
) external view returns (bool eligible, string memory reason);

ROSCAFactory.sol

Factory pattern for creating and managing ROSCA circles.

function createCircle(
    uint256 monthlyAmount,
    uint256 maxMembers,
    uint256 duration,
    string memory country,
    uint256 minAge,
    uint256 maxAge
) external returns (uint256 circleId);

ROSCACircle.sol

Individual ROSCA circle with automated payment cycles and reputation tracking.

function joinCircle() external onlyKYCVerified;
function makeContribution() external onlyMember;
function distributePayout() external onlyOwner;

πŸ” Self Protocol Integration

Backend Verification

import { SelfBackendVerifier, AllIds, DefaultConfigStore } from "@selfxyz/core";

const verifier = new SelfBackendVerifier(
  "rosca-guard-v1",
  "https://rosca-guard.onrender.com/api/self/verify-self",
  false, // production mode
  AllIds,
  new DefaultConfigStore({
    minimumAge: 18,
    excludedCountries: [],
    ofac: true,
  }),
  "uuid"
);

const result = await verifier.verify(
  attestationId,
  proof,
  publicSignals,
  userContextData
);

Contract Verification

contract KYCVerifier is SelfVerificationRoot {
    function customVerificationHook(
        ISelfVerificationRoot.GenericDiscloseOutputV2 memory output,
        bytes memory userData
    ) internal override {
        // Store verified user data on-chain
        verifiedUsers[userAddress] = VerifiedUser({
            nationality: output.nationality,
            age: calculatedAge,
            verificationTimestamp: block.timestamp,
            isVerified: true
        });
    }
}

🌐 API Documentation

Base URL

  • Production: https://rosca-guard.onrender.com
  • Development: http://localhost:3001

Endpoints

Health Check

GET /health

Verify Identity (Self Protocol)

POST /api/self/verify-self
Content-Type: application/json

{
  "attestationId": "1",
  "proof": {...},
  "publicSignals": {...},
  "userContextData": "..."
}

Get KYC Status

GET /api/self/kyc-status/:address

Check ROSCA Eligibility

POST /api/self/check-eligibility
Content-Type: application/json

{
  "userAddress": "0x...",
  "circleId": 1
}

Get Platform Statistics

GET /api/bridge/stats

Create ROSCA Circle

POST /api/bridge/create-circle
Content-Type: application/json

{
  "monthlyAmount": 100,
  "maxMembers": 5,
  "duration": 12,
  "country": "IN",
  "minAge": 18,
  "maxAge": 65
}

For complete API documentation, see API.md

πŸ§ͺ Testing

Get Testnet Tokens

Celo Alfajores (for KYC transactions)

Ethereum Sepolia (for ROSCA operations)

Mock PYUSD

  • Use the faucet function in the deployed contract
  • Or call faucet(amount) to mint test tokens

Test Self Protocol Verification

  1. Install Self Protocol app on your mobile device
  2. Set up test passport in the app (staging mode)
  3. Run the frontend locally
  4. Scan QR code to initiate verification
  5. Complete the verification flow

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Workflow

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

πŸ“ Project Structure

ROSCA-Guard/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/              # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ bridgeRoutes.ts
β”‚   β”‚   β”‚   └── selfRoutes.ts
β”‚   β”‚   β”œβ”€β”€ services/         # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ CrossChainBridge.ts
β”‚   β”‚   β”‚   └── SelfVerificationService.ts
β”‚   β”‚   └── app.ts           # Express app
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json
β”œβ”€β”€ contracts/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ KYCVerifier.sol
β”‚   β”‚   β”œβ”€β”€ ROSCAFactory.sol
β”‚   β”‚   β”œβ”€β”€ ROSCACircle.sol
β”‚   β”‚   β”œβ”€β”€ ROSCAAnalytics.sol
β”‚   β”‚   β”œβ”€β”€ YieldManager.sol
β”‚   β”‚   └── DateParser.sol
β”‚   β”œβ”€β”€ script/              # Deployment scripts
β”‚   β”œβ”€β”€ test/                # Contract tests
β”‚   └── foundry.toml
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”‚   β”œβ”€β”€ pages/           # Page components
β”‚   β”‚   β”œβ”€β”€ hooks/           # Custom hooks
β”‚   β”‚   β”œβ”€β”€ services/        # API services
β”‚   β”‚   β”œβ”€β”€ config/          # Configuration
β”‚   β”‚   └── App.tsx
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
└── README.md

πŸ† Hackathon Submission

Self Protocol Integration

  • Backend SDK: SelfBackendVerifier for proof verification
  • Smart Contracts: SelfVerificationRoot integration
  • Zero-Knowledge Proofs: Privacy-preserving identity verification
  • Multi-Document Support: Passport and Aadhaar verification

PYUSD Integration

  • Primary Currency: All ROSCA contributions in PYUSD
  • Smart Contract Integration: ERC-20 standard implementation
  • Automated Payments: Monthly contributions and payouts
  • Yield Generation: DeFi integration for returns

Innovation

  • Cross-Chain Architecture: KYC on Celo, operations on Ethereum
  • Reputation System: Merit-based payout selection
  • Sybil Resistance: Identity verification prevents fake accounts
  • Financial Inclusion: Accessible global savings circles

πŸ“„ License

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

πŸ™ Acknowledgments

  • Self Protocol for zero-knowledge identity verification
  • PayPal/Paxos for PYUSD stablecoin
  • Celo Foundation for affordable blockchain infrastructure
  • Ethereum Foundation for smart contract platform
  • ETHGlobal for hosting hackathons and fostering innovation

πŸ“ž Contact & Links

Team

🚧 Roadmap

  • Self Protocol KYC integration
  • PYUSD smart contract implementation
  • Cross-chain bridge architecture
  • Backend API deployment
  • Frontend deployment on Vercel
  • Mainnet deployment
  • Mobile app integration
  • Additional DeFi yield sources
  • Governance features
  • Multi-language support

Built with ❀️ for the EthGlobal New-Delhi Hackathon

Empowering financial inclusion through privacy-preserving identity verification

About

Sybil-resistant savings circles powered by verified identity and PYUSD, bringing traditional ROSCAs to the crypto era with automated AI management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors