How decentralized does blockchain gaming need to be?

Kingdoms Beyond
KingdomsBeyond

--

A bit about myself, I have been working on a passion project for about a year and a half. The idea that I had in mind was a completely decentralized blockchain RPG where the users will be in control of building the game for new users. I wanted to distribute the power from the game companies on to the users. I am writing this article to help explain to upcoming blockchain game developers some of the common pitfalls that I fell into while developing my game.

I first started learning about smart contracts after seeing the success of the CryptoKitties project. From there, I went on to creating my own smart contracts as a base foundation for my game. Although picking up the ability to write smart contracts was straight forward as I came from a software development background, there are a couple of limitations.

  1. Randomness is extremely difficult to program in smart contracts.
  2. Each transaction must happen in a single order. This poses the problem if you wanted your game to be extremely performant, real time gameplay is essentially impossible.
  3. Smart contract functions cost real money to perform. Storing data is especially expensive.
  4. As a developer, it is impossible to fix a smart contract if a bug was found. Either the developer needs to migrate their code or make it more centralized by introducing an upgradable component.

Definition of Decentralized Gaming

Although the concept of blockchain gaming is still in its infancy, there is a shared vision for the future. There are certain traits that are predominant.

Ownership

Currently, games that offer trading offer it only through their servers. The majority of games make it extremely difficult to trade accounts or items earned. Users must go through 3rd party markets and have the risk of having their account banned.

Users have true ownership over their items and do not need to jump through hoops to trade, sell, or gift it. There is a financial incentive since users can trade their hard earned assets for crypto assets.

Transparency

In many games, the drop rates are not publicly published. Even if they were, there is nothing in place to stop them from changing it server side.

All smart contract code is visible to everyone which reduces doubt over a fair system.

Empowers users

Currently, game companies are in charge of distribution of assets, balancing, and updates. As a result, many users feel that they have no voice.

By employing a decentralized system, governance systems can be formed, enabling gamers to be in charge of content, distribution, and balancing.

Decentralization as a Spectrum.

The few blockchain games today have defined a spectrum of decentralization that I have defined in the following categories.

Ownership Based

These games only track the ownership of the tokens in the game and do not store any other data.

Decentraland is a great example. It is essentially impossible to build a 3d world in the Ethereum blockchain. Thus, by giving ownership to the user for a plot of land in a finite world, users can find value in the scarcity and location of each plot.

Gods Unchained is another great example. They have chosen to only store the ownership over the cards in their smart contracts. What this means is that the metadata of the token such as the individual stats of the cards, the image, and the card effects are stored on the server. To the end user, that means that Gods Unchained can choose to change an image or rebalance your existing cards without your permission.

Layer 2 Scaling Solutions and Alternatives

Many games realize that building a blockchain game is next to impossible on the main chain. Thus they switch their code to a side chain such as Loom, or use a different chain such as EOS or TRON. Another option is to use state channels.

Axie Infinity comes to mind. Although their side chain solution is not out yet, they are planning to build their game on the Loom side chain. The benefits of this are that transactions are free for the end user. Transactions are a lot faster too.

The flaw with side chains is that there is no way of guaranteeing without trusting a centralized oracle. If users truly care about being decentralized, then this should also be their concern. The process for transferring an ERC721 token from a side chain to the main chain and vice versa is demonstrated below.

  1. User transfers a token to a smart contract on the side chain
  2. Smart contract on the side chain emits an event.
  3. A centralized oracle listens for the event and broadcasts a transaction on the main chain with the correct token id.
  4. Smart contract on main chain can then mint the correct token for user.

This seems perfect except that users are still trusting the developers to make sure that these oracles are doing what they are designed to do. Since an oracle has admin level functionality, the developers can program the oracle to send out ‘fake’ events allowing the creators to mint tokens that were not given to them or even steal from other users.

They can also shut down the oracle at any point in time, making it impossible for users to transfer their assets out of the side chain. This is an extreme case and essentially impossible as it risks the game’s reputation, but this is a factor that I think many users are not even aware of.

For certain games built on Loom, the default implementation is for the game client to hold the user’s private keys and sign transactions on their behalf. Although this makes for better user experience, it is extremely dangerous if a developer with ill intentions were to get involved. This is because the user DOES NOT know exactly what functions on the smart contract they are calling it from.

For example, a user presses a button in game that is supposed to reward them with an in game token. However the developer modified the code so that a transfer function is called instead that transfers over ALL assets from the user’s account to the developer’s account. If user’s have assets from other games built on LOOM or LOOM tokens itself, that can also be stolen.

As such, I recommend that users who do interact with side chains sign every transaction and double check that what they intend on doing is what is actually being done. To check, users can go on a block explorer to see their transaction.

What are the benefits of using a layer 2 solution?

Using a layer 2 solution is more performant in terms of transaction speed. It is extremely cheap for the end user to run transactions as well. Developers are empowered because these in game tokens have an actual purpose within smart contracts instead of only tracking ownership. In my personal opinion, the risks of using a side chain solution is no different from trusting a server.

This begs the question of, is a server any better than a layer 2 solution if you are trying to build a performant game? The end use case is the same, where as a server is a lot faster.

As Decentralized As Possible

These games built their entire game on the blockchain. All of the source code is published online for everyone to see.

