Introducing Keystone

Introducing Keystone

Today we’re proud to release the first stable version of Keystone, the best toolkit to build highly performant and composable onchain games for the most ambitious developers. Keystone represents the culmination of the last 2 years building onchain games from the Curio team. We believe that Keystone will enable developers to build onchain games with real commercial scale.

Origin Stories

Ever since late 2021, we started obsessively shipping experiments onchain. We first built an onchain ECS-based state management system and highly performant indexers. We soon realized that our contracts consumed tens of millions of gas per transactions and needed its own block space to scale, so in summer of 2022, we launched a naval-themed RTS mini game on our own dedicated app chain as one of the earliest to do so, where thousands of players interacted with our game.

In early 2023, we launched Treaty, the first game that let players deploy smart contracts that represents political and social contracts with one another. We were astounded by the creativity of our community that proposed all sorts of wild treaty ideas.

We believe that social composability and open data is the “100x feature” for onchain games, especially when combined with high stakes. We dream of a future where millions of treaties, smart contracts, and plugins are deployed by the community, spawning infinitely interesting social dynamics that we can’t even conceive of. We envision complex nations being formed launching their economies, and battles being fought onchain with smart contracts as weapons and tools. At Curio, we are dedicated to building this future. To read more on this, we summarized thoughts here.

What we discovered

However, throughout our first foray into building smart contract based onchain games, it was clear that these data and compute intensive worlds needed much more than vanilla smart contracts and generalized blockchains. Moreover, in order for onchain games to grow meaningfully as a whole, we must focus on bringing the same level of experiences the average player expects. Experiences like League and Starcraft should not be foreign to onchain game players. We deserved better.

Upon deeper reflection, we summarized the following:

  1. Onchain games needed more performant systems. Games built on a single EVM blockchain cannot handle many concurrent users let alone scale to millions. When deploying large applications on a single blockchain, one game instance heavily degrades the performance of another. Fundamentally, the EVM isn’t optimized for game specific needs, from the storage structure to how transactions are processed.
  2. Blockchains are missing critical game-building features. Traditional game servers are tick-driven, run on a highly performant game loop, and can process player requests automatically. However, the nature of blockchains blocks these systems from being built conveniently. Developers resort to lazy updating values to achieve similar effects, hindering developer experience.
  3. Isolated developer experience. Although EVM tooling has matured quite a lot, smart contract languages are ultimately unable to leverage existing mature toolchains and ecosystems for games, from useful libraries to 3rd party services (leaderboards, identity services, match making).

Inside Keystone

Keystone represents a step-function improvement in how onchain games are built. Think of Keystone as a blockchain and a game server enshrined in one unit. It’s designed from grounds up to create a highly performant data oriented game server with the composability of EVM smart contracts.

0:00
/0:07

Tutorial game found in the starter kit in real time

State management

Keystone uses a table-based state management system inspired by ECS. Each entity is associated with a schema struct with full type support in Go. Clients, whether in JavaScript or Unity, can subscribe to automatically sync state with no additional code. We’ve also entirely eliminated the need for an indexer, reducing latency dramatically. Query and subscribe to data streams directly from Keystone.

Execution

Game logic, organized into systems, is written in Go instead of Solidity, allowing developers to fully leverage existing libraries and 3rd party services while increasing performance drastically. The heartbeat of Keystone is a fast-paced game tick. At each tick, transactions submitted from the last tick are processed via systems. Transactions are executed atomically just like smart contracts, and Keystone can comfortably process tens of thousands of transactions per second with hundreds of ticks per second.

In addition, Keystone supports transaction replay — by deterministically playing back user transactions, developers can instantly rewind the game state back to any point in time — a handy tool for debugging, collecting analytics, and more.

Plugins

Keystone supports a wide range of plugins for persistent data storage, data availability, and more. We offer out of the box support for SQLite and MySQL solutions for backing up data when game worlds need to be consistent, making it easy to create data pipelines, analytics and logging services. Developers can create custom plugins by following a standard interface.

EVM

The Keystone EVM and game server is enshrined in a single instance. To do this, we’ve taken the necessary components from Geth and integrated it with the rest of the Keystone server, making the EVM hyper performant and specifically tailored for games. Smart contracts deployed on Keystone can both read and write data from the table-based state through precompiles. We will release more updates on the Keystone EVM soon.

The synthesis between a traditional game server architecture and the battle-tested EVM gives developers a highly performant system while retaining the full composability of smart contracts. We couldn’t be more excited to share this with the world.

Looking Ahead

Soon, Keystone will include an additional suite of tools, such as a deployment service that allows games to horizontally scale, useful in games with lobbies and sessions.

Keystone abstracts away the complexity of building onchain games to let developers focus on great content and game design. Internally, we have been developing our flagship game using Keystone. Our game studio is led by a world-class team that hails from miHoYo (Genshin Impact), Lillith Games (Rise of Kingdoms), Funplus (King of Avalon), and more. We are extremely excited to share more updates on the game very soon.

The best way to get started on Keystone is our starter kit here and documentation here. To receive direct support, join our Discord or DM us on Telegram.

Our Twitter here.