A professional, decentralized coinflip game built on Solana blockchain. Place bets on heads or tails and double your SOL or lose it all!
- Decentralized Gaming: Built on Solana blockchain with smart contracts
- Fair & Transparent: Results determined by on-chain slot numbers
- Multiple Bet Sizes: Choose from 0.05, 0.1, 0.25, 0.5, 1, or 2 SOL
- Real-time Updates: Live transaction history and game results
- Secure Wallet Integration: Support for Phantom, Solflare, Slope, and more
- Modern UI/UX: Beautiful, responsive interface with smooth animations
- Transaction History: View recent plays and results
This project consists of three main components:
- Built with Anchor framework (Rust)
- Handles game logic, randomness, and fund management
- Program ID:
G9H8d5s4cRKXUbiEg6XVSNHKiZXCEYMZw4WcN4YW4iUp
- Next.js 14 with React 18
- TypeScript for type safety
- Solana wallet adapter integration
- Real-time UI updates
- Express.js server
- Socket.io for real-time updates
- Transaction monitoring and history
- Node.js 18+ and npm/yarn
- Rust and Anchor CLI (for contract development)
- Solana CLI tools
- A Solana wallet (Phantom, Solflare, etc.)
git clone https://github.com/yourusername/s7ns-coinflip.git
cd s7ns-coinflipcd frontend
npm install
# or
yarn installcd ../backend
npm install
# or
yarn installcd ../contract
npm install
# or
yarn installUpdate frontend/src/contexts/type.ts with your RPC endpoint:
export const RPC_MAINNET = "your-mainnet-rpc-endpoint"
export const RPC_DEVNET = "your-devnet-rpc-endpoint"
export const RPC_CURRENT = RPC_MAINNET; // or RPC_DEVNETCreate a .env file in the backend directory:
PORT=3002
MONGODB_URI=your-mongodb-connection-string
SOLANA_NETWORK=your-solana-rpc-endpointUpdate contract/Anchor.toml with your wallet path and network settings.
Frontend:
cd frontend
npm run dev
# or
yarn devBackend:
cd backend
npm run dev
# or
yarn devFrontend:
cd frontend
npm run build
npm startBackend:
cd backend
npm run build
npm start- Connect Wallet: Click "Select Wallet" and connect your Solana wallet
- Choose Side: Select Heads or Tails
- Set Bet Amount: Choose your bet size (0.05 - 2 SOL)
- Place Bet: Click "Double or nothing" to start the game
- Wait for Result: The coin will flip and reveal the result
- Win or Lose:
- Win: Double your bet amount is added to your claimable rewards
- Lose: Your bet amount is lost
- Claim Rewards: Click "Claim" to withdraw your winnings
- All game logic is executed on-chain via Solana smart contracts
- Results are determined by blockchain slot numbers (provably fair)
- Funds are held in program-derived addresses (PDAs)
- Only the contract owner can withdraw from the vault
The game uses different win probabilities based on bet size:
- 0.05, 0.1 SOL: ~47.5% win rate
- 0.25, 0.5 SOL: ~40% win rate
- 1 SOL: ~25% win rate
- 2 SOL: ~16.67% win rate
Results are determined by: slot_number % 2 == chosen_side with additional modifiers for different bet sizes.
- Blockchain: Solana
- Smart Contracts: Anchor Framework (Rust)
- Frontend: Next.js 14, React 18, TypeScript
- Backend: Express.js, Socket.io, TypeScript
- Wallet Integration: @solana/wallet-adapter
- Styling: SCSS, Material-UI
- State Management: React Hooks
s7ns-coinflip/
├── contract/ # Solana smart contract (Anchor)
│ ├── programs/
│ │ └── coinflip/
│ ├── tests/
│ └── migrations/
├── frontend/ # Next.js frontend application
│ ├── src/
│ │ ├── components/
│ │ ├── contexts/
│ │ ├── pages/
│ │ └── styles/
│ └── public/
├── backend/ # Express.js backend server
│ └── src/
└── README.md
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Telegram: @moooncity
This is a gambling application. Please gamble responsibly. Only bet what you can afford to lose. The developers are not responsible for any losses incurred while using this application.
- Solana Foundation for the amazing blockchain
- Anchor team for the developer framework
- All the open-source contributors
Built with ❤️ on Solana