CryptoKitties started off right from the start as a pure blockchain game. The “genes”, a uint256 data structure demonstrates what the cat will look like. Although the premise is similar to the ownership games where users can own, sell, and trade CryptoKitty tokens, the entire gameplay of CryptoKitties revolve around breeding kitties. This function can be found inside the CryptoKitties smart contract.

Even though many of these games claim to be as decentralized as possible, is it really? Also, is it even possible?

  1. For CryptoKitties, they have admin functionalities such as being able to pause the game at any point in time in case of a bug.
  2. The uint256 gene does not demonstrate to the end user what the cat will end up looking like. For example, a special cat such as the “bird cat” will have a specific gene. This special flag is stored server side to show what the cat will end up looking like, even though the “bird cat” has genes that explicitly tell users that it should look like a different cat.
  3. The cat image itself is stored on a centralized server. Users based on the terms and service are not allowed to use the cat’s image outside of CryptoKitties.

Game Design

Designing a game is normally very difficult. It is extremely hard to figure out if a game is ‘fun’. This is amplified in the case of blockchain gaming.

Why is it so difficult making a fun game that is decentralized?

Blockchain calls are deterministic. Once a function is called, the result of the function is “determined” already based on the state it is in. As a result, it makes blockchain games predictable and easy to abuse. It is extremely hard to design a skill based game if the results are always calculated beforehand. Most of the games on the blockchain are glorified “forms”, where users click a button to achieve certain tasks. This kind of gameplay is extremely prone to bots.

Blockchain game developers must focus on good game design when it comes to blockchain gaming in order to avoid this. Strategy card games such as Gods Unchained is excellent at this because it is a lot more difficult to build a bot for a card game. Implementing a strategy where users who are better mechanically at the game will receive better rewards is beneficial for the entire ecosystem. This will also deter bots and encourage more genuine gamers.

Key Takeaways

These decisions are crucial for not just a blockchain developer but also a business to make in determining how decentralized a game should be. There are clear benefits and drawbacks to both sides which I would like to highlight.

If a developer cares about making a truly decentralized application, today’s layer 2 solutions sacrifice centralization and should be avoided.

Being centralized is not a bad thing. It may be crucial in development in order to build fun game with better user experience.

Users may not necessarily care if you make it more centralized. At the end of the day, blockchain gamers want a fun game to come back to.

What is the Blockchain good for?

  1. A central source of truth.
  2. Immutable data with no central organization having power over one another.
  3. Open source code for proven trust.
  4. A way of easily exchanging assets across games.

Blizzard removed the damage component from my beloved warlock’s Siphon Life spell. I cried myself to sleep, and on that day I realized what horrors centralized services can bring. I soon decided to quit.
- Vitalik Buterin

Many gamers share the same sentiment with Vitalik where a game company makes a balance change for their favourite item that ruins their hard work and progress. I dream of a decentralized system where this won’t happen. Although balance changes may occur, I hope to give the players a voice through a governance system that dictates what may pass into the game. The benefits of a system being completely on chain and decentralized is that it is extremely transparent, and users know exactly what the asset will have. The value that the token brings is what it can achieve within the blockchain.

Only store what you truly need on the blockchain

As a blockchain developer, it is important to critically think about exactly what data is being stored. When we were first developing our smart contracts, it is important to store the stats, appearance, and level of each hero. As we are designing the game on chain, it is important that other contracts we build are able to interact with this data as well. In traditional games, this is perfectly fine, however for the blockchain, this becomes unscalable and extremely expensive to store and mutate.

Lessons Learnt

I spoke with several blockchain developers, blockchain gamers, and main stream gamers and there are benefits and drawbacks to building a blockchain game on a centralized vs decentralized blockchain. It is up to the developer to decide on the use case to see what is appropriate for them.

For the past year and a half, I wrote an entire RPG game on the blockchain. After testing our code on main net, as well as various layer 2 solutions, we could not design a truly decentralized game that is fun to play. Although we are not saying it is impossible, for our specific use case, we believe that an RPG game should only track ownership on the blockchain.

If we sacrifice fun, we end up with more of a clicker game that bots can abuse easily. In the end, this decision required me to throw away over 90% of my smart contract code in favour of using a server to track data and logic. We will be following the ownership model where we will only track the ownership of tokens, all other data will be stored in metadata from a server.

We truly believe that the future of blockchain gaming comes from making a truly fun and polished game for the end user. We want real gamers playing our game. We believe that the value of adding blockchain to gaming comes from the ability to truly own these assets. In the end, complete decentralization may be better suited for finance dapps and should not have a place in gaming.

Introducing Kingdoms Beyond

We are building a MMORPG where users can collect heroes, items, and resources. We are tightly integrating with the Ethereum blockchain by enabling ownership over assets. In order to have a stable game economy, we will be backing many of these assets with DAI. More info on this in a later article!

We are focused on creating a fun game that players can come back to. Users can walk around and explore an vibrant world. Certain parts of the world will be player owned and built. Users can interact with other players such as chatting, trading, and battling. We are polishing up a battle system that requires strategy in order to succeed.

We will be holding several giveaways for heroes and items on Discord. In the coming weeks, we will be releasing developer updates on what we are building, come follow us!

--

--