Components
1. Smart Contracts
CeloReferEnhanced.sol
The main referral system contract that handles:- User registration with referral codes
- Two-level referral tree (direct referrer + parent referrer)
- Dynamic reward distribution based on badge tiers
- Quest system for milestone achievements
- Seasonal competitions with prize pools
- Partner authorization and platform fee management
Key Functions
registerUser(string referralCode): Register a new user with an optional referral coderegisterGenesisUser(string customCode): Register a genesis user with a custom coderecordAction(address user, uint256 actionValue): Record a user action (partner-only)createQuest(...): Create a new quest (owner-only)createSeason(...): Create a new season (owner-only)authorizePartner(address partner, uint8 tier): Authorize a partner (owner-only)
ReputationNFT.sol
A soulbound (non-transferable) NFT contract that:- Mints unique reputation NFTs for users
- Represents on-chain reputation and achievement
- Cannot be transferred (soulbound token)
- Provides dynamic metadata based on user stats
Key Functions
mintNFT(address user): Mint a reputation NFT for a usergetNFTData(address user): Get NFT data for a usergenerateBadgeSVG(...): Generate SVG badge for display
2. CeloRefer SDK
A TypeScript SDK built with viem that provides:- Easy integration with CeloRefer contracts
- Type-safe contract interactions
- Comprehensive API for all contract features
- Support for read and write operations
- Built for modern web3 development
Installation
Initialization
Core Modules
User Management
registerUser(referralCode: string): Register a new userregisterGenesisUser(customCode: string): Register as genesis usergetUserInfo(userAddress: Address): Get user informationgetBadgeTier(userAddress: Address): Get userโs badge tier
Referral Operations
recordAction(userAddress: Address, actionValue: bigint): Record a user actiongetRewardRates(userAddress: Address): Get user reward rates
Badge & Reputation
getBadgeInfo(tier: number): Get badge informationbpsToPercentage(bps: bigint): Convert basis points to percentage
NFT Operations
mintReputationNFT(userAddress: Address): Mint reputation NFThasReputationNFT(userAddress: Address): Check if user has NFTgetReputationNFTData(userAddress: Address): Get NFT data
Quest System
getQuest(questId: number): Get quest detailsgetUserQuestProgress(userAddress: Address, questId: number): Get user progressclaimQuestReward(questId: number): Claim quest rewardlistActiveQuests(): List all active quests
Seasonal Competitions
getCurrentSeason(): Get current seasongetSeasonUserStats(seasonId: number, userAddress: Address): Get user season statslistSeasons(): List all seasons
Partner Integration
isAuthorizedPartner(partnerAddress: Address): Check if authorized partnergetPartnerSubscription(partnerAddress: Address): Get partner subscriptiongetPlatformFee(): Get platform fee
Leaderboard
getTopUsers(limit: number): Get top usersgetUserRank(userAddress: Address): Get user rank
Utilities
generateReferralLink(referralCode: string): Generate referral linkgenerateBadgeSVG(tier, referrals, earnings, rank): Generate badge SVG
Core Features
๐ฏ Multi-Level Referral System
Two-tier referral tree:- Level 1 (Direct Referrer): Earns rewards when their direct referrals perform actions
- Level 2 (Parent Referrer): Earns rewards from their referralsโ referrals
- ๐ฅ Bronze (0+ referrals): 5% + 2%
- ๐ฅ Silver (5+ referrals): 6% + 2.5%
- ๐ฅ Gold (15+ referrals): 7% + 3%
- ๐ Platinum (50+ referrals): 8% + 3.5%
๐ Badge & Reputation System
Users earn badges based on their referral performance:- Badges unlock higher reward rates
- Badge tier displayed in reputation NFTs
- Visual representation of user achievement
- Gamification encourages viral growth
๐ฎ Quest System
Create milestone-based challenges:- Set target referral counts
- Offer cUSD rewards for completion
- Track user progress automatically
- Claim rewards on completion
- Drive specific user behaviors
๐ Seasonal Competitions
Run time-bound competitions:- Define season duration and prize pool
- Track user performance during season
- Distribute rewards to top performers
- Create urgency and engagement spikes
- Build community around leaderboards
๐ Reputation NFTs (Soulbound)
Mint on-chain reputation badges:- Unique NFT per user (soulbound - cannot be transferred)
- Dynamic metadata reflecting current stats
- Visual representation of achievements
- Portable reputation across ecosystem
- Proof of engagement and influence
๐ค Partner Integration
White-label support for dApps:- Authorize partner contracts to record actions
- Platform fee system (default 15%)
- Tiered subscription model (Free, Basic, Pro, Enterprise)
- Customization levels based on tier
- Revenue sharing through fees
๐ Leaderboards & Analytics
Track ecosystem performance:- Global user rankings
- Referral counts and earnings
- Contract statistics
- Season-specific leaderboards
- User quest progress