A fully decentralized poker platform built on Solana blockchain with Next.js, featuring 6-player Texas Hold'em tournaments with on-chain escrow and automatic prize distribution.
- 🎮 6-Player Tournaments: Fast-paced sit-and-go tournaments with exactly 6 players per table
- ⚡ Instant Payouts: Winners receive SOL directly to their wallet via Solana smart contract
- 🔒 Provably Fair: All buy-ins held in escrow, transparent rake structure
- 👛 Wallet-Only Auth: No passwords, just connect your Solana wallet
- 📊 Admin Dashboard: Create tournaments, configure rake, view statistics
- 🎯 Real-Time Gameplay: Live updates for all players at the table
- Frontend: Next.js 14 (App Router), React, TypeScript, Tailwind CSS
- Blockchain: Solana (Anchor framework)
- Database: PostgreSQL + Prisma ORM
- Authentication: Solana wallet signatures + JWT
- Styling: Tailwind CSS + shadcn/ui components
- Wallet Integration: @solana/wallet-adapter-react (Phantom, Solflare, Torus)
solpoker/
├── app/ # Next.js app router
│ ├── page.tsx # Home page (wallet connection)
│ ├── lobby/ # Tournament lobby
│ ├── game/[tournamentId]/ # Poker table/game UI
│ ├── admin/ # Admin dashboard
│ └── api/ # API routes
│ ├── auth/wallet/ # Wallet authentication
│ ├── tournaments/ # Tournament management
│ ├── game/ # Game actions & state
│ └── admin/ # Admin endpoints
├── components/
│ ├── providers/ # React context providers
│ └── poker/ # Poker UI components
├── lib/
│ ├── poker-engine/ # Core poker game logic
│ │ ├── deck.ts # Card shuffling
│ │ ├── hand-evaluator.ts # Hand ranking algorithm
│ │ ├── game-state.ts # Game state management
│ │ ├── actions.ts # Action validation
│ │ └── pot-calculator.ts # Pot/side pot calculation
│ ├── solana/ # Solana integration
│ │ ├── poker-program.ts # Program SDK
│ │ └── config.ts # Solana configuration
│ ├── auth/ # Authentication utilities
│ ├── tournament-manager.ts # Tournament orchestration
│ └── db.ts # Prisma client
├── prisma/
│ └── schema.prisma # Database schema
└── solana-program/ # Anchor Solana program
└── programs/poker-escrow/ # Smart contract
└── src/lib.rs # Rust program code
- Node.js v18 or later
- PostgreSQL database
- Rust & Anchor CLI (for deploying Solana program)
- Solana CLI tools
- Phantom/Solflare wallet (for testing)
npm installCreate a PostgreSQL database and run migrations:
# Create .env file with your database URL
echo 'DATABASE_URL="postgresql://user:password@localhost:5432/poker_db"' > .env
# Run Prisma migrations
npx prisma migrate dev --name init
npx prisma generate# Install Rust and Anchor (if not already installed)
# https://www.anchor-lang.com/docs/installation
cd solana-program
# Build the program
anchor build
# Deploy to devnet
anchor deploy --provider.cluster devnet
# Copy the program ID from the outputCreate/update .env in the root directory:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/poker_db"
# Solana
NEXT_PUBLIC_SOLANA_NETWORK="devnet"
NEXT_PUBLIC_SOLANA_RPC_URL="https://api.devnet.solana.com"
NEXT_PUBLIC_POKER_PROGRAM_ID="<YOUR_DEPLOYED_PROGRAM_ID>"
# Admin
ADMIN_WALLET_ADDRESS="<YOUR_ADMIN_WALLET_ADDRESS>"
# JWT
JWT_SECRET="your-secret-key-change-in-production"
NEXTAUTH_SECRET="your-nextauth-secret"
NEXTAUTH_URL="http://localhost:3000"After running the app once (so a user is created), update the database to make yourself admin:
-- Connect to your PostgreSQL database
psql -d poker_db
-- Make your wallet address an admin
UPDATE users SET is_admin = true WHERE wallet_address = 'YOUR_WALLET_ADDRESS';npm run devOpen http://localhost:3000 in your browser.
- Connect Wallet: Click "Connect Wallet" on the home page
- Join Tournament: Browse available tournaments in the lobby
- Play Poker: Once 6 players join, the game starts automatically
- Win Prizes: Winner receives the prize pool (minus rake) directly to their wallet
- Access Admin Dashboard: Navigate to
/adminafter connecting admin wallet - Create Tournament: Set name, buy-in amount, and rake percentage
- Monitor Stats: View total tournaments, active games, and rake collected
- Withdraw Rake: Collect accumulated rake from completed tournaments
-
Tournament Creation:
- Admin creates tournament via dashboard
- Smart contract initializes tournament escrow account
- Tournament appears in lobby
-
Player Join:
- Players connect wallet and join tournament
- Each player sends buy-in to escrow via Solana transaction
- Once 6 players join, game auto-starts
-
Gameplay:
- Server manages game state (dealing cards, betting rounds)
- Players take turns: fold, check, call, raise, all-in
- Hand evaluator determines winner at showdown
- Repeat until only one player has chips
-
Payout:
- Smart contract distributes prize pool to winner
- Admin can withdraw accumulated rake
- Tournament marked as complete
- Escrow Account: Holds all buy-ins during tournament
- Rake Calculation: Automatically deducts rake from buy-ins
- Prize Distribution: Transfers prize pool to winner
- Admin Controls: Only admin can trigger payouts and withdraw rake
- Card Shuffling: Cryptographically secure random shuffling
- Hand Evaluation: Accurate poker hand ranking (high card to royal flush)
- Action Validation: Prevents invalid moves
- Pot Management: Handles main pot and side pots for all-ins
- Tournament Manager: Orchestrates 6-player lifecycle
- Users: Wallet address, username, admin status, total winnings
- Tournaments: Buy-in, rake, status, escrow address
- Games: Current hand, pot, dealer position, blind amounts
- Hands: Community cards, winner, action history
GET /api/auth/wallet?address=xxx- Get message to signPOST /api/auth/wallet- Verify signature and get JWT
GET /api/tournaments- List all tournamentsPOST /api/tournaments- Create tournament (admin only)GET /api/tournaments/[id]- Get tournament detailsPOST /api/tournaments/[id]/join- Join tournament
GET /api/game/[tournamentId]/state- Get current game statePOST /api/game/[tournamentId]/action- Submit player action
GET /api/admin/stats- Get statistics (admin only)
# Run poker engine tests (once implemented)
npm test
# Run Prisma Studio (database GUI)
npx prisma studioAfter schema changes:
npx prisma migrate dev
npx prisma generatenpm run build
npm start- Push code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy
- Create PostgreSQL instance
- Update DATABASE_URL
- Run
npx prisma migrate deploy
Deploy to mainnet when ready:
cd solana-program
anchor build --verifiable
anchor deploy --provider.cluster mainnet-beta- Ensure tournament has 6 players and has started
- Check that game state is being synced to database
- Clear browser cache
- Try different wallet (Phantom vs Solflare)
- Check wallet is on correct network (devnet vs mainnet)
- Ensure sufficient SOL for buy-in + gas fees
- Verify program ID is correct in .env
- Check Solana network status
- Audit smart contract thoroughly
- Implement proper WebSocket authentication
- Add rate limiting to API endpoints
- Use secure random number generation
- Implement connection pooling
- Add comprehensive error handling
- Set up monitoring and logging
- Consider regulatory compliance
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - See LICENSE file for details
- Inspired by crypto-poker by troytroy
- Built with Anchor
- Uses Solana Wallet Adapter
For issues and questions:
- Open a GitHub issue
- Check IMPLEMENTATION_STATUS.md for known limitations
- Review Solana and Anchor documentation
Note: This project is for educational purposes. Online poker may be restricted in some jurisdictions. Do your research and ensure compliance with local laws before deploying.