Skip to main content

Rahat Project C2C - Technical Introduction

Overview

The Rahat Project C2C (Crypto-2-Crypto) is a comprehensive blockchain-based platform designed to facilitate secure, transparent, and efficient token disbursement for humanitarian aid and development projects. The system leverages smart contracts, multi-signature wallets, and decentralized infrastructure to ensure trustless and auditable financial transactions.

Architecture Overview

Monorepo Structure

The project is organized as a monorepo using Nx, containing multiple applications and libraries:

  • Backend API (apps/c2c/) - NestJS-based REST API
  • Smart Contracts (apps/contracts/) - Solidity smart contracts for blockchain operations
  • Subgraph (apps/graph/) - The Graph protocol for blockchain data indexing
  • React Query Library (libs/react-query/) - Frontend data fetching and state management
  • Extensions Library (libs/extensions/) - Shared DTOs and utilities
  • Contract Library (libs/contract/) - Smart contract abstractions

Technology Stack

Backend

  • Framework: NestJS (Node.js)
  • Database: PostgreSQL with Prisma ORM
  • Queue System: Bull with Redis
  • Authentication: Role-based access control
  • API Documentation: Swagger/OpenAPI

Blockchain

  • Smart Contracts: Solidity 0.8.20
  • Framework: Hardhat with Ignition deployment
  • Networks: Base Sepolia, Polygon Mumbai, Arbitrum Sepolia
  • Multi-sig: Safe Protocol integration
  • Token Standard: ERC-20

Frontend & Data

  • GraphQL: The Graph protocol for blockchain data
  • State Management: Zustand
  • Web3 Integration: Wagmi, Viem, Ethers.js
  • React Query: TanStack Query for data fetching

Core Components

1. Smart Contracts

C2CProject Contract

The main contract managing project operations:

contract C2CProject is AbstractProject, IC2CProject {
// Token management
function withdrawToken(address _tokenAddress, address _withdrawAddress)
function disburseProjectToken(address _tokenAddress, address _beneficiary, uint256 _amount)
function disburseOwnedToken(address _tokenAddress, address _beneficiary, uint256 _amount)

// Beneficiary management
function addBeneficiary(address _beneficiary)
function removeBeneficiary(address _beneficiary)
}

Key Features:

  • Token disbursement with balance validation
  • Beneficiary whitelisting and management
  • Multi-signature approval workflows
  • Event emission for transparency

RahatToken Contract

ERC-20 token implementation for the platform's native currency.

2. Backend API Modules

Beneficiary Management

  • Enrollment and verification of beneficiaries
  • Wallet address management
  • Referral system for beneficiary onboarding
  • Group-based organization

Campaign Management

  • Campaign creation and configuration
  • Message distribution via multiple transport channels
  • Beneficiary group targeting

Disbursement System

  • Multi-signature disbursement workflows
  • Token allocation and transfer
  • Approval tracking and audit trails
  • Integration with Safe Protocol

Communication Module

  • Multi-channel communication (SMS, Email, Push)
  • Template-based messaging
  • Delivery status tracking

3. Database Schema

Core Entities

  • Beneficiaries: Users receiving aid with wallet addresses
  • Campaigns: Aid distribution campaigns with targeting
  • Disbursements: Token transfer records with approval status
  • Settings: System configuration and parameters
  • Stats: Analytics and reporting data

Key Relationships

  • Beneficiaries can participate in multiple campaigns
  • Disbursements are linked to specific beneficiaries and campaigns
  • Multi-signature approvals track the approval workflow

4. Subgraph (Blockchain Data Indexing)

The Graph protocol indexes blockchain events for efficient querying:

  • Token Transfers: All ERC-20 token movements
  • Beneficiary Events: Addition/removal of beneficiaries
  • Approval Events: Multi-signature approval tracking
  • Project Events: Token budget changes and allocations

Use Cases

1. Humanitarian Aid Distribution

Scenario: International NGO distributing cash assistance to disaster-affected communities

Workflow:

  1. Project Setup: Deploy C2CProject contract with multi-signature configuration
  2. Beneficiary Enrollment: Register affected individuals with their wallet addresses
  3. Campaign Creation: Create aid distribution campaign with targeting criteria
  4. Token Funding: Transfer tokens to project contract via multi-signature
  5. Disbursement: Execute token transfers to beneficiary wallets
  6. Verification: Track all transactions on blockchain for transparency

Benefits:

  • Transparent fund flow tracking
  • Reduced corruption through blockchain immutability
  • Real-time disbursement status
  • Automated compliance reporting

2. Development Project Funding

Scenario: Government agency managing development project grants

Workflow:

  1. Grant Allocation: Set up project with approved budget
  2. Beneficiary Selection: Enroll qualified recipients
  3. Milestone-based Disbursement: Release funds based on project milestones
  4. Multi-party Approval: Require multiple signatures for large disbursements
  5. Audit Trail: Complete transaction history for compliance

3. Microfinance and Small Grants

Scenario: Microfinance institution providing small loans and grants

Workflow:

  1. Application Processing: Enroll loan/grant applicants
  2. Credit Scoring: Integrate with external verification systems
  3. Disbursement: Transfer tokens to approved recipients
  4. Repayment Tracking: Monitor loan repayments
  5. Reporting: Generate compliance and impact reports

4. Emergency Response

Scenario: Rapid response to humanitarian crises

Workflow:

  1. Rapid Deployment: Quick project setup with pre-approved templates
  2. Mobile Onboarding: QR code-based beneficiary registration
  3. Immediate Disbursement: Fast token transfers to affected individuals
  4. Real-time Monitoring: Live tracking of aid distribution
  5. Impact Assessment: Data collection for response evaluation

Technical Features

1. Multi-Signature Security

  • Safe Protocol integration for secure fund management
  • Configurable approval thresholds
  • Time-locked transactions for large amounts
  • Emergency pause functionality

2. QR Code Integration

  • Wallet address QR codes for easy beneficiary onboarding
  • Mobile-friendly registration process
  • Offline-capable beneficiary verification

3. Role-Based Access Control

  • Granular permissions for different user types
  • Whitelisting for sensitive operations
  • Audit logging for all administrative actions

4. Real-time Communication

  • Multi-channel messaging (SMS, Email, Push)
  • Template-based communication
  • Delivery status tracking
  • Automated notifications

5. Analytics and Reporting

  • Real-time dashboard with key metrics
  • Blockchain-based audit trails
  • Custom report generation
  • Impact measurement tools

Deployment Architecture

Development Environment

  • Local PostgreSQL database
  • Hardhat local blockchain
  • The Graph local node
  • Redis for queue management

Production Environment

  • Cloud-hosted PostgreSQL
  • Multi-chain deployment (Base, Polygon, Arbitrum)
  • The Graph hosted service
  • Redis cluster for scalability

Security Considerations

  • Multi-signature wallet integration
  • Role-based access control
  • Encrypted data transmission
  • Regular security audits
  • Compliance with financial regulations