ButtonGamev1 is an onchain game designed to give away 200k $DEGEN where the last player to press the button wins. There is a small fee to press the button. This fee is added to the giveaway pot.
ButtonGamev1 uses multiple onchain variables to determine the game state and endgame handling. All game variables are handled by the contract. All gameplay is dependent on confirmed transactions.
pot: Stores the current value of the pot.
blockTarget: Stores the target block number to determine the end of the game.
currentWinner: Stores the address of the current game winner.
endGameMet: Indicates whether the end game condition is met.
There are a few key values when it comes to ButtonGame.
1. The Pot: The current contract account balance. This will be transferred to the winner if the block target is reached.
2. The Block Target: The block target is set and updated each time the button is pressed (current block + 100). If the button is pressed while (current block >= block target) the game has ended and the tx will be rejected.
3. The Current Winner: This is the last player to press the button. If the block target is reached before another confirmed button press is recorded, this player will win the pot.
4. Free Play: 1 Free Play will be available to each of the first 69 unique wallets.
5. Play: Pressing the button will cost 69 $degen. 90% is added to the pot. 10% is directed to the team.