Chromia Explained: What Exactly is "On-Chain Logic"?

Chromia Explained: What Exactly is "On-Chain Logic"?

If you've been reading up on Chromia, chances are you've seen the term "on-chain logic" a time or two. But what does it really mean, and why does it matter? Let's break it down. 

In this article, we will address the topic through the lens of gaming. However, it is important to remember that these concepts can extend to a number of other use cases as well!

Understanding the Difference Between “Client” and “Server”

Broadly speaking, a ‘client side’ program refers to code that runs on the device owned by the user of the program. 

If you’ve ever played a video game console from before the internet era, you are familiar with applications where everything exists on the client side. Let’s consider a classic console like Sony Playstation 1, which had no internet connectivity. 

  • The graphical textures, music, cutscenes, etc, are stored on a disc.
  • The code that made game calculations determined the rules, etc., is also stored on a disc.
  • Your save data is stored on a memory card.

This setup worked great for single-player games with no competition between players and no financial incentives. If a person learned how to alter their save data to get infinite money or trick the game into dropping the rarest items 100% of the time, no one really cared.

That said, the client-side model did come with custodial risks for your save data. If you lose or damage your memory card, all of your progress in a game could be lost. 

Once the internet became common, many single-player games addressed this issue by moving save data to centralized servers while still storing all of the game rules and performing calculations on the player’s console. However, a new kind of game was emerging that would require far greater use of servers.

The Advent of MMOs

In the early 2000s, Massively Multiplayer Online Games (or MMOs for short) started to gain popularity. These games included titles like World of Warcraft and Final Fantasy 11, which gained massive followings. 

A hallmark of these games is the large amounts of time, skill, and luck that are required to advance characters to the highest levels and obtain the rarest and most powerful items. These games spawned highly competitive environments where accounts and items carried real monetary value, meaning save data, game rules, and calculations, can no longer be stored on a user’s local machine. 

MMOs have economies, which would be thrown into imbalance if a user could simply alter their save data and duplicate the most powerful items. They also place a premium on competitive integrity, because different factions may be battling head-to-head for resources. If a player could trick the rules of the game to land a critical hit every time, or ensure that his party received a rare drop every time they defeated a boss, they would have an unfair advantage that negatively affects every other person who plays the game.

The solution to these issues is to move more of the game’s architecture to servers owned by the publishers of the game. Under this design, users download a client program which contains things like graphics and music, while also transferring information to and from game servers.

Given that the publishers of a game have a financial stake in its success, they are inherently motivated to safeguard the integrity of players' save data and prevent cheating to maintain fair gameplay. Nonetheless, this arrangement also introduces several new concerns and risks, many of which have materialized in real-world scenarios:

  • Once a game declines in popularity and becomes unprofitable to support, a company may stop paying for servers and ‘brick’ the game.
  • Since developers control the rules of the game, they may decide to make changes that are unpopular. 
  • Servers can be hacked, allowing malicious actors to gain an unfair advantage.

Trading Real Money for In-Game Items

Online games have economies where items and accounts can hold tangible value. Whether acquired through time, skill, or luck, certain in-game assets command real-world monetary worth, and players will willingly exchange cash for them.

This has led to the creation of third-party marketplaces where people pay real money via PayPal, cryptocurrency, credit cards, etc., in exchange for items, achievements, unlocks, or even entire accounts.

However, these transactions hinge on trust and carry inherent risks. If you pay someone $100 to give you a magic sword inside your favorite MMO, can you be sure they will meet you inside the game world and deliver? If you spend $1000 to be given control of an account with a maximum leveled character, can you be sure that the seller will hand over legitimate login information? 

Even when you are selling that magic sword, you are really just exchanging some bits of information that exist on some company’s server. Which raises questions like “Do you really own the thing you just sold?” and “Do you really own the thing you just bought?”.

These issues of trust and ownership are some of the first problems being addressed by blockchain-enabled games.

Enter the Blockchain

