A full-stack, production-ready web application for a provably fair roulette casino game called "Solana Roulette VRF". This centralized casino game features real Solana Web3 wallet payments via Phantom, Backpack, and other Solana wallets, with cryptographic provable fairness verification.
- 🔐 Provably Fair Mechanism: Cryptographic seed-based fairness with server seed hash pre-commit, client seed, and nonce → HMAC-SHA256 to derive roulette outcomes (0-36 for European wheel)
- 💳 Solana Wallet Integration: Connect with Phantom, Backpack, and other Solana wallets for deposits, bets, and payouts
- 🎲 European Roulette: Full support for 0-36 wheel with common bet types (straight, split, red/black, even/odd, dozens, columns, etc.)
- ✨ Animated Wheel: Beautiful roulette wheel spin animation with Framer Motion
- ✅ Fairness Verification: Built-in tool to verify any spin's fairness by recomputing the outcome
- 💰 Real-time Balance: Off-chain balance tracking with on-chain SOL deposits
- 🎨 Modern UI: Dark casino-themed interface with Tailwind CSS v4
- 📱 Responsive Design: Works seamlessly on desktop and mobile devices
- Node.js + Express + TypeScript
- SQLite database for user data, balances, and spin history
- @solana/web3.js for transaction verification
- JWT authentication with wallet signature verification
- HMAC-SHA256 for provably fair outcome derivation
- React 19 + Vite + TypeScript
- Tailwind CSS v4 for styling
- Framer Motion for animations
- @solana/wallet-adapter-react for wallet integration
- @solana/web3.js for transaction creation
- React Hot Toast for notifications
- React Confetti for win celebrations
- Node.js 18+ and npm
- Solana Wallet (Phantom, Backpack, etc.)
- Solana RPC endpoint (public or Helius/Alchemy)
cd Solana-Roulette-VRF
npm run install:allCreate a .env file in the root directory:
# Server Configuration
PORT=3001
NODE_ENV=development
# JWT Secret for wallet authentication
JWT_SECRET=your-super-secret-jwt-key-change-in-production
# Solana Configuration
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
# Alternative: https://mainnet.helius-rpc.com/?api-key=YOUR_KEY
SOLANA_NETWORK=mainnet-beta
HOUSE_WALLET_ADDRESS=YourHouseWalletPublicKeyHere
# Database
DB_PATH=./data/casino.db
# CORS
FRONTEND_URL=http://localhost:5173Create a .env file in the frontend directory:
VITE_API_URL=http://localhost:3001
VITE_SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
VITE_SOLANA_NETWORK=mainnet-beta
VITE_HOUSE_WALLET_ADDRESS=YourHouseWalletPublicKeyHereTerminal 1 - Backend:
npm run dev:backendTerminal 2 - Frontend:
npm run dev:frontendNavigate to http://localhost:5173 and connect your Solana wallet!
- Connect Wallet: Click the wallet button in the header and connect your Phantom, Backpack, or other Solana wallet
- Authenticate: Sign a message to authenticate your wallet
- Deposit SOL: Send SOL to the house wallet address (shown in the deposit section)
- Place Bets:
- Choose bet amount (0.01, 0.05, 0.1, 0.5, or 1.0 SOL)
- Select bet type (red/black, even/odd, straight numbers, etc.)
- Add multiple bets if desired
- Spin: Click "SPIN!" to create a new spin
- Watch the Wheel: The animated roulette wheel will spin and reveal the winning pocket
- Verify Fairness: Click "Verify Fairness" on any resolved spin to cryptographically verify the outcome
- Withdraw: Request a withdrawal to send your winnings to your wallet
- Pre-Commit: Before each spin, the server generates a random server seed and sends its SHA-256 hash to the frontend
- Client Seed: The player provides or auto-generates a client seed (editable in the UI)
- Nonce & Round: Each spin has a unique nonce and round number
- Outcome Derivation: The winning pocket is derived using:
HMAC-SHA256(serverSeed, `${clientSeed}:${nonce}:${round}`) → Take first 8 bytes → Convert to number → Mod 37 → Pocket (0-36) - Reveal: After the spin, the server seed is revealed
- Verification: Players can verify fairness by:
- Confirming the server seed hash matches the revealed seed
- Recomputing the HMAC to derive the winning pocket
- Comparing with the actual outcome
The built-in verification tool allows you to:
- Input server seed, client seed, nonce, and round
- Verify the server seed hash matches
- Recompute the winning pocket using the same HMAC algorithm
- Confirm the outcome matches the revealed result
| Bet Type | Payout | Description |
|---|---|---|
| Straight | 35:1 | Single number (0-36) |
| Split | 17:1 | Two adjacent numbers |
| Street | 11:1 | Three numbers in a row |
| Corner | 8:1 | Four numbers |
| Line | 5:1 | Six numbers |
| Red/Black | 1:1 | All red or all black numbers |
| Even/Odd | 1:1 | All even or all odd numbers |
| Low/High | 1:1 | 1-18 or 19-36 |
| Dozen | 2:1 | 1-12, 13-24, or 25-36 |
| Column | 2:1 | One of three columns |
- Telegram: https://t.me/CasinoCutup
- Twitter: https://x.com/CasinoCutup