Welcome to the **Lotto Spin ** game, a decentralized, emoji-themed spin-to-win game. This project demonstrates the integration of Web3.js, Solidity smart contracts, MetaMask, and the Swisstronik Plugin. Players can stake ETH, guess an emoji, spin the wheel, and potentially win based on their guess. The game operates on the Ethereum blockchain.
- Blockchain Integration: Interact with Ethereum smart contracts using Web3.js.
- Emoji-based Game: Guess the correct emoji after each spin to win.
- Real-Time Wallet Interaction: Connect and authenticate with MetaMask.
- Swisstronik Plugin: Utilizes Swisstronik for enhanced blockchain functionality.
- Stake & Winnings: Manage your ETH stake and track your winnings.
-
Clone the Repository:
git clone https://github.com/your-username/lotto-spin.git cd lotto-spin
-
Install Dependencies:
npm install
-
Configure MetaMask: Ensure that MetaMask is connected to a test network and you have some test ETH in your account.
-
Start the Application:
npm start
The app will be available at
http://localhost:3000
.
-
Connect MetaMask: Click the "Connect Wallet" button to authenticate with MetaMask.
-
Stake ETH: Enter the amount of ETH you wish to stake and start the game.
-
Select an Emoji: Choose an emoji (π, π, π, or π) to guess.
-
Spin the Wheel: Click "Spin" and wait for the result. The game will randomly select an emoji.
-
Check Result: If the selected emoji matches the result, you win!
-
End Game or Withdraw: At any point, you can stop the game or withdraw your winnings.
- Frontend: React.js for UI
- Blockchain Interaction: Web3.js for blockchain communication
- Smart Contracts: Solidity smart contract for managing game logic
- Wallet: MetaMask for user authentication and transaction signing
- Plugin: SwisstronikPlugin for enhanced blockchain functionality
-
Game Logic:
startGame()
: Starts a new game by interacting with the smart contract.spin()
: Spinning mechanism that selects a random emoji and checks for a win.stopGame()
: Ends the game and resets the state.getWinnings()
: Withdraws the player's winnings.
-
UI Interaction: Players interact through a user-friendly interface that allows them to input their stake, choose an emoji, and spin the wheel.
Lotto Spin operates on a test network and uses test ETH only. This project is for demonstration purposes to showcase blockchain integration with games and is not intended for real-world use.
Enjoy the game and feel free to explore the code and smart contract logic!