Skip to content

Joybit is a cutting-edge decentralized gaming platform built on the Base blockchain, featuring three distinct games unified by the JOYB token economy.

License

Notifications You must be signed in to change notification settings

Adrijan-Petek/joybit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

190 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Joybit

Joybit Promo

A Decentralized Gaming Platform on Base Blockchain

Next.js TypeScript Solidity Base TailwindCSS Turso

Play โ€ข Earn โ€ข Own โ€ข Secure

๐ŸŒ Live Demo โ€ข ๐Ÿ“– Docs โ€ข ๐Ÿ“š Wiki โ€ข ๐ŸŽฏ Quick Start โ€ข ๐Ÿ›ก๏ธ Security Dashboard


โœจ Overview

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.

๐ŸŽฏ Key Features

  • ๐ŸŽฎ 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

๐Ÿ“š Documentation

Complete documentation for Joybit development and deployment:

๐ŸŽฎ Game Documentation

๐Ÿ›ก๏ธ Security & Administration

๐Ÿ”ง Technical Reference

๐Ÿ“‹ Additional Resources


๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18.0 or higher
  • MetaMask or compatible Web3 wallet
  • Base Sepolia testnet ETH (Get from faucet)

Installation

# 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 dev

Visit http://localhost:3000 to start playing!


๐ŸŽฎ Games

๐Ÿงฉ Match-3 Puzzle (JoybitGame)

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)

๐Ÿƒ 3-Card Game (CardGame)

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

๐Ÿ“… Daily Claim (DailyClaim)

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

๐ŸŽ๏ธ Basebound (Basebound)

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

๐Ÿ—๏ธ Architecture

Smart Contracts

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

Deployed Contracts (Base Mainnet)

Contract Address
JoybitToken 0xc732932ca7db558cf1bacc17b4f4f7e149e0eb07
Treasury 0x91F67245cE0ad7AFB5301EE5d8eaE29Db69078Af
Match3Game (JoybitGame) 0x72cC365b09D7cB4bE3416279407655cA9BBdc532
CardGame 0xa59Fd0ffE17D446157430E13db2d133DD2DfF3da
DailyClaim 0x6A27938E353Be8f25ECD7dEd90A47221e93F2941
AchievementERC1155 0x3DDfe21080b8852496414535DA65AC2C3005f5DE
BaseboundGame 0x56A173A52997974BAc324Ab6918437A5286585E1

Tech Stack

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

๐Ÿ’ฐ Token Economy

JOYB Token

  • Total Supply: 1,000,000,000 JOYB
  • Decimals: 18
  • Standard: ERC20
  • Utility: Gaming rewards, NFT purchases

Reward Distribution

Gameplay โ†’ ETH Fee โ†’ Treasury
    โ†“
Win/Loss โ†’ JOYB Reward โ†’ Pending Balance
    โ†“
Claim โ†’ Transfer โ†’ Player Wallet

Economic Model

  • Play Fees: ETH collected in Treasury
  • Win Rewards: JOYB distributed from game contracts
  • Claim System: User-initiated reward collection
  • Treasury: Admin-managed fund distribution

๐Ÿ† Achievement System

Unlock exclusive NFTs and track your gaming progress:

๐ŸŽ–๏ธ Achievement Categories

  • 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.

๐Ÿ… Rarity Tiers

  • Common (Yellow): Basic achievements
  • Rare (Blue): Moderate challenges
  • Epic (Purple): Advanced goals
  • Legendary (Teal): Expert level
  • Mythic (Rose): Ultimate challenges

๐ŸŽจ Theme System

Comprehensive theming with 18+ professional themes and full customization

๐ŸŽฏ Available Themes

  • 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

โš™๏ธ Customization Options

  • 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 Controls

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

๐Ÿ”Š Audio System

Professional audio controls with separate volume management

๐ŸŽต Features

  • 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

๐ŸŽฎ Audio Context

  • Global audio state management
  • Separate volume controls for different audio types
  • Smooth volume transitions
  • Accessibility-friendly controls

๐Ÿ”ง Development

Environment Setup

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...

Available Scripts

# 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

Testing

# Run comprehensive test suite
npx hardhat test

# Expected: 293 passing tests
# Includes unit tests, integration tests, and gas optimization checks

๐ŸŒ Deployment

Testnet Deployment (Base Sepolia)

# Deploy all contracts
npx hardhat run scripts/deploy-testnet.js --network baseSepolia

# Verify contracts on BaseScan
npx hardhat verify --network baseSepolia <CONTRACT_ADDRESS>

Production Deployment

# Deploy to Base mainnet
npx hardhat run scripts/deploy-testnet.js --network base

# Update frontend environment variables
# Redeploy on Vercel/Netlify

Frontend Deployment

Vercel (Recommended):

  1. Connect GitHub repository
  2. Add environment variables
  3. Deploy automatically

Manual:

npm run build
npm run start

๐Ÿ›ก๏ธ Security System

Enterprise-grade security with real-time threat detection and comprehensive monitoring

๐Ÿ” Security Features

  • ๐Ÿ›ก๏ธ 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

๐Ÿ–ฅ๏ธ Admin Security Dashboard

Multi-tab security management interface:

๐Ÿ“Š Dashboard Tab

  • Real-time security metrics
  • Active threat count
  • Recent security events
  • System status overview

๐Ÿšจ Threats Tab

  • Live threat monitoring
  • Threat classification (SQL injection, XSS, suspicious)
  • Threat details and timestamps
  • Resolution status tracking

๐Ÿ›ก๏ธ Firewall Tab

  • IP blocking management
  • Block/unblock IP addresses
  • Blocked IP list with reasons
  • Automatic threat-based blocking

๐Ÿ“‹ Logs Tab

  • Comprehensive audit logs
  • Security event history
  • User actions tracking
  • Export capabilities

โš™๏ธ Settings Tab

  • Security parameter configuration
  • Rate limiting settings
  • Threat detection sensitivity
  • Emergency lockdown controls

๐Ÿ”ง Technical Security Implementation

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

โšก API Performance & Caching

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 version field 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 cache
  • GET /api/announcements?v=${version} โ†’ Full data, 15-day Edge cache
  • GET /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

๐Ÿ“Š Analytics & Monitoring

๐Ÿ“Š Analytics & Monitoring

Game Statistics

  • 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

Security Monitoring

  • 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

Contract Monitoring

  • Balance tracking across all deployed contracts
  • Transaction volume and gas usage analysis
  • Treasury fund management and distribution tracking
  • Player reward claims and token transfers

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Write comprehensive tests
  • Update documentation
  • Ensure security standards

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Base for the excellent blockchain infrastructure
  • OpenZeppelin for secure smart contract libraries
  • RainbowKit for seamless wallet integration
  • Framer Motion for smooth animations

๏ฟฝ Recent Updates

v1.2.0 - UI/UX Improvements (January 2026)

  • ๐ŸŽจ 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

๏ฟฝ๐Ÿ“ž Support


Built with โค๏ธ on Base โ€ข Powered by JOYB โ€ข Made for Gamers

๐ŸŽฎ Start Playing โ€ข ๐Ÿ“š Documentation โ€ข ๐Ÿ’ฌ Discord

About

Joybit is a cutting-edge decentralized gaming platform built on the Base blockchain, featuring three distinct games unified by the JOYB token economy.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published