โโโโโโโโโโโโ โโโโโโโ โโโโโโโโโ โโโโโโ โโโโโโโ โโโโโโโโโ โโโโโโโ โโโโโโโโ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโ โโโโโโ โโโ โโโโโโโโโโโ โโโ โโโ โโโโโโโโโ
โโโ โโโโโโ โโโ โโโโโโโโโโโ โโโ โโโ โโโโโโโโโ
โโโ โโโโโโโโโโโ โโโ โโโ โโโโโโโโโโโ โโโ โโโโโโโโโโโโโโโโโ
โโโ โโโ โโโโโโโ โโโ โโโ โโโ โโโโโโโ โโโ โโโโโโโ โโโโโโโโ
โโโโโโโโโฆโโโโโโโโฆโโโโโโโโ
โ โ โ โ
โ X โ O โ X โ
โ โ โ โ
โ โโโโโโโโฌโโโโโโโโฌโโโโโโโโฃ
โ โ โ โ
โ O โ X โ O โ
โ โ โ โ
โ โโโโโโโโฌโโโโโโโโฌโโโโโโโโฃ
โ โ โ โ
โ X โ O โ X โ
โ โ โ โ
โโโโโโโโโฉโโโโโโโโฉโโโโโโโโ
Bet MATIC. Play Tic-Tac-Toe. Winner Takes All.
๐ฎ Play Now โข ๐ Docs โข ๐ Report Bug โข โจ Request Feature
A peer-to-peer betting platform where two players can wager MATIC on a Tic-Tac-Toe game. The smart contract acts as trustless escrow, holding funds until there's a winner. No house edge. No intermediaries. Just you, your opponent, and the blockchain.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฐ Bet Real Money ๐ฎ Play Classic Game ๐ Winner Gets 95%
๐ Trustless Escrow โก Instant Payouts ๐ Epic Celebrations
๐ Low Fees (5%) ๐ Polygon Network โก Fast Settlement
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- ๐ฒ No Draws: If there's a draw, the board auto-resets until someone wins
- โก Real-Time: Live updates via polling - see your opponent's moves instantly
- ๐ธ Fair Play: Smart contract ensures winner gets 1.9x their bet (5% hosting fee)
- ๐จ Beautiful UI: Minimalistic dark theme with confetti celebrations
- ๐ฑ Mobile Ready: Play on any device with MetaMask
- MetaMask browser extension
- Some MATIC on Polygon Mainnet (Bridge here)
1. ๐ Open: https://p2p-tic-tac-toe-1063244275551.us-central1.run.app
2. ๐ฆ Connect MetaMask (auto-connects on load)
3. ๐ฐ Create game OR join with Match ID
4. ๐ฎ Play Tic-Tac-Toe
5. ๐ Winner claims prize!
// Player A
1. Enter bet amount (e.g., 0.1 MATIC โ $0.10)
2. Click "Create Game"
3. Sign MetaMask transaction
4. Share your 6-digit Match ID with opponent// Player B
1. Enter the 6-digit Match ID
2. Enter same bet amount
3. Click "Join Game"
4. Sign MetaMask transaction
5. Game starts!- โ Auto wallet connection - โ Minimalistic dark theme - โ Fixed 3x3 grid (100px cells) - โ Copy-to-clipboard Match ID - โ Smooth animations
|
|
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ MetaMask โโโโโโโโบโ Frontend โโโโโโโโบโ Backend โ
โ (Polygon) โ โ (React) โ โ (Node.js) โ
โโโโโโโโฌโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโ
โ โ
โ Deposits & Claims โ Auto-signs
โ โ โ winners
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ UlaniWager Smart โ
โ Contract (Polygon) โ
โ Holds Funds Safely โ
โโโโโโโโโโโโโโโโโโโโโโโโ
| Layer | Technology |
|---|---|
| Frontend | React, Vite, ethers.js, canvas-confetti |
| Backend | Node.js, Express 4, ethers.js |
| Blockchain | Polygon Mainnet |
| Smart Contract | Solidity (UlaniWager) |
| Deployment | Google Cloud Run |
| Wallet | MetaMask |
// Player A creates game
createWager(matchId) payable
โ Locks Player A's MATIC
// Player B joins
joinWager(matchId) payable
โ Locks Player B's MATIC (must match A's bet)
// Winner claims prize
settle(matchId, winner, signature)
โ Verifies backend signature
โ Pays 95% of total pot to winner (5% hosting fee)
โ Winner receives 1.9x their original bet// Tracks game state
- Board position
- Whose turn
- Win/draw detection
// Signs winners
signature = sign(chainId + matchId + winnerAddress)
โ Cryptographic proof of win
โ Only backend can create valid signaturesQ: How do we prevent cheating?
A: Signature verification!
// Backend signs winner
const signature = backendWallet.sign(
keccak256(chainId, matchId, winnerAddress)
);
// Contract verifies signature
address signer = ecrecover(signature);
require(signer == TRUSTED_BACKEND_ADDRESS);
// โ
Only pays if signature is valid๐ Players can't forge signatures โ Need backend's private key
๐ Backend only signs actual winners โ Verified game state
๐ Contract mathematically verifies โ Uses ecrecover
graph LR
A[Player A Creates] -->|Deposit MATIC| B[Get Match ID]
B --> C[Player B Joins]
C -->|Deposit MATIC| D[Play Tic-Tac-Toe]
D -->|Win| E[Winner Claims]
D -->|Draw| F[Board Resets]
F --> D
E --> G[Get 2x Bet]
- Node.js 18+
- MetaMask with Polygon Mainnet
- Git
git clone https://github.com/88448844/polygon-p2p-tictactoe.git
cd polygon-p2p-tictactoe
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd ../frontend
npm installBackend (backend/.env):
PRIVATE_KEY=your_backend_wallet_private_key_without_0x
NODE_ENV=development
โ ๏ธ IMPORTANT: Never commit.envfiles! They're in.gitignore.
Frontend (frontend/.env):
VITE_API_URL=http://localhost:3000# Terminal 1: Start backend
cd backend
node server.js
# Terminal 2: Start frontend
cd frontend
npm run devOpen http://localhost:5173 and connect MetaMask to Polygon Mainnet!
# Setup
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
# Create secret for private key
echo -n "your_private_key" | gcloud secrets create BETTING_PRIVATE_KEY --data-file=-
# Deploy
gcloud run deploy p2p-tic-tac-toe \
--source . \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars "NODE_ENV=production" \
--set-secrets "PRIVATE_KEY=BETTING_PRIVATE_KEY:latest"See SPEC.md for detailed deployment guide.
- ๐ Technical Specification - Complete system architecture
- ๐ฎ Walkthrough - Feature guide & testing
- ๐๏ธ Smart Contract - View on PolygonScan
Contributions are welcome! Here's how:
- Fork the repo
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Polygon Network - For fast & cheap transactions
- MetaMask - For seamless wallet integration
- React & Vite - For amazing DX
- ethers.js - For blockchain interaction
- Google Cloud Run - For serverless hosting
Made with โค๏ธ for the Polygon community
๐ฎ Play Now โข ๐ Read Docs โข ๐ Report Issues
โโโโโโโโโฆโโโโโโโโฆโโโโโโโโ
โ โ โ โ
โ X โ O โ X โ
โ โ โ โ
โ โโโโโโโโฌโโโโโโโโฌโโโโโโโโฃ
โ โ โ โ
โ O โ X โ O โ
โ โ โ โ
โ โโโโโโโโฌโโโโโโโโฌโโโโโโโโฃ
โ โ โ โ
โ X โ O โ X โ
โ โ โ โ
โโโโโโโโโฉโโโโโโโโฉโโโโโโโโ
๐ฏ No draws. Only winners. ๐