Back to Projects
TypeScriptReactNext.js+8 more

Solana Coin Flip

On-chain inspired coin flip betting game built on Solana with wallet integration and backend verification.

Overview

FlipFi is a Web3 betting game where users connect their wallet, choose between heads or tails, and place a bet using SOL.

The game combines on-chain transactions with backend verification to ensure that every bet is backed by a real blockchain transaction. Once a user submits a bet, the transaction signature is validated server-side, and the result is determined.

Winnings are distributed based on the outcome, with successful bets returning nearly 2x the wager after platform fees.


Architecture

The system follows a hybrid Web2 + Web3 flow:

  1. User connects a Solana wallet
  2. User selects heads or tails and enters a bet amount
  3. A transaction is created and sent to the Solana network
  4. The transaction signature is sent to the backend
  5. Backend verifies the transaction via RPC
  6. Game result is generated
  7. Outcome and transaction details are stored in PostgreSQL
  8. If the user wins, payout is processed
  9. Recent transactions are displayed in the UI

Key Features

Wallet Integration

  • Solana wallet connection using Wallet Adapter
  • Seamless transaction signing experience
  • Real-time wallet interaction

Betting Mechanism

  • Choose between heads or tails
  • Place bets in SOL
  • Transparent input-driven gameplay

Transaction Verification

  • Backend verifies transaction signatures via RPC
  • Ensures bets are legitimate before processing
  • Prevents fake or replayed submissions

Game Logic

  • Randomized outcome generated on backend
  • Win condition returns ~2x reward minus fees
  • Loss results in forfeited bet

Database & Persistence

  • PostgreSQL used for storing:
    • Game results
    • Transaction signatures
    • Bet amounts
  • Displays last 10 recent transactions for transparency

Real-Time UI

  • Instant feedback on game results
  • Recent activity feed
  • Clean and responsive interface

Limitations & Improvements

  • Game randomness is currently handled off-chain via backend
  • This introduces trust assumptions

Planned Improvements:

  • Move randomness and result generation fully on-chain using a custom program
  • Use a Solana program for provable fairness
  • Integrate verifiable randomness (e.g. VRF)
  • Automate payouts via smart contract logic

Why I Built This

  1. To understand how wallet integrations actually work beyond theory
  2. To learn the full lifecycle of a Solana transaction
  3. To bridge on-chain actions with backend validation
  4. To explore real-world Web3 dApp architecture
  5. To get hands-on with building a complete betting system end-to-end

Developed by Shoumik Daterao
© 2026. All rights reserved.