Skip to content

Anchor Based Coinflip Game #14

Open
Kali-Decoder wants to merge 4 commits intoaarjn:mainfrom
Kali-Decoder:anchor-coinflip
Open

Anchor Based Coinflip Game #14
Kali-Decoder wants to merge 4 commits intoaarjn:mainfrom
Kali-Decoder:anchor-coinflip

Conversation

@Kali-Decoder
Copy link
Copy Markdown

🪙 Coinflip Game (On-chain Randomness)

🚀 Overview

This PR introduces a Coinflip betting game built on Solana using Anchor.
Users place a wager and guess Heads/Tails, and the outcome is determined using verifiable on-chain randomness.


✨ Features

  • Initialize player state with wager config
  • Users place bets with a coin flip guess
  • Funds are securely held in an escrow account
  • Fair settlement with win/lose logic
  • Winners receive 2x payout, losers lose wager
  • Safe SOL transfers using CPI

🎲 Randomness

  • Integrated Switchboard On-Demand Randomness
  • Uses RandomnessAccountData to fetch verifiable randomness :contentReference[oaicite:0]{index=0}
  • Ensures:
    • No manipulation by owner or user
    • Result tied to a specific slot (commit-reveal style)
    • Fair and transparent outcome generation

🧪 Gameplay Flow

  1. User initializes account
  2. Places a bet with a guess
  3. Randomness is committed
  4. Flip is settled using revealed randomness
  5. Rewards distributed if guess is correct

✅ Outcome

  • Fully on-chain, trustless coinflip game
  • Verifiable randomness ensures fairness
  • Ready for UI integration and scaling

@aarjn
Copy link
Copy Markdown
Owner

aarjn commented Mar 22, 2026

please remove the dice pool game program from this. since there is already an open PR for it

@Kali-Decoder
Copy link
Copy Markdown
Author

I check Closed pRS also there is not dice pool like game pr or folder
And this is Coinflip PR

@aarjn
Copy link
Copy Markdown
Owner

aarjn commented Mar 22, 2026

Screenshot 2026-03-22 at 6 18 56 PM

I mean this. Its better to have a single program in a PR.

@Kali-Decoder
Copy link
Copy Markdown
Author

I have maintained separate branches in my fork because both repositories represent different simple game implementations.

Keeping them in different branches helps ensure proper organization, avoids conflicts, and allows independent development and tracking for each game.

@aarjn
Copy link
Copy Markdown
Owner

aarjn commented Mar 22, 2026

Keeping them in different branches helps ensure proper organization, avoids conflicts, and allows independent development and tracking for each game.

yeah, you are right. that's why i asked to remove anchor-dicepool-game from this PR. since there is #12 for it

bug : solve testcases & added readme
@Kali-Decoder
Copy link
Copy Markdown
Author

Works I Closed Dice pool PR

@aarjn
Copy link
Copy Markdown
Owner

aarjn commented Mar 22, 2026

No need to close it. I said remove anchor-dicepool-game from this PR. Keep 2 PR for 2 Programs. Its fine for now I will review from this PR itself.

@Kali-Decoder
Copy link
Copy Markdown
Author

Works Review Let me know

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test cases are failing

(Use `node --trace-warnings ...` to show where the warning was created)


  sb-randomness-coinflip
    1) "before all" hook for "Initializes player account"


  0 passing (5ms)
  1 failing

  1) sb-randomness-coinflip
       "before all" hook for "Initializes player account":
     TypeError: Cannot read properties of undefined (reading 'load')
      at /Users/arjunc/Documents/solana/solana-programs-list/anchor-coinflip/tests/coinflip.ts:30:39
      at Generator.next (<anonymous>)
      at /Users/arjunc/Documents/solana/solana-programs-list/anchor-coinflip/tests/coinflip.ts:31:71
      at new Promise (<anonymous>)
      at __awaiter (tests/coinflip.ts:27:12)
      at Context.<anonymous> (tests/coinflip.ts:29:21)
      at processImmediate (node:internal/timers:505:21)



error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants