How Cartesi is Changing the Game: Showcasing Chess

A deeper look into how Cartesi can be used to easily build verifiable turn-based games using mainstream software components

Cartesi
Cartesi
Jul 27 · 10 min read

Introduction

As discussed in the first article of this series, the current state of affairs in blockchain technology has so far kept the mainstream gaming industry from investing more significant resources in decentralization. Major limitations faced by the industry include not only the restrictive computational power available for blockchain games but also a lack of tools necessary to achieve the required productivity in software development.

Architecture

The framework consists basically of a set of smart contracts that leverage Cartesi’s Descartes SDK to create a general-purpose solution for any turn-based game to work out of the box on an EVM-compatible blockchain. The smart contracts are available on Cartesi’s public Github repository and are also already deployed to Polygon’s Mumbai PoS Testnet.

Building a Game: Chess

The game of Chess is in principle simple enough that it could be executed directly on Layer-1, or alternatively using any other Layer-2 technology. However, being a turn-based game it is also a good example to illustrate how Cartesi can be used to easily implement such games on an EVM-compatible blockchain without coding any Solidity — but still ensuring they are fully verifiable! A working implementation of this Chess game (without a Client App) is available in our public Github repository.

  • players: players involved and their respective funds locked in the game;
  • turnsMetadata: informs which turn was submitted by which player and at what time;
  • turnsData: sequence of moves submitted by the players; the contents are game-specific and in this case will correspond to chess moves represented as strings in Standard Algebraic Notation (SAN) — such as the “b3” and “g5” moves used above;
  • verificationInfo: informs which player challenged the game and triggered the verification; if a result was claimed by a player, it also includes what result was claimed and by whom.

Deploying and Running

To set up the game for practical use, the first step is to have the Verifier Cartesi Machine deployed to the Descartes Validator Nodes that will be invoked when a game verification is requested. For development purposes, the Descartes SDK Environment can be used, which runs everything locally and already includes two validator nodes.

Conclusions

In this article we have shown how Cartesi can be used to easily deploy turn-based games on EVM-compatible blockchains, taking advantage of mainstream software components and tools. An example was showcased in which a game of Chess was quickly developed using an existing library available in JavaScript, without having to touch a single line of Solidity.

What’s next

Cartesi’s potential for increasing blockchain application complexity will be further explored in the next article of the series, in which we will take a deeper dive into the implementation of a complex Mental Poker Engine using C++ libraries. Like Chess, this engine implementation will then be used in conjunction with the TurnBasedGame contracts in order to build Texas HODL’em, the first fully decentralized Poker game ever built for the Ethereum blockchain.

About Cartesi

Cartesi is a multi-chain layer-2 infrastructure that allows any software developer to create smart contracts with mainstream software tools and languages they are used to while achieving massive scalability and low costs. Cartesi combines a groundbreaking virtual machine, optimistic rollups and side-chains to revolutionize the way developers create blockchain applications.

Cartesi

Smart Contracts Taken to the Next Level

Cartesi

Cartesi’s optimistic rollups are evolutionizing smart contract programming by allowing developers to code with mainstream software stacks. Noether is Cartesi’s side-chain that’s optimized for ephemeral data, providing low-cost data availability to DApps.

Cartesi

Written by

Cartesi

Smart Contracts Taken to the Next Level

Cartesi

Cartesi’s optimistic rollups are evolutionizing smart contract programming by allowing developers to code with mainstream software stacks. Noether is Cartesi’s side-chain that’s optimized for ephemeral data, providing low-cost data availability to DApps.