A full-stack, peer-to-peer heads-or-tails betting arena on Solana — Players connect a wallet, open or accept on-chain matches, and compete head-to-head for 2× the stake. The UI updates in real time over WebSockets, outcomes are resolved on-chain with Orao VRF, and the server tracks matches, chat, and wallet stats in MongoDB.
FlipArena is split into three packages:
| Package | Role |
|---|---|
| fliparena-client | React UI — wallet connect, open/accept matches, live lobby, chat |
| fliparena-server | Node.js WebSocket server — match orchestration, tx relay, MongoDB, VRF settlement |
| fliparena-program | Anchor/Rust reference workspace (on-chain program kept from original deploy) |
The production PvP program used by the client and server is deployed at:
472RXUv8zUX7zm4LprxNsFQvAZYEpSGaY9EUE4akCvG6
FlipArena/
├── fliparena-client/ # React + Tailwind + wallet adapter
│ ├── src/
│ │ ├── components/ # UI (arena, modals, header, chat)
│ │ ├── providers/ # Arena socket + effects providers
│ │ └── lib/ # RPC, program IDs, menu tokens
│ └── package.json
│
├── fliparena-server/ # WebSocket server + MongoDB
│ ├── services/ # Anchor txs, refunds, social notify
│ ├── models/ # Match & chat schemas
│ ├── config/ # DB connection
│ ├── constants/ # Program ID, seeds, token list
│ ├── index.ts # WebSocket entry (port 8881)
│ └── package.json
│
├── fliparena-program/ # Anchor workspace (reference)
│ └── anchor-workspace/
│ ├── programs/coinflip/ # Rust program (unchanged on-chain name)
│ ├── tests/
│ └── cli/
│
└── readme.md
Create a MongoDB database (local or Atlas) and note credentials for .env.
cd fliparena-server
yarn installCreate fliparena-server/.env (see Configuration).
Place the program IDL at fliparena-server/program-idl.ts (gitignored). Copy from fliparena-program/anchor-workspace/target/types/coinflip.ts or your build artifacts.
yarn devWebSocket listens on port 8881.
cd fliparena-client
yarn installEdit fliparena-client/src/lib/constant.ts:
- Set
WS_HOSTtows://localhost:8881 - Set
RPCto your Solana cluster URL
yarn startOpen http://localhost:3000.
| Variable | Description |
|---|---|
RPC |
Solana RPC URL |
PRIVATE_KEY |
Base58 relayer wallet secret |
FEE_RECEIVER |
Platform fee recipient |
DB_USERNAME / DB_PASSWORD / DB_HOST / DB_NAME |
MongoDB credentials |
Example:
RPC=https://api.devnet.solana.com
PRIVATE_KEY=your_base58_secret_key
FEE_RECEIVER=YourFeeReceiverPublicKey
DB_USERNAME=your_user
DB_PASSWORD=your_password
DB_HOST=cluster0.xxxxx.mongodb.net
DB_NAME=fliparena| Constant | Purpose |
|---|---|
FLIPARENA_PROGRAM |
On-chain program public key |
WS_HOST |
WebSocket URL |
RPC |
Solana JSON-RPC endpoint |
fliparena-server imports the IDL from program-idl.ts. Regenerate after contract changes:
anchor idl parse -f target/idl/coinflip.json -o program-idl.tsConnect to WS_HOST. Messages are JSON: { "type": "<EVENT>", ... }.
| Type | Description |
|---|---|
OPEN_MATCH |
Build open-match tx |
ACCEPT_MATCH |
Build accept-match tx |
LIST_MATCHES |
List active matches (last 5 minutes) |
SUBMIT_MATCH_TX |
event: "create" or "join" — submit signed txs |
GET_WALLET_STATS |
Stats for a wallet address |
CHAT_SEND |
Send chat message |
LOAD_CHAT |
Paginated chat history (page) |
| Type | Description |
|---|---|
MATCH_OPENED |
Unsigned open tx + match metadata |
OPPONENT_JOINED |
Unsigned accept tx + matchPda |
MATCH_LIST |
Active matches array |
MATCH_ADDED |
New match broadcast |
OPPONENT_UPDATED |
Opponent joined |
PROCESS_UPDATED |
Tx processing state |
MATCH_SETTLED |
Match finished with result |
MATCH_EXPIRED |
Match expired / refunded |
WALLET_STATS |
{ win, games } for wallet |
CHAT_BATCH |
Chat messages |
ERROR |
Error string for UI toasts |
FlipArena keeps the existing deployed program unchanged:
- Program ID:
472RXUv8zUX7zm4LprxNsFQvAZYEpSGaY9EUE4akCvG6 - Instructions:
createGame,joinOpposite,handleGame(called internally by server) - PDA seeds:
coinflip_global_main,coinflip_game - Randomness: Orao Solana VRF
Only application-layer names (folders, models, WebSocket events, UI copy) were rebranded.
Default list in fliparena-server/constants/index.ts: SOL, USDT, USDC, BONK.
# Terminal 1 — server
cd fliparena-server && yarn && yarn dev
# Terminal 2 — client
cd fliparena-client && yarn && yarn startEnsure MongoDB is running, .env is configured, program-idl.ts exists, and WS_HOST / RPC match your setup.
Keywords: FlipArena, Solana, anchor, PvP betting, blockchain-game, heads-or-tails, mongodb, websocket