Skip to content

Intelligence247/IlmQuest

Repository files navigation

IlmQuest: The Ethical "Learn-to-Earn" Protocol

Turning Knowledge into Capital on the Celo Blockchain

Built with Next.js Celo Network License

Live Demo: https://ilmquest-app.vercel.app


๐ŸŽฏ Overview

IlmQuest is a decentralized application (dApp) built for the MiniPay ecosystem that allows users in emerging markets to earn their first crypto asset (cUSD) by mastering financial concepts.

Unlike "Play-to-Earn" games that often rely on ponzi-nomics or gambling mechanics, IlmQuest utilizes the ancient Islamic Finance concept of Ju'alah (Reward for Service). Users perform a verified serviceโ€”educationโ€”and receive a guaranteed payment in return.

Tagline: Don't Bet. Learn.


๐Ÿ“ธ Application Screenshots

Landing Page

Landing Page Welcome screen with wallet connection. Users can connect their MiniPay or MetaMask wallet to get started.

Quest Dashboard

Quest Dashboard Available quests displayed with difficulty levels and rewards. Users can see their balance and select a quest to play.

Game in Progress

Game in Progress Memory matching game interface. Users flip cards to match crypto concepts with their definitions.

Knowledge Modal

Knowledge Modal Educational fact appears when a pair is matched. Users must acknowledge the fact to continue learning.

Victory Screen

Victory Screen Quest completion screen showing stats (moves, time) and reward amount. Users can claim their cUSD reward here.

Reward Claim

Reward Claim Transaction confirmation and success screen. Shows transaction hash and link to block explorer.

Profile Page

Profile Page User statistics dashboard showing total earned, quests completed, streaks, achievements, and detailed stats.

Admin Dashboard

Admin Dashboard Secret admin panel for managing quests. Admins can create, edit, delete, and toggle quest status.

Admin Quest Creation

Admin Quest Creation Form for creating new quests. Admins can add quest details, reward amounts, difficulty, and card pairs.


โœจ Key Features

  • ๐ŸŽฎ Memory Match Game - Learn crypto concepts through gamified education
  • ๐Ÿ’ฐ Fee Currency Abstraction - Pay gas fees in cUSD, no CELO required
  • ๐Ÿ” Trusted Oracle - Backend verifies game completion before reward
  • ๐Ÿ’ธ On-Chain Rewards - Direct cUSD payments via smart contract
  • ๐Ÿ“ฑ Mobile-First Design - Optimized for MiniPay users in emerging markets
  • ๐ŸŽฏ Admin Dashboard - Dynamic quest management system
  • ๐Ÿ“Š User Statistics - Track progress, streaks, and achievements
  • ๐Ÿ”„ Replay System - Users can replay quests after 24 hours for revision

๐ŸŽฎ User Flow & Features Explained

1. Landing Page

  • Purpose: Welcome users and connect wallet
  • Features:
    • Clean, mobile-first design
    • One-click wallet connection
    • Educational value proposition
    • Mobile wallet detection and instructions

2. Quest Dashboard (/play)

  • Purpose: Browse and select available quests
  • Features:
    • List of all active quests
    • Difficulty indicators (Beginner/Intermediate/Advanced)
    • Reward amounts displayed
    • Quest completion status (checkmark if completed)
    • Replay availability (24-hour cooldown)
    • Balance display (cUSD token balance)

3. Game Page (/play/[levelId])

  • Purpose: Play the memory matching game
  • Features:
    • 4x4 grid (8 cards, 4 pairs)
    • Flip cards to reveal concepts/definitions
    • Match pairs to learn facts
    • Move counter and timer
    • Knowledge modal on each match
    • Victory screen on completion

4. Victory Screen

  • Purpose: Display results and claim reward
  • Features:
    • Game statistics (moves, time, pairs matched)
    • Reward amount display
    • Backend verification status
    • Claim reward button
    • Transaction hash and block explorer link
    • Balance refresh after claim

5. Profile Page (/profile)

  • Purpose: View user statistics and achievements
  • Features:
    • Total earned (cUSD)
    • Quests completed count
    • Current streak and best streak
    • Total moves across all quests
    • Average completion time
    • Achievement badges
    • Real-time data from MongoDB

