Developing and running a game on the Ethereum blockchain #1

Ethergames
2 min readDec 30, 2017

--

In this series I will write about my experience developing a game on the Ethereum blockchain. It is called Realms of Ether — I know, a very creative name ;)

Somehow it reminds me of the times a few years ago, when browser based games started to emerge. At this time I learned programming all by myself with the help of the internet.

With the web 3 revolution happening right now, these small simple games are coming back. Also they are pushing to network to its limits, as CryptoKitties have proved it.

After setting up my development environment with ganache, truffle and MetaMask, I started coding the smart contract for Realms of Ether. It is nothing special. A storage contract for fortresses, buildings and troups, then libraries to connect those storage contracts to the main contract and as sugar on top of it some basic security mechanisms, so that only the user can interact with his fortresses, troups and buildings.

The next step was the client. I created a new project with preact-cli, installed web3.js and started working. After getting used the callback hell with web3.js prior to version 1.0, the game growed very quickly to where it is now. Thanks to opengameart.org I found some decent looking graphics throwing you back in the time of early browser based games.

Not the best, but I like it :)

After a lot of testing on a private blockchain, the time has come to go live. So I used truffle to deploy it to the main network and … I failed terribly.

Due to the 50 block limit, it stopped deploying and a lot of my ether was gone. But there was a solution. Linking the libraries in the bytecode was not easy, but possible. Now the next problem appeared. How do I use the constructor arguments in my main contract? After a lot of research I found a stackoverflow question, that saved my a$…ether. Converting the arguments to bytecode and append it to the contracts byte code.

Then things got scary. Deploying a very long file of 000036362fae236…0029 which I edited a lot manually. The amount of ether was low, but I tried it. And did it!!! It worked! Unbelieveable! And now Realms of Ether is on the main network.

This is only the beginning. Making it a open source project, updating the contracts, the client, … The journey has just started.

To be a part of it, you can start playing here: https://realms-of-ether.github.io/

All you need is ether and MetaMask.

Thank you for your attention and stay tuned for the next articles!

--

--

Ethergames

Developing and running games on the Ethereum blockchain