DINO.sol is an on-chain game built on Solana where players pay SOL to play and earn rewards based on their performance. The game features a classic dino runner mechanic with blockchain integration for payments and rewards.
- Character: A dinosaur that runs and jumps over obstacles
- Obstacles: Black rectangular blocks spawn randomly on the ground
- Controls: Press SPACE or click to make the dino jump
- Scoring: Each obstacle passed increases your score
- Difficulty: Game speed gradually increases over time
- Background: Light green sky (
#ccffcc) - Ground: Black surface where the dino runs and jumps
- Theme: Minimalist black and white design with a clean, retro aesthetic
Pay-to-Play Model:
- Players must pay 1 SOL (devnet) before each game session
- Payment is sent from the player's wallet to the game treasury via
SystemProgram.transfer - The payment is processed client-side using the Solana Wallet Adapter
- Once payment is confirmed, the game unlocks
Flow:
- User connects wallet (Phantom, Solflare, etc.)
- User navigates to
/play SolPaymentWrapperchecks SOL balance- If sufficient, user pays 1 SOL to treasury
- Game unlocks and player can start playing
Score-Based Rewards:
- Reward formula: Score ÷ 5 = SOL Reward
- Example: Score of 10 = 2 SOL reward, Score of 25 = 5 SOL reward
- Rewards are automatically sent from the treasury wallet to the player's wallet
Architecture:
- Frontend: Game component calls
/api/rewardendpoint when game ends - Backend: Server-side API route handles treasury signing (private key never exposed to client)
- Treasury Wallet: Holds SOL for rewards and faucet operations
- Transaction: Uses
SystemProgram.transferto send SOL from treasury to player
Security:
- Treasury private key is stored server-side only (in environment variables)
- Client never has access to treasury signing capabilities
- All reward transactions are signed server-side using the treasury keypair
SOL Faucet:
- Located at
/buy-wormroute - Provides free devnet SOL to players who need it
- Daily limit: 0.25 SOL per wallet address
- Uses the same treasury wallet to distribute SOL
Frontend:
- Next.js 16 (App Router) - React framework
- Phaser 3 - Game engine for the dino runner
- Solana Web3.js - Blockchain interactions
- @solana/wallet-adapter-react - Wallet connection and transaction signing
Backend:
- Next.js API Routes - Server-side endpoints for rewards and faucet
- Solana Web3.js - Server-side transaction signing
- Treasury Keypair - Server-managed wallet for automated payments
Key Components:
components/SimpleFlappyGame.tsx- Main game logic and Phaser scenecomponents/SolPaymentWrapper.tsx- Payment gate before game accessapp/api/reward/route.ts- Server-side reward distributionapp/api/sol-faucet/route.ts- Server-side SOL faucet
npm installnpm run devOpen http://localhost:3000 to play the game.
- Splash Screen → First-time users see an intro story
- Home Page → Connect wallet, view game info
- Play Route → Pay 1 SOL to unlock game
- Gameplay → Jump over blocks, increase score
- Game Over → Calculate reward (score/5), send SOL from treasury
- Reward Modal → Display earned SOL amount
- Redirect → Return to home page
- Treasury Key Management: Private keys are stored server-side only, never exposed to the client
- Transaction Signing: All treasury-signed transactions happen on the server via API routes
- Wallet Integration: Client-side wallet adapter handles user transactions securely
- Network: Currently configured for Solana devnet (testnet SOL only)
Solana Development:
Game Development: