What a hamster and blockchain have in common

World’s first marble race platform on the Blockchain. Powered by smart contracts. And a pet hamster. 🐹

What’s not to love about hamsters — they are tiny, cute, can be tamed and some people even craft them sophisticated miniature worlds and feed them miniature burritos.

a burrito eating hamster (not Mia)

On the other hand we have blockchain — a technology invented by the infamous Satoshi Nakamoto which is used for transferring value over the internet, completely outside the traditional banking system. But how do the two fit together? Let me explain.

A small hamster with a big dream 🐹

It all started with pet hamster Mia with a simple idea: “Let’s carry out online marble races and stream them live”, she whispered into my ear.

pet hamster Mia

“BUT, wouldn’t it be more interesting if the viewers could actually bet on which marble would win the next race?”, I asked her. She agreed but went on, saying: “I like it. But this comes with a series of complications. First of all, how do we guarantee that the races are provably random?”

Provably fair randomness is not easy to achieve and usually requires complex mathematical formulas that are hard to understand, even for technical-minded people. And if you don’t understand it, you don’t trust it.

While I was still groping in the dark Mia suddenly shouted: “I got it! There is a way to make it provably fair but easy to understand! We’ll just take my movements and relay them unto the race track. This way, we can achieve real-world randomness.”.

“Perfect,”, I responded, “but there are further open questions… How can we prove the viewer that the livestream is actually live? And what’s the best way to handle the bets in a transparent and safe manner?”

Mia and me went on and finally came up with the following stack to achieve all the critical requirements:

The mia.bet stack

Mia moves the spinners in an unpredictable manner

As we know, real randomness can’t be created in computer systems without the input of any physical real-world process. While this is an important caveat in cryptography it is quite similar in the case of marble races. So in order to bring real-world randomness unto the blockchain we had to add a real-world component that is unpredictable. Mia was totally into it from the very beginning so we decided to process her movements when she’s running in her wheel. The energy would then mechanically be forwarded to the spinners that are installed on the racetrack.

Entropy generation and randomized influence on the race

ETH Blockhash representation

We can now guarantee provably fair marble races, fine. But is the stream really live? What stops us from (in this very order)

  1. pre-recording the video of a marble race,
  2. placing a bet on the winning marble and finally
  3. streaming the video while claiming it is live?

Our conscience, of course, but since we know, that this won’t be enough for many of you out there (and rightfully so) we had to come up with a real-time component that can be embedded into the system. And what’s better suited than the respective id of the most recent Ethereum block which is updated every ~15s? We added 8 movable pegs unto the race track that represent the first Byte of the current respective block hash. The chance of accidentally guessing the correct combination once is therefore very tiny.

The movable pegs represent the first 2 Bytes of the current Ethereum block hash

Guessing it multiple consecutive times becomes almost impossible. You now learned about the most important mechanical components and the core ideas but how can they be linked together?

One smart contract to rule them all

Finally it all comes together in Mia’s smart contract that is deployed unto the Ethereum blockchain. While it contains all the associated core logic, it also acts as the counterparty that accepts and processes bets and finally pays out the jackpot after each round to the players that correctly anticipated the winning marble.

The contract knows 4 main states: Seeding, Accepting Bets, Race in Progress and Paying out. In case everything goes wrong there is a 5th state Refunding to make sure your funds are always safe when betting.

smart contract states


Mia & the Marbles is a novel and innovative platform for online marble races that are provably fair, provably live and feature betting, powered by pet hamster Mia and backed by Blockchain technology. We always value your feedback. We’d appreciate any comments here on Medium. You can also find us on Twitter, Telegram and Discord.

Hamster. Host of world’s first marble racing platform. Opinions are my owners’. https://mia.bet