{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiaxj6ht7fzf3srlgbqxbttnnapqbwjfiupdvjeyeghg2wrt5dk22u",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mpbsviqndgd2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreif3dn3dkec6cuc2rjelejhcokdp5xt3gmuzemhtomvixadeyrxvsq"
},
"mimeType": "image/webp",
"size": 1136
},
"path": "/xniiinx/i-open-sourced-a-full-stack-peer-to-peer-coinflip-betting-game-on-solana-20bf",
"publishedAt": "2026-06-27T15:35:31.000Z",
"site": "https://dev.to",
"tags": [
"solana",
"web3",
"typescript",
"anchor",
"coinflip-casino",
"https://www.flip.is/",
"https://github.com/xxniiinxx/coinflip-casino",
"Coinflip Casino on Solana tutorial",
"Coinflip Casino on Solana",
"https://www.youtube.com/watch?v=B0pLXF-sOuo"
],
"textContent": "# A full-stack, peer-to-peer coinflip betting game on Solana\n\nA full-stack, peer-to-peer coinflip betting game on Solana. Players connect a wallet, create or join on-chain game rooms, 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 backend tracks rooms, chat, and match history in MongoDB.\n\nI open-sourced coinflip-casino for developers in **Solana / Anchor smart contract development**. This post walks through what it does, how the pieces fit together, and how to run it locally.\n\n**Live demo / site:** https://www.flip.is/\n\n## Why I built this\n\n * Learn full-stack Web3 game architecture (wallet + program + backend + UI)\n * Study provably fair randomness with on-chain VRF integration\n * Fork and customize a peer-to-peer on-chain betting room model\n\n\n\nMost tutorials stop at a smart contract or a UI mockup. I wanted a **complete vertical slice** — wallet flow, on-chain logic, backend state, and a responsive frontend — so you can study or fork a production-shaped codebase.\n\n## What it does\n\n * **Create a room** — Pick Head or Tail, set bet amount, choose SOL or SPL token.\n * **Join a room** — Browse open games in the live lobby and match against another player.\n * **PvP coinflip** — When two players are in the same room, the backend triggers on-chain resolution.\n * **2× payout** — The winner receives double the bet (fees apply on-chain).\n * **Room expiration** — Open rooms older than **5 minutes** with no opponent are expired and refunded automatically.\n * **Portfolio stats** — Win count and total games per wallet.\n * Wallet connect — players sign in with a Solana wallet\n * Peer-to-peer rooms — create or join head-to-head matches\n\n\n\n## Architecture at a glance\n\n * **Wallet layer** — users connect a Web3 wallet to sign transactions\n * **On-chain program** — Anchor/Rust logic for escrow, rooms, and settlement\n * **Randomness** — verifiable flip outcomes via Orao VRF on Solana\n * **Real-time layer** — WebSocket events push room and flip state to the UI\n * **Persistence** — MongoDB stores rooms, chat, and historical match data\n * **Application layer** — TypeScript backend/frontend tying on-chain and off-chain flows\n\n\n\n\n User Wallet → On-chain Program → VRF / Settlement\n ↓\n Backend (API + WebSockets) → MongoDB / state\n ↓\n Frontend UI (real-time)\n\n\nAdjust the diagram to match your repo layout if components differ.\n\n## Tech stack\n\n * Solana\n * Anchor\n * TypeScript\n * MongoDB\n * WebSockets\n * Orao VRF\n * React\n\n\n\n## Quick start\n\n\n git clone https://github.com/xxniiinxx/coinflip-casino.git\n cd coinflip-casino\n\n\n**Setup steps:**\n\n 1. Install dependencies (see README — typically npm install or yarn)\n 2. Copy .env.example to .env and fill in RPC, wallet, and API keys\n 3. Run local validator or point to devnet/mainnet as documented\n 4. Start the backend and frontend; connect wallet and create a test room\n\n\n\nSee the full README for environment variables, deploy scripts, and test commands: https://github.com/xxniiinxx/coinflip-casino\n\n## Video walkthrough\n\n * Coinflip Casino on Solana tutorial — How to set up and run coinflip-casino step by step\n * Coinflip Casino on Solana — Coinflip Casino on Solana — architecture and demo walkthrough\n\n\n\n## What to explore in the repo\n\n * Program / contract entrypoints and account models\n * API routes and WebSocket event handlers\n * Frontend wallet adapter and game room components\n * Tests, scripts, and deployment configs\n\n\n\n## Contributing\n\nIssues and PRs are welcome. If this helped you learn something, a ⭐ on GitHub makes it easier for others to find.\n\n## Links\n\n * **Video:** https://www.youtube.com/watch?v=B0pLXF-sOuo\n * **GitHub:** https://github.com/xxniiinxx/coinflip-casino\n * **Website:** https://www.flip.is/\n\n\n\n_Disclaimer: Educational content only. Not financial advice. Gambling and trading involve risk; use responsibly and comply with local laws._\n\n# anchor #betting #blockchaingame #casino #coinflip #cryptocurrency",
"title": "I open-sourced A full-stack, peer-to-peer coinflip betting game on Solana"
}