6. Admin Dashboard (/admin-ilmquest-secret-2024)

  • Purpose: Manage quests dynamically (secret route)
  • Features:
    • Wallet signature authentication
    • View all quests (including inactive)
    • Create new quests
    • Edit existing quests
    • Delete/disable quests
    • Toggle active/inactive status
    • Toggle locked/unlocked status
    • Quest validation and error handling

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ and pnpm
  • MongoDB Atlas account (or local MongoDB)
  • MetaMask or MiniPay wallet
  • Celo Sepolia testnet access

Installation

  1. Clone the repository

    git clone https://github.com/Intelligence247/IlmQuest.git
    cd IlmQuest
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    Backend (apps/backend/.env):

    MONGODB_URI=your_mongodb_connection_string
    ADMIN_PRIVATE_KEY=0x...
    VAULT_ADDRESS=0x9857b9d8F49C035Df7e56397870A0a16d851e371
    CHAIN_ID=42220
    VAULT_ADDRESS=0xYourDeployedVaultAddress
    REWARD_TOKEN_ADDRESS=0x765DE816845861e75A25fCA122bb6898B8B1282a
    ADMIN_WALLETS=0xYourAdminWalletAddress
    PORT=4000

    Frontend (apps/frontend/.env.local):

    NEXT_PUBLIC_BACKEND_URL=http://localhost:4000
  4. Run migration script (import existing quests)

    cd apps/backend
    node scripts/migrateQuests.js
  5. Start development servers

    # Terminal 1: Backend
    cd apps/backend
    pnpm dev
    
    # Terminal 2: Frontend
    cd apps/frontend
    pnpm dev
  6. Open the app


๐Ÿ—๏ธ Project Structure

IlmQuest/
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ frontend/          # Next.js 14 frontend application
โ”‚   โ”‚   โ”œโ”€โ”€ app/           # App Router pages
โ”‚   โ”‚   โ”œโ”€โ”€ components/    # React components
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/         # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ lib/           # Utilities and config
โ”‚   โ”œโ”€โ”€ backend/           # Node.js/Express backend API
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ routes/    # API routes
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ middleware/# Auth middleware
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ services/  # Business logic
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ db/       # MongoDB connection
โ”‚   โ”‚   โ””โ”€โ”€ scripts/      # Migration scripts
โ”‚   โ””โ”€โ”€ contracts/         # Solidity smart contracts (Hardhat)
โ”‚       โ”œโ”€โ”€ contracts/    # Solidity files
โ”‚       โ”œโ”€โ”€ test/         # Contract tests
โ”‚       โ””โ”€โ”€ ignition/     # Deployment scripts
โ”œโ”€โ”€ ArchectureAndUserFlow.md
โ”œโ”€โ”€ DesignSystem.md
โ”œโ”€โ”€ projectIdea.md
โ”œโ”€โ”€ projectPRD.md
โ””โ”€โ”€ README.md

๐Ÿ› ๏ธ Tech Stack

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: shadcn/ui
  • Wallet: ethers.js (MiniPay/MetaMask)
  • State Management: React Context API

Backend

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB (Atlas)
  • Signing: ethers.js (ECDSA signatures)
  • Security: Helmet, CORS

Smart Contracts

  • Language: Solidity
  • Framework: Hardhat
  • Network: Celo Mainnet
  • Standards: ERC20, EIP-712
  • Libraries: OpenZeppelin

๐Ÿ“‹ Available Scripts

Root Level

pnpm dev          # Start all development servers
pnpm build        # Build all packages
pnpm lint         # Lint all code

Contracts

cd apps/contracts
pnpm compile      # Compile smart contracts
pnpm test         # Run contract tests
pnpm deploy:mainnet  # Deploy to Celo Mainnet
pnpm fund:vault:mainnet  # Fund vault with cUSD

Backend

cd apps/backend
pnpm dev          # Start backend server
node scripts/migrateQuests.js  # Import quests to database

Frontend

cd apps/frontend
pnpm dev          # Start Next.js dev server
pnpm build        # Build for production

๐ŸŽฎ How It Works

