Skip to content

Ayyykayy/W3B-Poker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Web3 Poker Game

A fully decentralized Texas Hold'em poker game built on Avalanche blockchain with AI opponents, real money stakes, and Supabase backend for persistent game history and leaderboards.

Tech Stack TypeScript Vite ethers.js Avalanche Supabase

โœจ Features

๐ŸŽฏ Core Game

  • 3-Player Texas Hold'em - Play against 2 AI opponents
  • AI Personalities - AGGRESSIVE, TIGHT, LOOSE, CONSERVATIVE personalities
  • Smart Hand Evaluation - pokersolver library for accurate hand rankings
  • Real Betting - Chip stacks, bet sliders, all-in mechanics
  • Game Stages - PreFlop, Flop, Turn, River, Showdown

๐Ÿ’ฐ Blockchain Integration

  • Real Money Poker - Entry fees in AVAX, winner payouts from smart contract
  • Wallet Support - MetaMask & Core Wallet
  • Avalanche Fuji - Testnet for development (~$0.06 per game)
  • Smart Contract - Solidity escrow (joinGame, payWinner, setEntryFee)
  • On-Chain Transparency - All transactions logged on blockchain

๐Ÿ—„๏ธ Backend & Database

  • Supabase PostgreSQL - Persistent game history
  • Player Profiles - Wallet-based identification
  • Nodepoints Loyalty - Earn points for wins (50 base + 10ร—profit)
  • Leaderboard - Top 10 rankings by nodepoints
  • Game Analytics - W/L record, ROI, win streaks

๐ŸŽจ UI/UX

  • Beautiful Dark Theme - Modern gradient design
  • Smooth Animations - Framer Motion transitions
  • Responsive Design - Works on desktop & tablet
  • Real-Time Logging - Game ledger with transaction hashes
  • Settings Panel - Contract address configuration

๐Ÿš€ Quick Start

Prerequisites

Installation

  1. Clone & Install

    git clone <your-repo>
    cd web3-poker
    npm install
  2. Setup Environment Variables

    cp .env.example .env.local
    # Add your Supabase credentials if desired
    # (Optional - game works without backend)
  3. Run Locally

    npm run dev
    # Opens at http://localhost:3000
  4. Deploy Smart Contract (Optional - for real stakes)

๐Ÿ“‹ Technology Stack

Layer Technology
Frontend React 19 + TypeScript + Vite
Styling Tailwind CSS + Motion animations
Blockchain ethers.js v6 + Solidity + Avalanche
Backend Supabase (PostgreSQL)
Game Logic pokersolver + custom AI
Wallets MetaMask + Core Wallet

๐Ÿ“‚ Project Structure

web3-poker/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ gameLogic.ts         # Poker rules & AI
โ”‚   โ”‚   โ”œโ”€โ”€ web3.ts              # Blockchain integration
โ”‚   โ”‚   โ””โ”€โ”€ supabaseClient.ts     # Database operations
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ PokerGame.tsx        # Main game component
โ”‚   โ”‚   โ””โ”€โ”€ ui/                  # shadcn components
โ”‚   โ”œโ”€โ”€ App.tsx
โ”‚   โ””โ”€โ”€ main.tsx
โ”œโ”€โ”€ PokerGame.sol                # Smart contract
โ”œโ”€โ”€ .env.example                 # Environment template
โ”œโ”€โ”€ vite.config.ts               # Build config
โ”œโ”€โ”€ tsconfig.json                # TypeScript config
โ””โ”€โ”€ package.json

๐ŸŽฏ Game Rules

Hand Rankings

Follows standard poker hand rankings (High Card โ†’ Royal Flush)

Betting

  • Starting chips: 1000
  • Minimum bet: 10
  • No limit (pot-style betting)
  • All-in allowed

Stages

  1. PreFlop - 2 hole cards, first betting round
  2. Flop - 3 community cards, betting round
  3. Turn - 4th community card, betting round
  4. River - 5th community card, final betting round
  5. Showdown - Best 5-card hand wins pot

๐Ÿค– AI Opponent Personalities

Type Playstyle Aggression
AGGRESSIVE Bluffs often, raises frequently 90%
TIGHT Plays premium hands only 50%
LOOSE Plays many hands, loose calls 70%
CONSERVATIVE Folding-heavy, risk-averse 30%

๐Ÿ’ณ Supabase Setup (Optional)

Game works perfectly without Supabase, but with setup you get persistent stats!

See SUPABASE_SETUP_GUIDE.md for detailed instructions.

Quick version:

  1. Create free account at https://supabase.com
  2. Get URL + Anon Key from Settings โ†’ API
  3. Update .env.local with credentials
  4. Run SQL schema in Supabase editor
  5. Game automatically syncs player stats

๐Ÿ”— Smart Contract

Deploy PokerGame.sol on Avalanche Fuji:

contract PokerGame {
  function joinGame() payable public    // Pay entry fee
  function payWinner(address winner) onlyOwner  // Payout winner
  function setEntryFee(uint256 fee) onlyOwner   // Admin control
}

See REMIX_INTEGRATION_GUIDE.md for step-by-step deployment.

๐Ÿงช Testing

npm run dev      # Start dev server
npm run build    # Compile for production
npm run preview  # Test production build locally
npm run lint     # Check TypeScript

๐Ÿ“Š Game Statistics

  • Gas Cost: ~$0.06 per game on Avalanche Fuji
  • Block Time: 2-3 seconds
  • UI Load Time: <2 seconds
  • Hand Evaluation: Instant (<100ms)

๐Ÿ” Security Notes

  • Private keys never leave your wallet
  • Smart contract handles fund escrow
  • Supabase auth via wallet signature (EIP-191)
  • RLS policies restrict database access
  • Contract is NOT audited (development version)

๐ŸŽ“ Architecture

User Wallet (MetaMask/Core)
    โ†“
ethers.js (Web3 Library)
    โ†“
PokerGame.sol (Avalanche Blockchain)
    โ†“
Game Logic + AI (Client-side)
    โ†“
Supabase (Optional: Game History & Stats)
    โ†“
React UI (Tailwind + shadcn)

๐Ÿ“š Documentation

๐Ÿš€ Deployment

Testnet (Avalanche Fuji)

  1. Deploy smart contract on Remix (free)
  2. Set up Supabase (free tier)
  3. Run npm run build
  4. Deploy to Vercel/Netlify

Mainnet (Production)

  • Deploy contract on Avalanche C-Chain
  • Use mainnet Supabase project
  • Add security policies (RLS)
  • Audit smart contract before real funds

See ON_CHAIN_DEPLOYMENT.md for instructions.

๐Ÿค Contributing

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

๐Ÿ“„ License

MIT License - see LICENSE file

๐ŸŽ“ Learning Resources

๐ŸŽฎ Play Now

npm run dev
# Connect wallet โ†’ Play game โ†’ Earn AVAX + nodepoints!

Built with โค๏ธ using Web3 technologies. Have fun and play responsibly!

About

WEBSITE

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages