Playing CryptoKitties on the Blockchain

Kitty Hawk
9 min readFeb 23, 2018

--

When you play CryptoKitties, you’re usually visiting the cryptokitties.co website which acts as a front end to all the blockchain components of the game including your tokens (kitties) and the smart contracts that govern everything you can do with your kitties (short of naming them). But since the truth lives on the blockchain, that means you can continue to play even if the website goes down — or if you just woke up on the geeky side of the bed.

Don’t be confused, poor beautiful kitty with unreleased traits that I so want.

What does it mean to play CryptoKitties on the blockchain? It means that you can use various tools available for free on the internet to do all the things that the website normally handles for you. This is our primary toolbox, you’ll want to bookmark these resources:

https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#readContract

https://ethgasstation.info/

https://www.myetherwallet.com/#contracts

https://kittycalc.co/read

How do we use these tools? Let me tell you a little story…

Recently, I spent some time finding the perfect breeding partner for one of my kitties, using my favorite website of all time (and I am totally not biased whatsoever), which is a website I helped create: KittyCalc.co

KittyCalc.co will help you find and breed the perfect CryptoKitties.

There was only one problem — Kitty 504965 wasn’t mine.

After deciding she was the perfect mate for Cotter (503404), I entered a transaction to purchase her on the website. And then I waited, and waited….

Hope no one beats me to it!

Eventually I got tired of waiting and clicked “View Details” to find that the transaction was successful. Twi/Wasn/Gana/Apri/Sass was all mine, even if the website wasn’t ready to aknowledge that yet. But I bought this kitty to breed them, so how do I do that if the website doesn’t want to let me? I decided to plug into the Matrix and engage the Smart Contract!

But first, I wanted to make sure the Smart Contract agreed with my understanding of the situation. Enter: Etherscan

Etherscan is a tool that lets us explore the blockchain, and since our kitties live on the blockchain it lets us explore truths about our kitties. The link above goes directly to the CryptoKitties Read Smart Contract interface, which lets us ask very specific questions about specific accounts and kitties. What I wanted to know first was whether the blockchain agreed with me that both of my kitties are owned by me and were ready to breed (not currently resting or with child), so I entered my two kitty IDs on line 14 (canBreedWith) and pressed Query.

The truth is on the blockchain.

This resulted in a method Response of “true” — the blockchain knows my kitties are ready to breed together! The next tool our toolbox is My Ether Wallet, commonly called “MEW”

After following this link, I then selected the CryptoKitties contract from the drop down. My goal was to breed my kitties together using the smart contract directly, and the function that lets me do that is “breedWithAuto”.

You want to end up on a screen that looks a little something like this.

If this is all a little overwhelming or complicated, it might be helpful to watch Lucy’s video lesson on using My Ether Wallet. (Thanks for making the video, Lucy!)

As Lucy points out in the video, you rarely want to pay the default gas price for a transaction in CryptoKitties. So we have one more tool in our toolbox, which is Eth Gas Station.

Depending on how much of a hurry I’m in, I’ll usually pay just slightly over the Gas Price Std (Gwei) amount. Today I’m in luck and that amount is just 2 Gwei.

The two numbers we care about are the highlighted “2” (Standard) and “1” (Safe low) Gwei amounts at the top of the page.

Having verified what gas price I wanted to use, I went back to MEW and pressed the “WRITE” button, which brought up this scary dialog.

Warning! You can lose all your ETH if you let your RL cat walk on your keyboard here and then press a series of confirmation buttons.

No problem, I happen to know that when breeding using the smart contract I can just enter the current breeding fee (0.008 as I write this) as the Amount to Send and let the Gas Limit auto populate.

I decided to add an extra significant digit to the Gas Limit here just to show you what will happen later.

Click “Generate Transaction” and we’re almost there….

Those numbers still look good to me.

Click “Yes, I am sure! Make transaction.” and we’re almost there……

Even though I entered my own Gas Limit in the previous step, MetaMask chose its own Gas Limit. That’s fine, let’s leave this one alone.

Change that Gas Price to 2.1 and then press “SUBMIT” and we’re almost there………

Phew! Transaction submitted. Now I’m just waiting for a miner to pick it up and include it in a block.

Are we almost there yet? Thankfully Etherscan’s estimated confirmation duration of 1 hr 16 minutes is overly pessimistic here. In fact the transaction was being picked up by a miner right at this exact moment! Thanks, 2.1 Gas Price!

Since I have nothing better to do, I’m going to verify that the matronID listed under “InputData” is correct. Unfortunately, I only know my kitty’s ID number in “normal” decimal form and this matronID is listed in hex. Fortunately, the internet has tools for everything, including any number of online Hexadecimal to Decimal converters. (I’ll let you find one you like!)

Yep, that’s the kitty I bought to kick this whole thing off! I wonder if the front end has updated to show that I’m the new owner of kitty 504965 yet?

