A Decentralized Gaming Platform on Base Blockchain
Play โข Earn โข Own โข Secure
๐ Live Demo โข ๐ Docs โข ๐ Wiki โข ๐ฏ Quick Start โข ๐ก๏ธ Security Dashboard
Joybit is a cutting-edge decentralized gaming platform built on the Base blockchain, featuring three distinct games unified by the JOYB token economy. Players can enjoy Match-3 puzzles, strategic card games, and daily reward systems while earning and trading JOYB tokens.
- ๐ฎ Three Unique Games: Match-3 puzzles, 3-card strategy, and daily rewards
- ๐ Unified Token Economy: All games reward in JOYB tokens
- ๐ Achievement System: Unlock NFTs and track progress
- ๐จ Advanced Theme System: 18+ professional themes with full customization
- ๐ Audio Controls: Separate volume controls for music and sound effects
- ๐ Decentralized Rewards: Players claim their own earnings
- ๐ก๏ธ Advanced Security: Real-time threat detection and monitoring
- ๐ฑ Modern UI/UX: Responsive design with smooth animations
- โก Fast Transactions: Optimized for Base network
- ๐ Admin Dashboard: Comprehensive management and analytics
Complete documentation for Joybit development and deployment:
- Getting Started - Quick setup and first steps
- Home - Overview and architecture
- Games - Game-specific documentation
- Security Dashboard - Security monitoring and management
- Deployment Guide - Production deployment instructions
- API Reference - Complete API documentation
- Database Schema - Database structure and migrations
- Contributing Guide - How to contribute to the project
- Wiki Auto-Publish Setup - Set up automatic wiki publishing
- Mainnet Deployment - Mainnet deployment guide
- Testnet Deployment - Testnet deployment guide
- Farcaster Integration - Social features integration
- Notifications Setup - Push notification configuration
- Node.js 18.0 or higher
- MetaMask or compatible Web3 wallet
- Base Sepolia testnet ETH (Get from faucet)
# Clone the repository
git clone https://github.com/Adrijan-Petek/joybit.git
cd joybit
# Install dependencies
npm install
# Set up environment
cp .env.example .env.local
# Edit .env.local with your configuration
# Start development server
npm run devVisit http://localhost:3000 to start playing!
Strategic tile-matching gameplay with progressive difficulty
- ๐ฏ Objective: Match 3+ tiles to reach score targets
- ๐ฐ Entry Fee: 0.001 ETH per play (plus 1 free play every 24h)
- ๐ Rewards: JOYB tokens based on performance
- โก Features: 8x8 grid, time challenges, combo multipliers
Scoring System:
- 3 tiles: 30 points
- 4 tiles: 80 points (2.67ร multiplier)
- 5 tiles: 150 points (5ร multiplier)
- 6+ tiles: 200+ points (6.67ร+ multiplier)
Luck-based strategy with blockchain randomness
- ๐ฏ Objective: Choose 1 of 3 face-down cards
- ๐ฐ Entry Fee: 0.002 ETH (plus 1 free play every 24h; configurable)
- ๐ Win Rate: ~33.3% with block-based randomness
- ๐ Win Reward: 100 JOYB (default; configurable)
- โก Features: Instant results, fair distribution
Build streaks for maximum rewards
- ๐ฏ Objective: Claim daily rewards to build streaks
- ๐ฐ Base Reward: 100 JOYB (default; configurable)
- ๐ Streak Bonus: +10 JOYB per consecutive day (default; configurable)
- โก Features: Automatic tracking, NFT achievements
Side-scrolling hill-climb racer
- ๐ฏ Objective: Drive as far as possible while collecting coins and managing fuel
- ๐ฐ Rewards: In-game coins and progression (profile-based)
- โก Features: Physics-driven terrain, vehicle upgrades, and mini-app ready
| Contract | Purpose | Key Features |
|---|---|---|
| JoybitToken | ERC20 Token | JOYB token with 18 decimals |
| JoybitGame | Match-3 Logic | Score validation, reward distribution |
| CardGame | Card Game | Block randomness, JOYB rewards |
| DailyClaim | Daily Rewards | Streak tracking, NFT achievements |
| BaseboundGame | Basebound Racer | Gameplay state and on-chain hooks |
| AchievementERC1155 | Achievements | ERC1155 badges and rewards |
| Treasury | Fund Management | ETH fee collection, authorized withdrawals |
| GameSettings | Configuration | Dynamic pricing, game parameters |
| AccessControl | Permissions | Role-based access, admin management |
| Contract | Address |
|---|---|
| JoybitToken | 0xc732932ca7db558cf1bacc17b4f4f7e149e0eb07 |
| Treasury | 0x91F67245cE0ad7AFB5301EE5d8eaE29Db69078Af |
| Match3Game (JoybitGame) | 0x72cC365b09D7cB4bE3416279407655cA9BBdc532 |
| CardGame | 0xa59Fd0ffE17D446157430E13db2d133DD2DfF3da |
| DailyClaim | 0x6A27938E353Be8f25ECD7dEd90A47221e93F2941 |
| AchievementERC1155 | 0x3DDfe21080b8852496414535DA65AC2C3005f5DE |
| BaseboundGame | 0x56A173A52997974BAc324Ab6918437A5286585E1 |
Frontend:
- Next.js 16.1+ with App Router
- TypeScript for type safety
- TailwindCSS for styling
- Framer Motion for animations
- Wagmi v2 + RainbowKit for Web3
- Advanced theme system with CSS variables
- Audio context with separate volume controls
Security & Middleware:
- Next.js Proxy (Edge Runtime)
- Real-time threat detection
- Rate limiting and IP blocking
- Security event logging
- Admin dashboard with live monitoring
Blockchain:
- Solidity 0.8.22+
- OpenZeppelin contracts
- Hardhat development framework
- Base Sepolia testnet
Database:
- Turso (SQLite) for user data
- Security events and threat logs
- Achievement tracking
- Game statistics and analytics
- Total Supply: 1,000,000,000 JOYB
- Decimals: 18
- Standard: ERC20
- Utility: Gaming rewards, NFT purchases
Gameplay โ ETH Fee โ Treasury
โ
Win/Loss โ JOYB Reward โ Pending Balance
โ
Claim โ Transfer โ Player Wallet
- Play Fees: ETH collected in Treasury
- Win Rewards: JOYB distributed from game contracts
- Claim System: User-initiated reward collection
- Treasury: Admin-managed fund distribution
Unlock exclusive NFTs and track your gaming progress:
- Match-3 Achievements: First Win, Hot Streak, Gem Master, etc.
- Card Game Achievements: Card Novice, Card Winner, Card Expert, etc.
- Daily Claim Achievements: Daily Starter, Streak Master, Dedicated Player, etc.
- General Achievements: Well Rounded, High Scorer, Level Climber, etc.
- Common (Yellow): Basic achievements
- Rare (Blue): Moderate challenges
- Epic (Purple): Advanced goals
- Legendary (Teal): Expert level
- Mythic (Rose): Ultimate challenges
Comprehensive theming with 18+ professional themes and full customization
- Default: Classic Joybit purple theme
- Dark: Deep dark theme for night gaming
- Neon: Cyberpunk neon aesthetic
- Retro: 80s arcade style
- Ocean: Cool blue aquatic theme
- Forest: Natural green theme
- Professional: Corporate blue theme
- Corporate: Clean business theme
- Minimal: Simple black and white
- Elegant: Purple luxury theme
- Tech: Monospace developer theme
- Sunset: Warm orange theme
- Midnight: Deep blue night theme
- Aurora: Northern lights inspired
- Cyberpunk: Futuristic neon theme
- Nature: Earthy green theme
- Colors: Primary, secondary, accent, background, surface, text, borders
- Typography: Font family, size, headline size
- Layout: Border radius, spacing, shadows
- Animation: None, minimal, or full animations
- Persistence: Themes saved to localStorage
Admin panel includes:
- ๐จ Theme Management: Theme preset selection and full color customization
- ๐ต Audio Settings: Global audio controls and volume management
- ๐ Game Analytics: Real-time statistics and player metrics
- ๐ก๏ธ Security Dashboard: Threat monitoring, IP blocking, and security logs
- โ๏ธ System Configuration: Game parameters and contract settings
- ๐ฅ User Management: Player data and achievement tracking
- ๐ฐ Treasury Management: Fund distribution and withdrawal controls
Professional audio controls with separate volume management
- Music Volume: Background music control
- Sound Effects: Game sound effects volume
- Mute Controls: Individual mute toggles
- Persistent Settings: Volume preferences saved
- Theme Integration: Audio controls match current theme
- Global audio state management
- Separate volume controls for different audio types
- Smooth volume transitions
- Accessibility-friendly controls
Create .env.local with the following variables:
# Network Configuration
NEXT_PUBLIC_CHAIN_ID=84532
NEXT_PUBLIC_BASE_TESTNET_RPC_URL=https://sepolia.base.org
# WalletConnect
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id
# Admin Configuration
NEXT_PUBLIC_ADMIN_WALLET_ADDRESS=0xYourAdminAddress
# Database (Turso)
TURSO_DATABASE_URL=your_database_url
TURSO_AUTH_TOKEN=your_auth_token
# Security Configuration
SECURITY_MAX_REQUESTS_PER_MINUTE=60
SECURITY_MAX_REQUESTS_PER_HOUR=1000
SECURITY_BLOCK_DURATION_MINUTES=15
SECURITY_SQL_INJECTION_DETECTION=true
SECURITY_XSS_DETECTION=true
SECURITY_INPUT_VALIDATION=true
# Contract Addresses (after deployment)
NEXT_PUBLIC_JOYBIT_TOKEN_ADDRESS=0x...
NEXT_PUBLIC_JOYBIT_GAME_ADDRESS=0x...
NEXT_PUBLIC_CARD_GAME_ADDRESS=0x...
NEXT_PUBLIC_DAILY_CLAIM_ADDRESS=0x...
NEXT_PUBLIC_TREASURY_ADDRESS=0x...# Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
# Testing
npm run test # Run all tests
npm run test:watch # Run tests in watch mode
# Contracts
npm run compile # Compile Solidity contracts
npm run deploy:test # Deploy to testnet
npm run deploy:main # Deploy to mainnet
# Database
npm run db:setup # Initialize database tables
npm run db:migrate # Run database migrations
# Security
npm run security:check # Run security audit
npm run security:logs # View security logs# Run comprehensive test suite
npx hardhat test
# Expected: 293 passing tests
# Includes unit tests, integration tests, and gas optimization checks# Deploy all contracts
npx hardhat run scripts/deploy-testnet.js --network baseSepolia
# Verify contracts on BaseScan
npx hardhat verify --network baseSepolia <CONTRACT_ADDRESS># Deploy to Base mainnet
npx hardhat run scripts/deploy-testnet.js --network base
# Update frontend environment variables
# Redeploy on Vercel/NetlifyVercel (Recommended):
- Connect GitHub repository
- Add environment variables
- Deploy automatically
Manual:
npm run build
npm run startEnterprise-grade security with real-time threat detection and comprehensive monitoring
- ๐ก๏ธ Real-time Threat Detection: SQL injection, XSS, and suspicious pattern monitoring
- ๐ซ IP Blocking: Automatic and manual IP address blocking
- โฑ๏ธ Rate Limiting: Configurable request limits per IP and globally
- ๐ Security Dashboard: Live monitoring with threat analytics
- ๐ Audit Logging: Comprehensive security event logging
- ๐จ Emergency Response: Lockdown capabilities for critical situations
- ๐ Threat Analytics: Historical data and trend analysis
- โ๏ธ Configurable Settings: Adjustable security parameters
Multi-tab security management interface:
- Real-time security metrics
- Active threat count
- Recent security events
- System status overview
- Live threat monitoring
- Threat classification (SQL injection, XSS, suspicious)
- Threat details and timestamps
- Resolution status tracking
- IP blocking management
- Block/unblock IP addresses
- Blocked IP list with reasons
- Automatic threat-based blocking
- Comprehensive audit logs
- Security event history
- User actions tracking
- Export capabilities
- Security parameter configuration
- Rate limiting settings
- Threat detection sensitivity
- Emergency lockdown controls
Edge Proxy Security (Next.js 16):
- Request-level threat detection
- Rate limiting with sliding windows
- IP-based access control
- Real-time security logging
Database Security:
- Turso SQLite with secure connections
- Security event persistence
- Threat pattern storage
- Audit trail maintenance
API Security:
- Input validation and sanitization
- SQL injection prevention
- XSS protection
- Suspicious pattern detection
Announcements API Optimization:
- Edge Caching: 15-day fresh cache with 15-day stale-while-revalidate
- Cache Busting: Version-based cache invalidation for instant updates
- Reduced Polling: Frontend polls every 6 hours instead of every 3 seconds
- Monthly Updates: Optimized for monthly announcement changes
- Cache Headers:
Cache-Control: public, s-maxage=1296000, stale-while-revalidate=1296000
Version-Based Cache Busting:
- API returns
versionfield with latest update timestamp - Meta requests (
?meta=1) bypass cache to get current version - Data requests use
?v=${version}for cache busting with Edge caching - New announcements appear instantly for all users
- Combines caching efficiency with real-time update capability
API Endpoints:
GET /api/announcements?meta=1โ{version}only, no cacheGET /api/announcements?v=${version}โ Full data, 15-day Edge cacheGET /api/announcementsโ Full data, 15-day Edge cache
Smart Polling:
- 5-minute intervals when tab is visible
- 30-minute intervals when tab is hidden
- Immediate check when tab becomes visible
- Balances responsiveness with resource efficiency
Benefits:
- 99.9% reduction in function invocations
- Instant announcement updates when published
- Improved response times for users
- Reduced server load and costs
- Maintains data freshness for monthly updates
- Real-time player counts and active sessions
- Game completion rates and success metrics
- Reward distribution and token flow tracking
- Achievement unlock rates and player progression
- Threat Detection: Real-time security event monitoring
- IP Analytics: Blocked IP tracking and access patterns
- Rate Limiting: Request volume analysis and abuse detection
- Audit Trails: Comprehensive security event logging
- Performance Metrics: System response times and error rates
- Balance tracking across all deployed contracts
- Transaction volume and gas usage analysis
- Treasury fund management and distribution tracking
- Player reward claims and token transfers
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Write comprehensive tests
- Update documentation
- Ensure security standards
This project is licensed under the MIT License - see the LICENSE file for details.
- Base for the excellent blockchain infrastructure
- OpenZeppelin for secure smart contract libraries
- RainbowKit for seamless wallet integration
- Framer Motion for smooth animations
- ๐จ Consistent Color Scheme: All windows, modals, and UI elements now use unified theme colors
- ๐ฆ Staking Window: Added "Coming Soon" staking feature window to main page
- ๐ฏ Logo Redesign: JOYBIT logo now features "JOY" in gold and "BIT" in custom blue (#1652F0)
- ๐ Button Standardization: All buttons updated to use consistent blue color (#1652F0)
- ๐ณ Wallet Button: Wallet connect button color fixed to match theme
- ๐ฑ Responsive Grid: Main page features grid updated for better mobile layout
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ง Contact: adrijan@joybit.game
Built with โค๏ธ on Base โข Powered by JOYB โข Made for Gamers