Complete User Journey

  1. User visits app โ†’ Landing page with wallet connection
  2. Connects wallet โ†’ MiniPay or MetaMask (desktop/mobile)
  3. Selects quest โ†’ Chooses from available quests (Celo Basics, Stablecoins 101, etc.)
  4. Plays game โ†’ Memory matching: flips cards to match concepts with definitions
  5. Learns facts โ†’ Knowledge modal appears on each successful match
  6. Completes quest โ†’ All 4 pairs matched successfully
  7. Backend verifies โ†’ Oracle checks game duration, moves, and rate limits
  8. Receives signature โ†’ Backend cryptographically signs reward authorization
  9. Claims reward โ†’ Smart contract validates signature and pays cUSD
  10. Pays gas in cUSD โ†’ Fee Currency Abstraction - no CELO needed!
  11. Views profile โ†’ Stats, achievements, and total earnings updated

Technical Flow

User Action โ†’ Frontend โ†’ Backend API โ†’ MongoDB โ†’ Smart Contract โ†’ Blockchain
  • Frontend: Handles UI, wallet connection, game logic
  • Backend: Verifies games, signs rewards, manages quests
  • Smart Contract: Validates signatures, distributes rewards
  • Blockchain: Records transactions, maintains state

๐Ÿ” Smart Contracts

Deployed Contracts (Celo Mainnet)

  • JualahVault: 0x980DC8695F6D30A3b20770Ad42A5458784CBeA90

    • Handles reward distribution
    • Verifies EIP-712 signatures
    • Implements replay protection (nonce tracking)
    • ERC20 token transfers
  • cUSD (Reward Token): 0x765DE816845861e75A25fCA122bb6898B8B1282a

    • Real cUSD token on Celo Mainnet
    • Used for rewards and Fee Currency Abstraction

Block Explorer: https://celoscan.io

View Contracts:


๐ŸŽฏ Key Innovations

1. Fee Currency Abstraction

Users pay gas fees in cUSD (the same token they earn), eliminating the need for CELO tokens. This removes a major onboarding barrier for new users in emerging markets.

Implementation: Smart contract calls include feeCurrency: REWARD_TOKEN_ADDRESS parameter.

2. Jualah Model

Ethical reward system based on Islamic Finance principles. Users are paid for a service (learning), not gambling. This makes crypto accessible to users who avoid gambling-based platforms.

3. Trusted Oracle Pattern

Backend verifies game completion off-chain (checking duration, moves, rate limits), then cryptographically signs reward authorizations. Smart contract validates signatures before payout, preventing bots and abuse.

4. Mobile-First Design

Optimized for low-bandwidth connections and small screens, perfect for MiniPay users in emerging markets. Works seamlessly on Opera MiniPay and MetaMask Mobile.

5. Dynamic Quest Management

Admin dashboard allows adding/editing quests without code changes. Quests stored in MongoDB, enabling rapid content updates.


๐Ÿ“š Documentation


๐Ÿงช Testing

Smart Contracts

cd apps/contracts
pnpm test

Tests cover:

  • Valid reward claims
  • Replay protection
  • Invalid signatures
  • Edge cases

Backend API

cd apps/backend
node test-api.js

Frontend

Manual testing recommended:

  1. Connect wallet
  2. Play a quest
  3. Verify reward claim
  4. Check profile stats
  5. Test replay cooldown

๐Ÿš€ Deployment

Frontend (Vercel)

cd apps/frontend
vercel deploy

Live URL: https://ilmquest-app.vercel.app

Backend (Railway/Render)

  1. Connect GitHub repository
  2. Set environment variables
  3. Deploy

Smart Contracts

Deployed to Celo Mainnet. See contract addresses above.

Deployment Instructions: See MAINNET_DEPLOYMENT_STEPS.md


๐Ÿ”’ Security Features

  • Wallet Signature Authentication - Admin routes require cryptographic signatures
  • Rate Limiting - Prevents quest spam (24-hour cooldown)
  • Replay Protection - Nonce tracking prevents double-claiming
  • Input Validation - Server-side validation for all quest data
  • CORS Protection - Configured for specific origins
  • Helmet Security - Security headers enabled

๐Ÿ‘ฅ Contributing

This is a hackathon project. For questions or issues, please open a GitHub issue.


๐Ÿ“„ License

MIT License - see LICENSE file for details


๐Ÿ™ Acknowledgments

  • Celo Foundation for the amazing blockchain infrastructure
  • MiniPay team for wallet integration
  • OpenZeppelin for secure smart contract libraries
  • Next.js and Vercel for the excellent framework

๐Ÿ“ž Contact


Built with โค๏ธ for the Celo ecosystem

About

Turning Knowledge into Capital - Earn cUSD by learning crypto concepts through gamified education

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published