This is a decentralized PvP (Player vs. Player) coin flip game built on the Sui blockchain. Players can create new games by placing a bet, and other players can join these games to compete for the pot.
Website: https://coinflip-pvp.netlify.app/
- Decentralized Gameplay: All game logic is handled by a Sui smart contract, ensuring fairness and transparency.
- Player vs. Player: Create a game or join an existing one to play against others.
- SUI Betting: Use SUI tokens to place bets.
- Asynchronous Prize Claiming: Winners receive a
PrizeVaulttoken, which they can use to claim their winnings at any time. - Built with Next.js: A modern, performant web application built with React and Next.js.
The coin flip game has a simple and clear workflow:
- Create a Game: A player can start a new game by specifying a bet amount in SUI. This action deploys a
Gameobject on the Sui network, making it available for other players to join. - Join a Game: Another player can browse the list of available games and join one by matching the original player's bet.
- The Flip: When a second player joins, the smart contract's
flipfunction is executed.- A winner is determined pseudo-randomly using the transaction's digest.
- A small house fee (1%) is deducted from the total pot.
- The remaining amount is placed into a
PrizeVault. - The
PrizeVaultis transferred to the winner.
- Claim Your Prize: The winner can navigate to the "Pending Rewards" section of the dApp and execute a transaction to claim the SUI from their
PrizeVault.
The core logic is powered by a Sui smart contract written in Move. You can find the source code in contracts/coin_flip/sources/coin_flip.move.
create_game: Initializes a new game session.flip: Pits two players against each other and determines a winner.claim_prize: Allows the winner to withdraw their earnings.
First, you need to have the Sui wallet extension installed in your browser and have some SUI tokens on the Testnet.
Then, run the development server:
npm run devOpen http://localhost:3000 with your browser to see the result.
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.