Predict. Compete. Survive. โ A gamified prediction market where players stake ETH, predict BTC price movements, and compete in elimination rounds until one winner takes the pot.
- Multi-round tournaments โ 3โ20 rounds per game with progressive elimination
- Commit-reveal scheme โ Prevents front-running of predictions using on-chain hashed commitments
- Oracle-powered โ Chainlink price feeds for BTC/USD and ETH/USD resolution
- Real-time eliminations โ Bottom players eliminated each round
- 70/20/10 payout โ Winner takes 70%, 2nd gets 20%, 3rd gets 10%
- ERC-721 badges โ Participation NFTs with on-chain SVG metadata
- Live leaderboard โ Real-time score updates via Supabase Realtime
- Wallet-first โ No email/password. Connect MetaMask, WalletConnect, or Coinbase Wallet
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Contract Architecture โ
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ GameFactoryโโโโโโโถโ GameLobby (per game) โ โ
โ โ (Solidity) โ โ (Solidity) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ โ
โ โ โ โ โ
โ โผ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโ
โ โ ScoreEngine โ โ PrizeVault โ โ Oracle โโ
โ โ (Solidity) โ โ (Solidity) โ โAdapter โโ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ParticipationNFT (ERC-721) โ โ
โ โ (Solidity) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
User โ Frontend (Next.js) โ RainbowKit/wagmi โ Smart Contracts (Arbitrum Sepolia)
โ
Event Indexer (ethers.js)
โ
PostgreSQL (Supabase)
โ
Realtime WebSocket โ Frontend
| Layer | Technology |
|---|---|
| Smart Contracts | Solidity 0.8.x |
| Framework | Foundry (forge, cast, anvil) |
| L2 Network | Arbitrum Sepolia |
| Oracle | Chainlink Price Feeds |
| Frontend | Next.js 16 + TypeScript + Tailwind CSS |
| Web3 | wagmi v2 + viem + RainbowKit |
| State | Zustand + React Query |
| Charts | Recharts |
| Animations | Framer Motion |
| Backend | Node.js + Express |
| Database | PostgreSQL (Supabase) |
| Realtime | Supabase Realtime (WebSocket) |
pr/
โโโ contracts/ # Foundry project (Smart Contracts)
โ โโโ src/
โ โ โโโ GameFactory.sol # Lobby factory & registry
โ โ โโโ GameLobby.sol # Core game logic
โ โ โโโ ScoreEngine.sol # Scoring & ranking
โ โ โโโ PrizeVault.sol # Prize pool management
โ โ โโโ ParticipationNFT.sol # ERC-721 badges
โ โ โโโ OracleAdapter.sol # Chainlink feed wrapper
โ โ โโโ interfaces/ # Solidity interfaces
โ โ โโโ mocks/ # Test mocks
โ โโโ test/ # Foundry tests
โ โโโ script/ # Deployment scripts
โ โโโ foundry.toml
โ
โโโ frontend/ # Next.js application
โ โโโ src/
โ โ โโโ app/ # Pages (landing, lobby, game, profile)
โ โ โโโ components/ # Reusable UI components
โ โ โโโ lib/ # Utilities, ABI, contracts config
โ โ โโโ store/ # Zustand state
โ โโโ package.json
โ
โโโ backend/ # Express API + Supabase
โ โโโ src/
โ โ โโโ routes/ # REST endpoints
โ โ โโโ db/ # Schema + queries
โ โ โโโ server.ts
โ โโโ package.json
โ
โโโ indexer/ # Blockchain event indexer
โ โโโ src/
โ โ โโโ eventListener.ts
โ โโโ package.json
โ
โโโ README.md
- Node.js 20+
- Foundry (forge, cast, anvil)
- Git
# Clone the repository
git clone <repo-url>
cd pmbr
# Install frontend dependencies
cd frontend && npm install
# Install backend dependencies
cd ../backend && npm install
# Install indexer dependencies
cd ../indexer && npm installCopy .env.example to .env and fill in:
# Required for deployment
ARB_SEPOLIA_RPC=https://sepolia-rollup.arbitrum.io/rpc
PRIVATE_KEY=your_deployer_private_key
ARBISCAN_API_KEY=your_arbiscan_api_key
# Required for frontend
NEXT_PUBLIC_ARB_SEPOLIA_RPC=https://sepolia-rollup.arbitrum.io/rpc
NEXT_PUBLIC_GAME_FACTORY_ADDRESS=deployed_factory_address
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your_walletconnect_project_id
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
# Required for backend
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_KEY=your_supabase_service_role_keycd contracts
forge test -vvvcd contracts
forge script script/DeployAll.s.sol \
--rpc-url $ARB_SEPOLIA_RPC \
--private-key $PRIVATE_KEY \
--broadcast \
--verifycd frontend
npm run devcd backend
npm run devcd indexer
npm run start- Connect Wallet โ MetaMask / WalletConnect on Arbitrum Sepolia
- Browse/Create Lobby โ Set stake, max players, rounds
- Join & Wait โ Pay stake, wait for players or countdown
- Commit Phase (30s) โ Submit hashed prediction (YES/NO on price move)
- Reveal Phase (60s) โ Reveal prediction with salt
- Oracle Resolution โ Chainlink fetches real price
- Elimination โ Bottom players removed per round
- Repeat โ Until 1 player remains or all rounds complete
- Payout โ Winner 70%, 2nd 20%, 3rd 10% (3% protocol fee)
Factory contract that deploys and tracks all GameLobby instances.
| Function | Description |
|---|---|
createGame() |
Deploy new game lobby with params |
getActiveGames() |
List all open lobbies |
getGamesByPlayer() |
Player's game history |
Core game logic โ round management, commit-reveal, scoring, elimination, payouts.
| Function | Description |
|---|---|
joinGame() |
Pay stake to join |
submitCommitment() |
Commit hashed prediction |
revealPrediction() |
Reveal value + salt |
resolveRound() |
Fetch oracle price, compute scores |
eliminatePlayers() |
Remove bottom scorers |
claimPayout() |
Withdraw winnings |
Scoring: accuracy % + time bonus. Rankings via bubble sort.
Isolated escrow with non-reentrant claims.
ERC-721 badges with on-chain SVG showing rank, game ID, rounds survived.
Chainlink AggregatorV3Interface wrapper with staleness check (5 min).
- ReentrancyGuard on all payable functions
- Commit-reveal prevents front-running
- No admin rug โ PrizeVault has no owner withdrawal
- Oracle staleness check โ rejects prices >5 minutes old
- Max 100 players โ prevents gas griefing
- Solidity 0.8.x โ built-in overflow protection