Writing the Contract
This section dives into the heart of Clown Beatdown — the shielded smart contract that powers its functionality. You'll start by building the secrets pool using shielded storage, then implement the stamina system and the robbery mechanic, before adding rounds, resets, and contributor-based access control. By the end of this section, you'll have a fully functional, round-based ClownBeatdown contract that is secure, fair, and replayable.
What You'll Learn
In this section, you'll:
Define a pool of shielded secrets using
sbytesand a shielded index usingsuint256.Build the stamina bar, the protective layer that guards the secrets, and implement a
hit()function to reduce it.Add a
rob()function to reveal a randomly selected secret to authorized contributors.Implement a reset mechanism to restart the game for multiple rounds.
Track player contributions in each round, ensuring that only contributors can rob the clown.
Overview of Chapters
You'll define the secrets pool using shielded storage (sbytes) and a shielded index (suint256), and implement an addSecret() function to populate it. This chapter introduces shielded writes.
Learn how to build the stamina system, which protects the secrets from being accessed prematurely. You'll implement the hit() function to reduce stamina and the rob() function to reveal a secret once conditions are met.
This chapter introduces a reset mechanism to enable multiple rounds of gameplay. You'll track contributions per round and ensure that only players who helped knock out the clown in a specific round can rob it. This chapter introduces signed reads.
Last updated

