A gamified DeFi learning platform built on Shardeum Unstable testnet where users complete educational quests and earn achievement NFTs.
- 🎮 Interactive quest-based learning system
- 🏆 Achievement NFTs for completing milestones
- 📊 Progress tracking and leaderboard
- 💰 XP rewards for quest completion
- 🔐 Wallet-based authentication
- 📱 Responsive design
- Smart Contract: Solidity, Hardhat
- Frontend: React, Ethers.js
- Backend: Node.js, Express, MongoDB
- Blockchain: Shardeum Unstable Testnet
- Node.js (v16+)
- MongoDB
- MetaMask wallet
- Shardeum testnet SHM tokens
git clone <your-repo-url>
cd shardeum-quest# Root dependencies
npm install
# Backend dependencies
cd backend
npm install
# Frontend dependencies
cd ../frontend
npm installCreate a .env file in the root directory:
PRIVATE_KEY=your_private_key_here
CONTRACT_ADDRESS=
REACT_APP_CONTRACT_ADDRESS=
BACKEND_URL=http://localhost:3001
MONGODB_URI=mongodb://localhost:27017/shardeumquest
JWT_SECRET=your-secret-key-change-in-production# From root directory
npx hardhat compile
npx hardhat run scripts/deploy.js --network shardeumUnstableUpdate .env with the deployed contract address.
cd backend
npm startcd frontend
npm start- Install PM2:
npm install -g pm2- Create ecosystem config:
cd backend
pm2 init simple- Update
ecosystem.config.js:
module.exports = {
apps: [{
name: 'shardeum-quest-backend',
script: './src/server.js',
env: {
NODE_ENV: 'production',
PORT: 3001
}
}]
}- Start with PM2:
pm2 start ecosystem.config.js
pm2 save
pm2 startup- Install Vercel CLI:
npm install -g vercel- Build the frontend:
cd frontend
npm run build- Deploy to Vercel:
vercel --prod- Set environment variables in Vercel dashboard:
REACT_APP_CONTRACT_ADDRESSREACT_APP_BACKEND_URL
- Connect your MetaMask wallet to Shardeum Unstable testnet
- Visit the platform and connect your wallet
- Browse available quests
- Complete quest steps to earn XP
- Track your progress and compete on the leaderboard
registerUser(): Register a new usercompleteQuest(questId): Complete a quest and earn XPgetUserStats(address): Get user statisticsgetActiveQuests(): View all active quests
- Local Development:
http://localhost:3001 - Frontend Proxy:
http://localhost:3000(auto-proxied to backend)
Authenticate user with wallet signature.
Request Body:
{
"message": "Sign this message to authenticate with ShardeumQuest\\nTimestamp: 1693574400000",
"signature": "0x...",
"address": "0x..."
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIs...",
"user": {
"id": "64f1...",
"walletAddress": "0x...",
"totalXP": 0,
"completedQuests": 0,
"achievements": 0
}
}cURL Example:
curl -X POST http://localhost:3001/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"message": "Sign this message...",
"signature": "0x...",
"address": "0x..."
}'Verify JWT token validity.
Request Body:
{
"token": "eyJhbGciOiJIUzI1NiIs..."
}Response:
{
"valid": true,
"user": {
"id": "64f1...",
"walletAddress": "0x...",
"totalXP": 100
}
}Get all available quests.
Response:
[
{
"id": 1,
"title": "Welcome to DeFi on Shardeum",
"description": "Learn DeFi basics and understand Shardeum's role in decentralized finance",
"xpReward": 100,
"steps": [
{
"id": "defi-basics",
"title": "Read: What Is Decentralized Finance? The Basics of DeFi"
},
{
"id": "shardeum-intro",
"title": "Read: What is Shardeum?"
},
{
"id": "complete",
"title": "Complete the welcome quest"
}
]
}
]cURL Example:
curl -s http://localhost:3001/api/quests | jq '.'Browser URL: http://localhost:3001/api/quests
Get specific quest details.
Parameters:
id(path): Quest ID (1-5)
Response:
{
"id": 1,
"title": "Welcome to DeFi on Shardeum",
"description": "Learn DeFi basics and understand Shardeum's role in decentralized finance",
"xpReward": 100,
"steps": [...]
}cURL Example:
curl -s http://localhost:3001/api/quests/1 | jq '.'Browser URL: http://localhost:3001/api/quests/1
Get quest educational content with Shardeum blog links.
Parameters:
id(path): Quest ID (1-5)
Response:
{
"content": "\\n# Welcome to DeFi on Shardeum!\\n\\n## What is DeFi?\\nDecentralized Finance...\\n\\n**[What Is Decentralized Finance? The Basics of DeFi](https://shardeum.org/blog/basics-of-defi/)**\\n...",
"quiz": [
{
"question": "What does DeFi stand for?",
"options": ["Digital Finance", "Decentralized Finance", "Direct Finance", "Distributed Finance"],
"correct": 1
}
]
}cURL Example:
curl -s http://localhost:3001/api/quests/1/content | jq '.content'Browser URL: http://localhost:3001/api/quests/1/content
All progress endpoints require Authorization: Bearer <token> header.
Start a new quest.
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Parameters:
questId(path): Quest ID to start
Response:
{
"_id": "64f1...",
"userId": "64f1...",
"questId": 1,
"status": "started",
"steps": [],
"createdAt": "2023-09-01T...",
"updatedAt": "2023-09-01T..."
}cURL Example:
curl -X POST http://localhost:3001/api/progress/start/1 \
-H "Authorization: Bearer YOUR_TOKEN_HERE"Update quest step completion.
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Parameters:
questId(path): Quest ID to update
Request Body:
{
"stepId": "defi-basics",
"completed": true
}Response:
{
"_id": "64f1...",
"userId": "64f1...",
"questId": 1,
"status": "in_progress",
"steps": [
{
"stepId": "defi-basics",
"completed": true,
"completedAt": "2023-09-01T..."
}
]
}cURL Example:
curl -X PUT http://localhost:3001/api/progress/update/1 \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{"stepId": "defi-basics", "completed": true}'Complete a quest (with blockchain verification).
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Parameters:
questId(path): Quest ID to complete
Request Body:
{
"transactionHash": "0x...",
"blockchainVerified": true
}Response:
{
"progress": {
"_id": "64f1...",
"status": "completed",
"completedAt": "2023-09-01T...",
"transactionHash": "0x..."
},
"user": {
"totalXP": 100,
"newAchievements": [...]
}
}cURL Example:
curl -X POST http://localhost:3001/api/progress/complete/1 \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{"transactionHash": "0x...", "blockchainVerified": true}'Get user's progress across all quests.
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Response:
{
"completedQuests": [
{
"questId": 1,
"xpEarned": 100,
"completedAt": "2023-09-01T..."
}
],
"activeProgress": [
{
"_id": "64f1...",
"questId": 2,
"status": "in_progress",
"steps": [...]
}
],
"totalXP": 100,
"achievements": [
{
"achievementId": 1,
"earnedAt": "2023-09-01T..."
}
]
}cURL Example:
curl -s http://localhost:3001/api/progress/user \
-H "Authorization: Bearer YOUR_TOKEN_HERE"Verify quest completion on blockchain.
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Parameters:
questId(path): Quest ID to verify
Response:
{
"onChain": true,
"inDatabase": true,
"synced": true
}Get user profile information.
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Response:
{
"id": "64f1...",
"walletAddress": "0x...",
"username": "cooluser",
"totalXP": 100,
"completedQuests": [
{
"questId": 1,
"xpEarned": 100,
"completedAt": "2023-09-01T..."
}
],
"achievements": [
{
"achievementId": 1,
"earnedAt": "2023-09-01T..."
}
],
"registeredAt": "2023-09-01T...",
"lastActiveAt": "2023-09-01T..."
}cURL Example:
curl -s http://localhost:3001/api/users/profile \
-H "Authorization: Bearer YOUR_TOKEN_HERE"Update user profile (username).
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Request Body:
{
"username": "newusername"
}Response:
{
"id": "64f1...",
"walletAddress": "0x...",
"username": "newusername"
}cURL Example:
curl -X PUT http://localhost:3001/api/users/profile \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{"username": "newusername"}'Get platform leaderboard.
Query Parameters:
limit(optional): Number of users to return (default: 100)offset(optional): Offset for pagination (default: 0)
Response:
{
"users": [
{
"rank": 1,
"walletAddress": "0x...",
"username": "topuser",
"totalXP": 1000,
"completedQuests": 5,
"achievements": 4
}
],
"total": 50,
"limit": 100,
"offset": 0
}cURL Example:
curl -s http://localhost:3001/api/users/leaderboard | jq '.users'Browser URL: http://localhost:3001/api/users/leaderboard
Get platform statistics.
Response:
{
"totalUsers": 50,
"totalXPEarned": 5000,
"topUser": {
"walletAddress": "0x...",
"username": "topuser",
"totalXP": 1000
}
}cURL Example:
curl -s http://localhost:3001/api/users/stats | jq '.'Browser URL: http://localhost:3001/api/users/stats
Server health check.
Response:
{
"status": "OK",
"timestamp": "2023-09-01T12:00:00.000Z"
}cURL Example:
curl -s http://localhost:3001/api/healthBrowser URL: http://localhost:3001/api/health
-
Welcome to DeFi on Shardeum (100 XP)
- Learn DeFi basics with What Is Decentralized Finance?
- Understand Shardeum with What is Shardeum?
-
ERC-20 Token Expert (150 XP)
- Master token deployment with Deploy ERC-20 Smart Contracts using Truffle
- Learn token creation with Mint Your Cryptocurrency on Shardeum Testnet
-
DeFi Vault Builder (200 XP)
- Build vaults with Build and Deploy an ERC20 Vault on Shardeum
- Deploy contracts with Deploy a Bank Smart Contract Using Solidity
-
Multi-Token Standards Master (250 XP)
- Explore advanced standards with What is ERC-1155?
-
Web3 Career Strategist (300 XP)
- Plan your future with Career Opportunities in Web3
# Test all quests
curl -s http://localhost:3001/api/quests | jq length
# Test specific quest content
curl -s http://localhost:3001/api/quests/1/content | jq '.content'
# Test leaderboard
curl -s http://localhost:3001/api/users/leaderboard | jq '.users[0]'
# Test server health
curl -s http://localhost:3001/api/health
# Test platform stats
curl -s http://localhost:3001/api/users/statsOpen these URLs directly in your browser:
- http://localhost:3001/api/quests
- http://localhost:3001/api/quests/1/content
- http://localhost:3001/api/users/leaderboard
- http://localhost:3001/api/users/stats
- http://localhost:3001/api/health
- Open browser DevTools (F12)
- Go to Network tab
- Use the ShardeumQuest frontend
- See all API calls in real-time
- Connect Wallet: User connects MetaMask wallet
- Sign Message: Frontend generates message with timestamp
- Submit Signature: Send message, signature, and address to
/api/auth/login - Receive Token: Backend verifies signature and returns JWT token
- Store Token: Frontend stores token in localStorage
- Use Token: Include
Authorization: Bearer <token>header in subsequent requests
The API implements tiered rate limiting:
- General APIs: 1000 requests per 15 minutes
- Authentication: 50 requests per 15 minutes
- Profile Updates: 20 requests per 5 minutes
Contract Address: 0x1169Ea80acD04e4379a72e54Dd4B1810e31efC14
Network: Shardeum Unstablenet (Chain ID: 8080)
Feel free to submit issues and enhancement requests!
MIT