惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
宝玉的分享
宝玉的分享
量子位
V
Visual Studio Blog
罗磊的独立博客
Vercel News
Vercel News
B
Blog
J
Java Code Geeks
S
SegmentFault 最新的问题
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
GbyAI
GbyAI
G
Google Developers Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I open-sourced A full-stack, peer-to-peer coinflip bettin...
NinE X · 2026-06-27 · via DEV Community

NinE X

A full-stack, peer-to-peer coinflip betting game on Solana

A 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.

I 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.

Live demo / site: https://www.flip.is/

Why I built this

  • Learn full-stack Web3 game architecture (wallet + program + backend + UI)
  • Study provably fair randomness with on-chain VRF integration
  • Fork and customize a peer-to-peer on-chain betting room model

Most 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.

What it does

  • Create a room — Pick Head or Tail, set bet amount, choose SOL or SPL token.
  • Join a room — Browse open games in the live lobby and match against another player.
  • PvP coinflip — When two players are in the same room, the backend triggers on-chain resolution.
  • 2× payout — The winner receives double the bet (fees apply on-chain).
  • Room expiration — Open rooms older than 5 minutes with no opponent are expired and refunded automatically.
  • Portfolio stats — Win count and total games per wallet.
  • Wallet connect — players sign in with a Solana wallet
  • Peer-to-peer rooms — create or join head-to-head matches

Architecture at a glance

  • Wallet layer — users connect a Web3 wallet to sign transactions
  • On-chain program — Anchor/Rust logic for escrow, rooms, and settlement
  • Randomness — verifiable flip outcomes via Orao VRF on Solana
  • Real-time layer — WebSocket events push room and flip state to the UI
  • Persistence — MongoDB stores rooms, chat, and historical match data
  • Application layer — TypeScript backend/frontend tying on-chain and off-chain flows
User Wallet  →  On-chain Program  →  VRF / Settlement
                    ↓
              Backend (API + WebSockets)  →  MongoDB / state
                    ↓
                 Frontend UI (real-time)

Adjust the diagram to match your repo layout if components differ.

Tech stack

  • Solana
  • Anchor
  • TypeScript
  • MongoDB
  • WebSockets
  • Orao VRF
  • React

Quick start

git clone https://github.com/xxniiinxx/coinflip-casino.git
cd coinflip-casino

Setup steps:

  1. Install dependencies (see README — typically npm install or yarn)
  2. Copy .env.example to .env and fill in RPC, wallet, and API keys
  3. Run local validator or point to devnet/mainnet as documented
  4. Start the backend and frontend; connect wallet and create a test room

See the full README for environment variables, deploy scripts, and test commands: https://github.com/xxniiinxx/coinflip-casino

Video walkthrough

What to explore in the repo

  • Program / contract entrypoints and account models
  • API routes and WebSocket event handlers
  • Frontend wallet adapter and game room components
  • Tests, scripts, and deployment configs

Contributing

Issues and PRs are welcome. If this helped you learn something, a ⭐ on GitHub makes it easier for others to find.

Links


Disclaimer: Educational content only. Not financial advice. Gambling and trading involve risk; use responsibly and comply with local laws.

anchor #betting #blockchaingame #casino #coinflip #cryptocurrency