This guide covers deploying Joybit to production environments. The platform consists of a Next.js frontend, smart contracts on Base blockchain, and a Turso database.
- Node.js: 18.0+ for frontend
- Solidity: 0.8.22+ for contracts
- Database: Turso account and database
- Hosting: Vercel/Netlify for frontend
- Vercel/Netlify: Frontend hosting
- Base Mainnet: Production blockchain
- Turso: Database hosting
- Wallet: Admin wallet with ETH
# Install Hardhat dependencies
npm install
# Create production environment file
cp .env.example .env.production# Production Network
MAINNET_RPC_URL=https://mainnet.base.org
MAINNET_PRIVATE_KEY=your_admin_private_key
# Contract Addresses (will be set after deployment)
JOYBIT_TOKEN_ADDRESS=
JOYBIT_GAME_ADDRESS=
CARD_GAME_ADDRESS=
DAILY_CLAIM_ADDRESS=
TREASURY_ADDRESS=# Compile contracts
npm run compile
# Deploy to Base mainnet
npx hardhat run scripts/deploy.js --network base
# Verify contracts on BaseScan
npx hardhat verify --network base <CONTRACT_ADDRESS>After deployment, note the contract addresses for the frontend configuration.
# Install Turso CLI
npm install -g @tursodatabase/cli
# Login to Turso
turso auth login
# Create production database
turso db create joybit-production
# Get database URL
turso db show joybit-production# Set environment variables
export TURSO_DATABASE_URL=your_production_db_url
export TURSO_AUTH_TOKEN=your_auth_token
# Run database setup
npm run db:setup-
Connect Repository
- Go to vercel.com
- Import your GitHub repository
- Connect the
Adrijan-Petek/joybitrepository
-
Configure Environment Variables
Add these environment variables in Vercel dashboard:
# Network Configuration NEXT_PUBLIC_CHAIN_ID=8453 NEXT_PUBLIC_BASE_MAINNET_RPC_URL=https://mainnet.base.org # WalletConnect NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id # Admin Configuration NEXT_PUBLIC_ADMIN_WALLET_ADDRESS=0xYourAdminAddress # Database TURSO_DATABASE_URL=your_production_db_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 (from 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...
-
Deploy
- Vercel will automatically build and deploy
- Monitor deployment logs for any issues
- Access your site at the provided URL
# Build for production
npm run build
# Start production server
npm run start- Go to Vercel project settings
- Add custom domain in "Domains" section
- Configure DNS records as instructed
- Update any hardcoded URLs in the application
- Vercel provides automatic SSL certificates
- Manual deployments require SSL configuration
-
Access Admin Panel
- Navigate to
https://yourdomain.com/admin - Connect with admin wallet
- Navigate to
-
Initial Configuration
- Set up security settings
- Configure game parameters
- Test all functionality
# Test database connection
npm run db:test
# Verify table creation
npm run db:verify-
BaseScan Verification
- Verify all contracts on BaseScan
- Ensure contract code is publicly visible
-
Contract Testing
- Test contract interactions on mainnet
- Verify token transfers and game logic
- Enable Vercel Analytics for performance monitoring
- Monitor error rates and response times
- Track user engagement metrics
- Regular security dashboard checks
- Monitor threat detection logs
- Review blocked IP addresses
# Monitor database performance
turso db stats joybit-production
# Check database logs
turso db logs joybit-production- Monitor contract balances on BaseScan
- Track transaction volumes
- Set up alerts for unusual activity
# Deploy updates via Git
git add .
git commit -m "Production update"
git push origin main
# Vercel auto-deploys on push# For contract updates (if needed)
npx hardhat run scripts/upgrade-contract.js --network base
# Verify updated contract
npx hardhat verify --network base <NEW_CONTRACT_ADDRESS>- Database Backup: Regular automated backups
- Contract Immutability: Plan for proxy upgrade patterns
- Frontend Rollback: Use Vercel deployment history
- Detection: Monitor security dashboard
- Assessment: Review threat logs
- Containment: Enable lockdown mode if needed
- Recovery: Restore normal operations
- Analysis: Post-incident review
- Identify Issue: Check Vercel status and logs
- Database Check: Verify Turso connectivity
- Contract Check: Monitor Base network status
- Communication: Update users via status page
- Edge Runtime: Security proxy runs at edge
- Database Indexing: Optimize query performance
- Caching Strategy: Implement appropriate caching layers
- CDN: Use Vercel's global CDN
- Database: Monitor usage and scale as needed
- Contracts: Gas optimization for high usage
- Frontend: Optimize bundle size and loading
- All contracts verified on BaseScan
- Admin wallet secured with hardware wallet
- Environment variables properly configured
- Security settings tuned for production
- Database access restricted
- SSL certificates valid
- Rate limiting configured
- Threat detection active
- Regular security audits
- Monitor threat logs daily
- Update dependencies monthly
- Review access logs weekly
- Backup security configurations
Build Failures:
# Clear build cache
rm -rf .next
npm run buildDatabase Connection:
# Test database connectivity
npm run db:testContract Interaction:
- Verify RPC URL configuration
- Check contract addresses
- Monitor Base network status
- Deployment Issues: GitHub Issues
- Security Concerns: Security Discussions
- General Support: adrijan@joybit.game
- Smart contracts deployed and verified
- Database created and configured
- Frontend deployed to hosting platform
- Environment variables configured
- Custom domain configured
- SSL certificate active
- Admin panel accessible
- All games functional
- Security system active
- Monitoring tools configured
- Backup procedures in place
- Emergency procedures documented
🎉 Congratulations! Joybit is now live in production! /home/mobb/Downloads/Joybit/wiki/Deployment.md