Let’s imagine an MMO that works similarly to the one above, but now every limited edition item in the game is represented by a Non-Fungible Token or NFT. Players still download a game client, and the game still relies on centralized servers to store most of its data and perform calculations, but now the most valuable items are handled by a different kind of ‘server’, one that no one person or company controls: a blockchain.

Because public blockchains are fully transparent, every person with an interest in the game can confirm that the limited items exist in the correct quantity, no one has found a way to generate unlimited quantities of the item, the ownership history of the item, how much the item has sold for the in the past, etc.

There is also a way to exchange these limited edition items for cryptocurrencies like ETH, BTC, and USDT, in a way that removes trust from the equation. By automating the swap of an NFT for another cryptocurrency, the seller of an item knows that they will receive payment, and the buyer knows that they will receive the item.  

However, you will notice that this design still relies heavily on centralized servers to keep the game running.

How can you be sure that the calculations dictating competitive gameplay are fair? How can you be sure that technically unlimited but valuable support items that could give players an advantage have been earned and distributed fairly? How can you be sure that the designer of this blockchain game will continue to pay the server fees that keep the game running? 

The chart above is a more or less accurate representation of most blockchain games that exist today. The majority of the backend still relies on centralized servers, with tokenization being used in a limited capacity to represent some in-game assets.

What is the Bottleneck?

This begs the question, “Why can’t we put more parts of a game on-chain?”. There are two main reasons for this. Firstly, blockchains can be slow and expensive. Secondly, even if a chain solves the problems of scalability and cost, it stores information using a ‘key value’ format that is not very good at storing complex data sets.

If your only goal is to represent some of the most valuable in-game items as NFTs, these obstacles can be worked around. However, let’s imagine you want to put all of these other things on-chain:

  • The code responsible for building procedurally generated levels.
  • The code responsible for controlling drop rates and generating random numbers to decide if a rare item drops.
  • The code responsible for determining how much damage your character inflicts during an attack.
  • The entire inventory of a character, not just a small number of items.
  • The save state of a character within a world (i.e., position, quest status, etc.)
  • The metadata and image files associated with NFT-backed items and collectibles.

Well, now you’re going to need a blockchain that is both scalable and highly effective at storing, accessing, reading, and writing data. Now you’re going to need a relational blockchain. Now you’re going to need Chromia

Chromia and My Neighbor Alice

Everything discussed above is not theoretical! In fact, the fundamental concepts have already been put into production with My Neighbor Alice’s Alpha Season 4 on Chromia’s Appnet. 

In any game with lots of visuals, a user will have to download and install a game client in order to play. However, every other process that helps MNA run is stored and executed on the blockchain. When we talk about ‘fully on-chain dapps’ and ‘on-chain logic’, this is exactly what we mean!

On Chromia, complex games don’t need to be built with a combination of client, centralized server, and blockchain. 

Advantages of On-Chain Logic

The shift to on-chain logic brings numerous advantages, including:

Verifiable Fairness: With all logic recorded on the blockchain, users can verify that the application is operating as intended, without the risk of manipulation or tampering.

Decentralization: By removing the need for centralized servers, applications become truly decentralized, with no single point of control or failure.

True Ownership: On-chain logic enables actual ownership of assets within the application, such as in-game items, and even entire characters.

Governance Opportunities: Since the rules that govern gameplay are on-chain, a game could be designed where token holders need to vote to approve changes.

Chromia's Role 

Chromia is at the forefront of enabling on-chain logic, providing a platform that offers better performance, flexibility, and developer experience compared to traditional blockchain solutions. With Chromia, developers can build complex games with on-chain logic, unlocking the full potential of Web3. By moving logic onto the blockchain, applications become transparent, decentralized, and verifiably fair. 

About Chromia
Modern society runs on data and every online service you’re using is built upon underlying databases - ranging from your online bank to music streaming and gaming. Chromia is a relational blockchain - a combination of a relational database and a blockchain - making it easy to develop user-friendly decentralized apps for almost any industry, including DeFi, NFTs, gaming, and more.

Website | Twitter | Telegram | Facebook | Instagram | Youtube | Discord