Welcome to Shall We Move, a fully on-chain multiplayer card game implemented on the Sui blockchain. This project leverages the unique features of the Sui blockchain to provide secure, transparent, and decentralized gameplay.
Immerse yourself in the game interface, crafted to provide a smooth and captivating card gaming experience with real-time multiplayer support.
- Overview
- Features
- Architectures
- Encryption
- Tech Stack
- Get Started
- Mini Poker: Instructions, Rules, and Hand Rankings
Shall We Move is a decentralized application (dApp) that brings the classic games of 2-card poker and 3-card poker to the Sui blockchain. All game functionalities, including card dealing, shuffling, and hiding, are executed on-chain using encryption and randomness to ensure fairness and transparency.
- Multiplayer Support: Play Blackjack with multiple players in real-time.
- On-Chain Execution: All game logic runs on the Sui blockchain, ensuring transparency and security.
- Encryption: Cards are encrypted to keep them hidden from other players.
- Randomness: Cards are distributed randomly to ensure fair play.
- Next.js + Typescript Frontend: A modern, responsive web interface for seamless gameplay.
ShallWeMove's smart contract encrypts and securely delivers cards 100% on-chain, with no backend. shallwemove's encryption goes through the following process
- The client generates its own asymmetric key.
- The client sends the public key of the asymmetric key generated by the client.
- The smart contract draws a random card from the card deck using Sui Randomness.
- The smart contract encrypts the card with the client's public key.
- the Client receives the encrypted card
- decrypts the encrypted card using the client's secret key.
As a result, the only data stored on-chain is the client's public key and the encrypted card. Even the process of drawing the card uses Sui's randomness, so no one can know the information on the card, and even the blockchain itself cannot know which card was given because the card information is volatile after the smart contract is executed.
- Frontend: Next.js, Typescript
- Blockchain: Sui
- Smart Contracts: Move language
There are two ways to run the project locally.
- Run with Docker container
- Run with pnpm
Installing Docker is required
git clone https://github.com/ShallWeMove/Overflow2024.git && cd Overflow2023/frontend
make # Create SSL Certficates
docker compose up -d
http://localhost
For more detailed settings, See Run project with pnpm
- Node.js (v18.17.0 or later)
- pnpm
- Sui Blockchain node (or access to a Sui node)
git clone https://github.com/ShallWeMove/Overflow2024.git
you should see the package address in the output after running the command below.
cd shallwemove
sui client publish
after update shallwemove/Move.toml
cd ../poker_logic
sui client publish
you should see the casino and lounge addresses in the output after running the command above. Use these addresses to create your casino and lounge on the Sui blockchain.
### create-casino
sui client call --package {package_address} --module cardgame --function create_casino --args {n_value_of_public_key} --gas-budget 1000000000
ex) sui client call --package 0xd10b25e4b34a013949d22666cf115cd01c2b0714585cd260122cb3e627893b63 --module cardgame --function create_casino --args 35263 --gas-budget 1000000000
### create lounge
sui client call --package {package_address} --module cardgame --function create_lounge --args {casino_id} {max_round} --gas-budget 1000000000
ex) sui client call --package 0xd10b25e4b34a013949d22666cf115cd01c2b0714585cd260122cb3e627893b63 --module cardgame --function create_lounge --args 0xd3b23a73870de6f5958e33fa18801757c826ee1dab6762bb412842fa9f8b233c 1 --gas-budget 1000000000
### add game table to lounge
sui client call --package {package_address} --module cardgame --function add_game_table --args {casino_id} {lounge_id} {ante_amount} {bet_unit} {game_seats} 0x0000000000000000000000000000000000000000000000000000000000000008 --gas-budget 1000000000
ex) sui client call --package 0xd10b25e4b34a013949d22666cf115cd01c2b0714585cd260122cb3e627893b63 --module cardgame --function add_game_table --args 0xd3b23a73870de6f5958e33fa18801757c826ee1dab6762bb412842fa9f8b233c 0x287ee1df5522907fe9aad6a47ff03dfa1b868cbb82c17118ea625140c63e7847 500 500 5 0x0000000000000000000000000000000000000000000000000000000000000008 --gas-budget 1000000000
- shallwemove package address
- casino object address
- lounge object address
- game_logic package address
cd frontend
and update the top line of src/config/config.ts
file with the following content:
const config: Config = {
core: {
packageId: '0xbb82f18ff31baf24223bac5176f2c272fdf296cfef5ef32b255af200f161b3ea', // shallwemove package id
},
games: {
twoCardsPoker: {
packageId: '0xae6c82857ae56d339ca54ac85de07900b215b9c49d293cff5eaaa74c8e33ca63', // game logic package id
objects: {
casinoId: '0x5b9d2b62c3a0a79341e24844e71947c5366ea3d078658485d39685e04745e1c2',
loungeId: '0xe88cc89eaee3d13315572b1b0679f58dbc031305776f32ffd84c33d9a5aba1d3',
}
},
threeCardsPoker: {
packageId: '0x2cddba646146b7e3964eed9b9905d15027555f583addd1e6bef4a86c275485c8', // game logic package id
objects: {
casinoId: '0x5b9d2b62c3a0a79341e24844e71947c5366ea3d078658485d39685e04745e1c2',
loungeId: '0x9344be522ec8dca0fad97735d9b7a27567482a95f69990745075193421fa493b',
}
},
},
};
pnpm install
pnpm dev
In contrast to traditional poker, which utilizes 5 cards, Mini Poker is played with only 2 cards, forming combinations to create hands (poker hands). Following the 2-card rule, players are given one card each, engage in betting, then receive the second card and proceed with another round before revealing their hands to determine the winner. When the game ends, the draw rule is applied, ensuring that players' cards remain undisclosed throughout the game.
- Connect your Sui wallet.
- In the wallet settings, set the Network to Testnet, as only Testnet is supported.
- If you don't have any Testnet Sui Tokens, click the "Request Testnet Sui Tokens" button.
- To join the game, click the "Enter Game" button on the homepage.
- Press the "Ante" button to indicate your intention to participate.
- The game requires at least 2 players to start and can accommodate up to 5 players.
- Once 2 or more players have joined and pressed the "Ante" button, the Manager can click the "Start Game" button to begin.
- Ante
- The mandatory initial bet placed at the beginning of the game to ensure active participation and discourage excessive folding without betting.
- It serves to encourage more proactive betting behavior.
- Check
- A privilege given to the player who either must bet the minimum amount or the first player to bet regardless of their hand.
- It allows them to pass their turn without adding more money to the pot.
- Bet
- The act of placing the first bet after card exchange or additional distribution.
- If no one bets, the round progresses with everyone checking, without further betting.
- Call
- Accepting the amount of money bet by the previous player.
- Accepting the amount of money bet by the previous player.
- Raise
- Accepting the previous bet and adding more to it.
- Accepting the previous bet and adding more to it.
- Fold
- Giving up the hand, resulting in the loss of any money bet before folding.
- Folding is used to minimize further losses when a player determines that their hand has little chance of winning.
- Royal Straight Flush: A combination of A and K cards of the same suit. It is the strongest hand.
- Back Straight Flush: A combination of A and 2 cards of the same suit. Depending on the rules, it may be recognized as the second strongest hand.
- Straight Flush: A combination of two consecutive numbers of the same suit. It is the third strongest hand.
- A pair consists of three cards with the same number or the same letter, such as J, Q, K.
- Royal Straight (Mountain): A combination of A and K cards with different suits. It is one of the strongest combinations among straight hands.
- Back Straight: It consists of A and 2 cards with different suits.
- Straight: A combination of two consecutive numbers with different suits. In mini poker, similar to three of a kind, this hand is considered higher than a flush.
- A flush consists of two cards of the same suit.
- A pair consists of two cards with the same number or the same letter, such as J, Q, K.
- The highest single card in a hand, not forming any particular combination. It does not contribute to any specific hand rank. An Ace (A) is the highest top card, and a 4 is the lowest.
- Royal Straight Flush: A combination of A and K cards of the same suit. It is the strongest hand.
- Back Straight Flush: A combination of A and 2 cards of the same suit. Depending on the rules, it may be recognized as the second strongest hand.
- Straight Flush: A combination of two consecutive numbers of the same suit. It is the third strongest hand.
- A pair consists of two cards with the same number or the same letter, such as J, Q, K.
- Royal Straight (Mountain): A combination of A and K cards with different suits. It is one of the strongest combinations among straight hands.
- Back Straight: It consists of A and 2 cards with different suits.
- Straight: A combination of two consecutive numbers with different suits. In mini poker, similar to three of a kind, this hand is considered higher than a flush.
- A flush consists of two cards of the same suit.
- The highest single card in a hand, not forming any particular combination. It does not contribute to any specific hand rank. An Ace (A) is the highest top card, and a 4 is the lowest.