HackAG MBC is a web-first, multiplayer Texas Hold’em poker platform built on the Base L2 blockchain, designed to bring transparency and trust to online poker. It features a dual-mode system: a Real-Money Mode where players compete with USDC on Base (Sepolia/Mainnet) and a Play-Money Mode for casual, off-chain practice.
The platform ensures game integrity through a decentralized architecture, securing funds and logic with Solidity smart contracts while delivering a seamless, real-time experience via a Socket.io-powered backend. Uniquely, it incorporates a Reputation System using Soulbound NFTs to track and display player stats permanently on-chain.
With an intuitive interface built on Next.js and TailwindCSS, and seamless onboarding via Coinbase Smart Wallet and Metamask, HackAG MBC bridges the gap between traditional gaming usability and Web3 security.
HackAG MBC employs a hybrid architecture combining the security of smart contracts with the speed of a centralized game server for real-time play.
-
Smart Contracts (Base L2)
- Layer: Base (EVM L2).
- Management:
PokerGameManager.solhandles table creation, USDC escrow, and secure payouts. - Identity:
ReputationNFT.sol(Soulbound Token) tracks player statistics on-chain. - Currency: Uses USDC (and MockUSDC for testing).
-
Backend (Game Engine)
- Runtime: Node.js with TypeScript (
/backend). - Logic: Centralized game engine handles poker rules (hand evaluation, pot calculation, turn management) to ensure instant finality and smooth UX.
- Real-time Interaction:
Socket.ioserver manages bi-directional communication (dealing cards, player actions). - Verifiable: Listens to on-chain events (
GameCreated,PlayerJoined) to sync state.
- Runtime: Node.js with TypeScript (
-
Frontend (Client)
- Framework: Next.js (React) (
/frontend). - Web3 Integration:
wagmiandviemfor wallet connection (Coinbase Smart Wallet, Metamask) and contract interactions. - Styling: TailwindCSS for a responsive, modern UI.
- Framework: Next.js (React) (
- Frontend: Deployed on Vercel (recommended) or Netlify. It requires build-time environment variables for strict typing and public client keys.
- Backend: Hosted on a persistent Node.js server (e.g., Render, Heroku, or AWS EC2). It requires a persistent
Socket.ioconnection. - Smart Contracts: Deployed on Base Sepolia (Testnet) or Base Mainnet.
- Database: Uses SQLite for lightweight persistence of game history and user sessions (can be swapped for PostgreSQL for scale).
- Real-Money Mode: Play with USDC on Base (Sepolia/Mainnet).
- Play-Money Mode: Free play with off-chain chips.
- Reputation System: Soulbound NFT tracking player stats.
- Real-Time Gameplay: Socket.io based game engine.
- Wallet Auth: Connect with Metamask/Coinbase Wallet.
Languages & Frameworks:
- TypeScript
- Solidity (0.8.24)
- Next.js
- Express
- Hardhat
Libraries & Tools:
- React
- Socket.io
- TailwindCSS
- RainbowKit
- wagmi / viem
- Ethers.js
- SQLite
Blockchain:
- Base (L2)
- Node.js v18+
- Git
-
Install Dependencies
# Root directory npm install # Install subproject dependencies cd contracts && npm install cd ../backend && npm install cd ../frontend && npm install
-
Environment Variables
- Create
.envincontractsandbackendbased on.env.example. - Backend: Needs
PRIVATE_KEYfor contract interaction (optional for play-money only) and providing thePORT(default 3001). - Frontend: Configure
NEXT_PUBLIC_API_URLto point to your backend.
- Create
You can run the full stack with the provided PowerShell script:
./start-dev.ps1Or manually:
-
Contracts (Local Node)
cd contracts npx hardhat node # In another terminal: npx hardhat run scripts/deploy.js --network localhost
-
Backend
cd backend npm run dev # Server runs on http://localhost:3001
-
Frontend
cd frontend npm run dev # App runs on http://localhost:3000
- Contracts:
cd contracts && npx hardhat test - Backend:
cd backend && npm test
ISC