Did I pay way too much for this kitty? Can you really pay too much for purrfection?

Nope. And that “For sale” price continues to appear to drop. Yikes, hope nobody else tries to buy this kitty, because someone else beat them to it. It was me. I beat them to it.

Time to check on my transaction again.

Thanks to EthGasStation, I was able to find a Gas Price that confirmed super quickly and only cost $0.13!

Success! Almost there. Once this transaction has been processed, the smart contract will make some changes to my kitties. Specifically, it will put the sire on cooldown, stick a bun in the oven of my dame, and specify a particular block number where my new kitty can be born.

Is 504965 pregnant? Plug her ID into line 10 and check and… why, yes, she is!

If the website front end were working properly, this is where I’d see a nice little bun in the oven icon and timer on my kitty. But since it isn’t, I still want to know how long I need to wait for my new kitty to be born. That information lives in the blockchain!

getKitty is my favorite function here. Look at all that juicy data on my kitty!

Scrolling to the bottom of the ReadContract tab on that Etherscan link from above, I can enter my kitty ID in “getKitty” to get a bunch of information, including her gene sequence! Cool. But what I really care about now is when that baby will be born. That is shown here as “nextActionAt” which tells us the block number where my kitty can be born. But how is that number useful?

If we go to the homepage of Etherscan, we can easily see what block number has most recently been mined.

Look for “LAST BLOCK” on the left side of the blue section

Great, so I know that we’re on block 5066038, and that I need to be patient until block 5066117. But what does that really mean for me? I can see above that the last block took about 14 seconds to be mined. But is that a realistic estimate of how long blocks are taking right now? Lets look up some historical data while we wait for time to pass!

Etherscan has all kinds of information, including this Average BlockTime Chart. It does appear that 14 seconds is a pretty good estimate of average block time recently. Doing some simple math, it looks like I’ve got to wait a little over 18 minutes for my new kitty to be born. Since every tool I want exists on the internet, I Google for an online timer and Google itself offers me exactly what I want. I set the timer and watch as it ticks down.

Are we almost there yet?

Maybe I could be doing something more productive while I wait. Like watching other people on Discord complain as they wait.

Oh, hi Louie! Big fan, love the stream!

That was fun. Still 17 minutes to kill though. In case you’re wondering whether the Activity tab on the website reports actions you take when interacting directly with the smart contract, it does not. I still see the same message I started this process with.

Remember, the app takes a couple of minutes to receive the updates, so keep checking!

Finally, my computer starts making a loud noise at me thanks to the timer I set up. Once I find the right browser tab and shut the noise off, I see that my kitty should now have been born!

Lets verify that on Etherscan!

Last time we checked, isGestating was true and isReady was false. Progress!

To find my new kitty, I check my profile first in a fit of optimism. Sadly, there is no new kitty there for me to see. So instead I take a look at my MetaMask address because I’m going to need that for the next step.

503404 sired a baby and he doesn’t even know it.

Now I’m going to start checking “ownerOf” recently created Kitty IDs until I see my MetaMask address pop up. After checking a few kitties, I find it!

Let’s just take a look at that kitty on the website and….

You’ve got to be kitten me right now.

Yeah. I expected that.

Thankfully my favorite website in the whole world (and again, totally not biased. Like, not even a little bit. Nope!) has a tool that will help me figure out what my kitty looks like: KittyCalc.co/read

Yes, KittyCalc lets you check the genes of any kitty on the blockchain, even when the website doesn’t know it exists yet!

Back when I took this screenshot, we didn’t have official names for all the traits yet.

A Happygokitty, Simple, Cymric, Bananacream, Ganado with Twilightsparkle eye color? Now that is a beautiful kitty, even if I didn’t land that Sass eye shape. And all of this happened through the magic of the blockchain and a few awesome tools, proving that you can play CryptoKitties even without CryptoKitties.co!

In case you can’t just close your eyes and picture her, here is how my beautiful Gen 95 Arizona Diamond turned out.

This is really only scratching the surface of what you can do in the world of Cryptokitties using the blockchain. There are dozens of fun tools around that leverage the open nature of the blockchain to report interesting and useful data about CryptoKitties. You can track sales history, your own personal transaction history, or even buy a virtual hat for your kitty!

I love being able to collect and breed amazing kitties, but beyond that one of my favorite things about this game is that it’s helped me to learn so much about Etherium and blockchain technology in general. I love learning about the various tools and infrastructure that the crypto community has made available to interact with all this. I hope this article helped you learn a thing or two as well, and if you find that you still have any questions please feel free to drop them in a comment below or find me on Twitter or Discord.

Until next time, happy breeding — whether you use the website or interface with the smart contract directly!

--

--

Kitty Hawk

I draw pictures of hats for pictures of cats on the internet. My life is awesome. Co-creator of KittyCalc.co