Like any future pet father or mother, you’re probably wondering what you’re about to get yourself into. Luckily, we’re fluent in degeneracy / solidity and English, so let’s get started.
(Note: we’ll also be deploying to Etherscan soon and you’ll be able to read the full contract before mint as well.)
For this game, our main goal was to reduce the amount of gas you have to pay for this game. After extensively gas benchmarking, we ultimately ended up going with Azuki’s ERC721A implementation for this project as it drastically reduces batch mints and the nature of our game suits the implementation nicely (lots of minting, not very many transfers).
Some functions may look inefficient, but they’re purposely like that because those functions are what we(devs) call and what we(devs) pay gas for (essentially we’re taking some of that gas cost so it’s cheaper to play you the game). Keep this in mind as we go through the implementation.
First and foremost, we’d like to address the biggest question in the room: are my funds sifu or safu?
There’s a lot of rugs and shitty projects out there, so we built this contract with the refund functionality in mind. So if you mint an adorable pet and decide you can’t bare to watch him possibly die, you can refund your mint at any time before the games start.
Assuming the game hasn’t started and you’re the owner of the token, you’ll be able to refund in the “My Pets” section of the website. From there the following code will be ran:

In this code block, we buy back the pet from you, and pay you the MINT_PRICE. No hard feelings, we understand that sometimes it’s better to never love than have loved and lost.
Now you’ve decided to adopt your new best friend and given it a name (maybe it’s Gilbert). For minting, we wanted to minimize bad actors and shady things from going on. Therefore we use signature verification to prevent bots from minting our contract. Everyone must mint manually from our website in order for the transaction to succeed.

This isn’t a project built on FOMO, so we don’t have a max supply. Mint will be open only for 24 hours so no need to FOMO in. We’ve added a limit of 5 mints per mint() transaction but you can call mint an unlimited amount of times during the minting window, but that’s a lot of names to come up with 👀.

Each mint is 0.15 ETH, of which 70% will go into the prize pool for pets to win! Let’s make NFTs fun again 🤠.
Note: You can play the actual game on our website, but we’re breaking down what’s actually going on in behind the scenes on the smart contract side.
The game is decided by rounds. A round is marked by a feeding period opening or closing. So the we have a variable gameIndex which starts 0 when the game has yet to start (and increments as rounds are played). We plan to start the games some time around the 16th.

On that day we’ll call the toggleFeedingState() at some point during the day, triggering the first feeding period. Once this window is open your pet will be in a hungry. You’ll have to call feed() on your animal, in order keep him fed and happy. We’ll call toggleFeedingState() after a variable amount of time (which will be disclosed when we open the feeding window), and the feeding period will close. If you didn’t feed your animal, he’ll be dead, nooooo! If you fed him, congrats, you’re 2 rounds closer to the finish line.

In the contract we set a TOTAL_ROUNDS constant when we deploy the contract, so you’ll know exactly how many rounds you have to survive. For this genesis season, we’ll be doing a total of 20 rounds (roughly 10 days), so you’ll have to feed your pet at 10 distinct random times in order to make it to the finish line.
Once deployed, you’ll be able to see on Etherscan that on our contract has 20 total rounds. Don’t trust us, verify yourself :)
A core component of the game is feeding your pet. From the website you’ll be able to feed all your pets or a single pet in the “My Pets” section. We also use signature verification here so bots can’t monitor our contract transactions and auto submit feeding transactions. Everyone is on the same playing field and has the same duty to feed their pet.

Feeding costs 0.03 ETH per pet, of which 70% goes into the prize pool. As the game progresses, the prize pool grows as pets are fed!

You’ll be notified about feeding times through tweets and Discord (coming soon). Be Alert! Keep your pet Alive!
We made the smart contract in a way where it’s actually impossible for us to take all the funds from this game even if we wanted to.
After the 10 feeding periods are through, endGame() will be called which calculates how much ETH the winners’ pot will contain. Besides paying out the devs (who did something), it calculates the winners and uses this number to know how much each living pet should be paid out.

We can only call endGame() once, and our fees are built into this function that only runs a single time. You can see at the end of the function, the owner gets paid 30% of the pot and _withdrew gets set to true. Once withdrew_ == true, it’s impossible for devs to withdraw anymore funds from the contract, as it can’t be called again and the only remaining withdraw function is for surviving pets.
(Note: you’ll notice that endGame() is fairly gas inefficient with the looping, but this ultimately makes the game cheaper for you to play since we’re storing less variables whenever you mint/feed into storage. Since owner is the only one that can call this function, we’re perfectly happy fronting the gas to make everything else cheaper.)

After the game is over you’ll be able to claim your share of the pot from the website (which calls claimPrize), and you’ll see your share of ETH in your wallet :)
Anytime you ape into a contract without an established and GOAT’ed team (which we are working towards becoming), you’re exposing yourself to a number of risks. Let’s outline a few of them below and what we’re doing to minimize them.
The Rug. These are the projects that promise the world but deliver only the contract with functions that take all your ETH. Since we’re not a PFP project, we’re proud to offer people a refund for any minted ERC721A before the game starts. We believe Web3 consumers deserve the right to opt-out of projects and experiments if they get cold feet.
Tricky backdoors. We’ve designed this contract to really align our incentives when it comes to making money. The function that pays us(devs) is only callable once and immediately opens the payout() function for yourself. There also has to be a certain number of rounds played, no more and no less. The biggest risk we see here is that the devs (us) never call
endGame(), leaving the game in a state of limbo. But this would mean the ETH is trapped in the contract with no payouts for anyone. Because we stand to gain from ending the game, we think the incentives are fairly aligned there as well.A layer of centralization. This is the genesis version of this game and we wanted to build a fun and engaging game as quickly as possible, but also as safely as possible. We made trade offs but ultimately believe the choices were carefully chosen to deliver a fully functional version of this game that has aligned incentives and is engaging. If this game works out really well, we’re already thinking about season 2 on how to add more mechanics and remove any existing layers of centralization.
Honestly, we’re just builders and hope you all enjoy this game. We’re going to keep building and we appreciate your support :). If you learned something or have any questions, just tweet at us @SpartanTrainee and we’ll reply soon.

