Overview
The ZKScore Achievement Registry is a sophisticated smart contract that manages on-chain achievements across the ZKScore ecosystem. It handles achievement creation, claiming, progress tracking, and verification, enabling gamified reputation building and milestone recognition.Contract Architecture
Core Components
The Achievement Registry consists of several key components:- Achievement Management: Creation and configuration of achievements
- Progress Tracking: Real-time progress monitoring for each user
- Claiming System: Secure achievement claiming with verification
- Reward Distribution: Automated reward distribution upon claiming
- Badge System: NFT badge minting for earned achievements
Achievement Categories
1. DeFi Achievements
Decentralized finance milestones:- Liquidity Provider (LP tokens > $10k)
- Lending Master (lending volume > $100k)
- Yield Farmer (3+ protocols)
- DeFi Pioneer (early adopter)
- Protocol Veteran (1 year+ active)
2. NFT Achievements
NFT ecosystem achievements:- NFT Collector (10+ unique NFTs)
- Blue Chip Holder (rare NFT owner)
- Active Trader (50+ trades)
- Creator Support (support 5+ creators)
- Community Builder (active participation)
3. Social Achievements
Social platform milestones:- Profile Complete (100% completion)
- Content Creator (10+ posts)
- Community Leader (100+ followers)
- Engagement Champion (high interaction)
- Network Builder (connections)
4. Trading Achievements
Trading performance milestones:- Day Trader (20+ trades/month)
- Profitable Trader (positive ROI)
- Diamond Hands (long-term holder)
- Risk Manager (diversified portfolio)
- Market Maker (liquidity provision)
5. Governance Achievements
Governance participation:- Active Voter (voted in 10+ proposals)
- Proposal Creator (created proposal)
- Delegate (received delegation)
- Governance Expert (high participation)
- Community Advocate (forum activity)
6. Gaming Achievements
Gaming milestones:- Game Explorer (played 5+ games)
- High Scorer (top leaderboard)
- Tournament Winner (won tournament)
- Asset Collector (rare in-game items)
- Gaming Veteran (active player)
7. Identity Achievements
Identity verification milestones:- Verified Identity (KYC completed)
- Multi-Chain User (3+ chains)
- ENS Holder (owns ENS)
- Early Adopter (early user)
- Community Member (active 6+ months)
8. Trust Achievements
Trust layer milestones:- Trusted Member (5+ attestations)
- Attestation Giver (issued attestations)
- Reputation Builder (high trust score)
- Verified Credential (verified credentials)
- Trust Network (trust connections)
Contract Addresses
Mainnet Deployments
Testnet Deployments
Achievement Structure
Achievement Data Model
Rarity Levels
Requirement Types
Contract Interface
Core Functions
Events
Progress Tracking
Progress Structure
Automatic Progress Updates
Progress is automatically updated when:- User performs qualifying on-chain action
- Score thresholds are met
- Time-based milestones are reached
- Activity counters increment
- Category scores update
Manual Progress Verification
For certain achievements, manual verification is required:Claiming System
Claim Process
- Check Eligibility: Verify user meets requirements
- Generate Proof: Create verification proof (if needed)
- Submit Claim: Call
claimAchievement()with proof - Verification: Contract verifies requirements
- Mint Badge: NFT badge minted to user
- Distribute Rewards: Points and score boost applied
- Emit Events: Claim event emitted
Claim Verification
Reward System
Points Distribution
Score Boost
NFT Badges
Each claimed achievement mints a unique NFT badge:Gas Optimization
Efficient Storage
Batch Operations
Gas Estimates
| Operation | Gas Cost | Description |
|---|---|---|
| Create Achievement | ~200,000 | Create new achievement |
| Claim Achievement | ~180,000 | Claim with badge minting |
| Update Progress | ~30,000 | Update user progress |
| Get Achievement | ~3,000 | View achievement data |
| Get User Achievements | ~5,000 | View user’s achievements |
| Batch Claim (3) | ~450,000 | Claim 3 achievements |
Access Control
Roles
Permission Matrix
| Operation | CREATOR_ROLE | VERIFIER_ROLE | ADMIN_ROLE | User |
|---|---|---|---|---|
| Create Achievement | ✅ | ❌ | ✅ | ❌ |
| Update Achievement | ✅ | ❌ | ✅ | ❌ |
| Verify Progress | ❌ | ✅ | ✅ | ❌ |
| Claim Achievement | ❌ | ❌ | ❌ | ✅ |
| View Achievements | ✅ | ✅ | ✅ | ✅ |
| Grant Roles | ❌ | ❌ | ✅ | ❌ |
Integration Examples
Basic Achievement Query
Claim Achievement
Security Considerations
Claim Verification
All claims are verified before processing:Double-Claim Prevention
Best Practices
For Developers
- Verify Progress: Always check progress before claiming
- Handle Errors: Implement comprehensive error handling
- Monitor Events: Listen for achievement events
- Cache Data: Cache achievement metadata locally
- Batch Queries: Use batch functions for multiple queries
For Users
- Track Progress: Monitor achievement progress regularly
- Claim Promptly: Claim achievements when eligible
- Verify Requirements: Understand requirements before attempting
- Check Gas: Ensure sufficient gas for claiming
- Secure Wallet: Keep wallet secure as badges are valuable
Related Documentation
- Functions Reference - Complete function documentation
- Events Reference - Event documentation
- Integration Guide - Integration examples
- Custom Achievements - Creating custom achievements
- Score Calculator - Score calculation contract