paint-brush
How I Spent One Week Giving Birth to Pregnant Crypto Kittiesby@dominiek
2,265 reads
2,265 reads

How I Spent One Week Giving Birth to Pregnant Crypto Kitties

by Dominiek Ter HeideMarch 22nd, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

It was the second week of December. Most people had holiday on their minds and the hodlers were in ecstasy because <a href="https://hackernoon.com/tagged/bitcoin" target="_blank">bitcoin</a> had just popped $15K. Life was good. Everyone around me was talking about Crypto Kitties, and my coworker was elaborating with theatrical arm gestures on the genetic breeding of non-fungible assets on the Ethereum <a href="https://hackernoon.com/tagged/blockchain" target="_blank">blockchain</a>. In other words, it was a normal day in crypto land.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - How I Spent One Week Giving Birth to Pregnant Crypto Kitties
Dominiek Ter Heide HackerNoon profile picture

It was the second week of December. Most people had holiday on their minds and the hodlers were in ecstasy because bitcoin had just popped $15K. Life was good. Everyone around me was talking about Crypto Kitties, and my coworker was elaborating with theatrical arm gestures on the genetic breeding of non-fungible assets on the Ethereum blockchain. In other words, it was a normal day in crypto land.

After deciding that yes, it is a great idea to diversify my assets to include virtual cats, I bought some and started breeding. My coworker was way ahead of me and was running quite the breeding operation by this time. But he encountered a problem that many people had during the Crypto Kitty boom of 2017 — his pregnant cats would not give birth.

You see, the gestation period of a Crypto Kitty is dependent on its genes. Some of them take hours, some take days. But it seemed that many cats were not giving birth on time. There was a flaw in the system.

Breeding Crypto Kitties

After scouring the deep corners of Reddit my coworker found the solution: Call the giveBirth() function on the Crypto Kitties smart contract.

Follow the white rabbit.

The Anatomy of a Crypto Kitten

It’s important to understand that any state change inside an Ethereum smart contract requires a transaction where Ether — aka “Gas” — is spent. Every instruction executed inside the Ethereum Virtual Machine costs a certain amount of Gas. This means that in practice all execution is finite. There are no background processes on Ethereum.

A pregnant Crypto Kitten has a bunch of internal states to it:

Internal Ethereum State of a Crypto Kitten

For us in the Crypto Kitty Midwifery business, the most important attribute here is nextActionAt. This variable determines when a cat is supposed to give birth. The time is specified as a future block number. Ethereum has a new block number every 4–20 seconds.

Now, the only way for a cat to give birth is for someone — anyone — to call the giveBirth() function.

The giveBirth() function will give a small ~$4 bounty to anyone who calls that function…

WAIT WHAT WAS THAT?

FREE MONEY?

Delivering Overdue Kittens

This is the point where all normal productivity went out the window. I quickly created a skeleton dApp and my first task was building a system that could scan for pregnant Crypto Kitties that were overdue for giving birth.

The Pregnant Target Finder

We gave birth to many cats this way, but quickly realized that an increasingly smaller set of overdue cats were available. We suspect this was because someone had fixed “the script” that gives birth automatically to cats that are due.

It was time to bring out the big guns and beat “the script”.

Predictive Crypto Kitten Midwifery

We quickly upgraded the kitten scanner to include cats that were due in the future. We would then index these cats and organize them by future Ethereum blocks.

The Long Tail of Pregnant Crypto Kittens

At this point, my wife was wondering what had happened to her husband and why he was not doing any of his parenting duties. Strangely, a rational explanation of what I was doing did not help my case.

The next step was making sure that the giveBirth() function was called at the right moment. This meant making sure a local Ethereum client is synced and paying close attention to the current block. Being the first one to call giveBirth() will result in a $3 profit, however, calling it too late or too early will result in a loss of $0.30 due to spend transaction fees (Gas).

The Betting Interface

When there’s a lot of traffic on the Ethereum chain, it becomes quite challenging to time the giveBirth() bets. The right gas price is needed and the transactions need to be created before the target Ethereum block. Nevertheless, it seemed that the system was working: it was making about $100 per hour without intervention. It was time to go to bed and make money while sleeping.

That sweet green row of a profitable birth!

At 4am I was awoken by my inner capitalist and walked to my laptop to check the loot. A sea of red. At some point during the night all bets started failing.

It turns out that due to the variable traffic on-chain, continuous adjustment is needed to time the giveBirth() transactions.

I spent the following days trying to optimize the “autopilot” functionality to increase the hit rate, but I gradually became aware of something hiding in the data patterns:

I was not alone.

It became clear that other people — probably smarter and more patient than me — were also in the midwifery business. Over the next days the gas prices had to be set higher and higher, which resulted in lower and lower profits.

I was out.

And for Crypto Kitties, the market had solved giveBirth() in the optimal way.

Amazing.

Conclusion

This experiment revealed to me the true power of blockchain. Even though the mechanics of blockchain are simple, the big idea hiding in blockchain is that economics are now programmable. These “tokenomics” provide very pure monetary rewards to perform certain actions. The upside can be so big that tremendous resources are spent by the market to automate certain behaviors. In software, this is very different than the voluntary open source community contributions of the past. Tokenomics provide economic incentives on a micro-level and they inject a big dose of capitalism into self organizing networks.

But it is still early days for blockchain and tokenomics. On a practical level, every capitalist business strives to become a monopoly. In the words of Peter Thiel — too much competition is bad for business. It’s a race to zero margins. This experiment has shown that this can happen very rapidly, although to be fair I could’ve stepped up my game and I would be running the biggest Crypto Kitten midwifery farm today.

And like any powerful technology, they can be used for both good and bad purposes. It’s only a matter of time for a network with “evil” tokenomics to cause harm. There are some very scary scenarios imaginable involving the wrong kind of tokenomics.

A lot of experimentation is needed to find out how the power of tokenomics can be used to improve software networks to benefit human organizations.

Here’s to more experimentation.

Special thanks to Cameron Thacker, Josh Jones-Dilworth and Russell Moench for their input on this article.