I frequently push my recent sample smart contract for a better understanding of hunters!
WEB 3.0 GAME - ROCK PAPER SCISSORS DESCRIPTION:
- Enum for Moves: We use an enumeration to represent the possible moves in the game (Rock, Paper, Scissors).
- Mappings for Player Moves and Balances: The contract uses mappings to store the moves and balances of each player.
- Event for Game Played: An event is emitted when a game is played, indicating the moves of both players and the result.
- Play Move Function: Players can call this function to play a move (Rock, Paper, or Scissors).
- Determine Winner Function: Players call this function to determine the winner based on the moves they played. The winner's balance is increased, and the loser's balance is decreased.
- Get Balance Function: Players can check their current balance.
WEB 3.0 LOTTERY - DESCRIPTION:
- Manager: The manager is the address that deploys the contract and has special privileges, such as picking a winner.
- Participants Array: An array to store the addresses of participants who enter the lottery.
- Events: Events are emitted to log important actions (participant entering, winner selected).
- Restricted Modifier: A modifier to restrict certain functions to be called only by the manager.
- Enter Function: Participants can call this function to enter the lottery by sending ether.
- Pick Winner Function: The manager can call this function to randomly select a winner and transfer the entire contract balance to the winner.
- Random Function: A simple pseudo-random number generator based on block information.
- Get Balance Function: Participants or anyone can check the current balance of the lottery contract.
- Get Participants Function: Participants or anyone can check the addresses of participants.
FEEL FREE TO CONTACT ME:
Email: [email protected] Twitter: https://twitter.com/top_djinn Linkedin: https://www.linkedin.com/in/umer-yousuf/ WEB 3.0 Portfolio: https://shorturl.at/bsMOX WEB 2.0 Resume: https://shorturl.at/ABEJV