Game state & logic

To build a game onchain, you’ll need to familiarize with Solana programs (smart contracts). You might be already familiar with Anchor, one of the most used toolkit for writing smart contract on Solana.

BOLT is a framework that extends Anchor functionalities to include a standardized way to model your game’s logic using an Entity Components Systems (ECS) pattern.

The ECS is a modular pattern that decouples logic from state and facilitates code reusability, extensibility and performance improvement for large-scale projects. The Solana Virtual Machine (SVM) also makes use of a paradigm similar to an ECS given that state (accounts) and the logic (programs) are natively separated.

In the Entity Component System:

  • Entities are general-purpose object represented by a unique identifier. They don’t contain any data or behaviour but serves as an identifier for a bundle of components.
  • Components are raw data structures. For instance, a Position Component might contain some x, y, and z coordinates. This is concept is essentially equivalent to accounts on Solana.
  • Systems perform the game logic by acting upon entities that have specific components. Systems are essentialy programs on Solana, which only specify the logic and the accounts they operate on.

While BOLT supports all the functionalities of Anchor, adopting the ECS pattern is helpful if you want to reuse existing components/system or enable simpler mods and extension for your game.