Architecture

How The Etherscape Works

The Etherscape has built an online service designed to scale up to large numbers of concurrent players while enabling them to securely mint custom NFT items onto the Enjin blockchain. Below is an architecture diagram of how this is done along with some brief descriptions about how the different parts work.

Client Server Setup

For the game client and server, we are using Unity with the Netcode for GameObjects library. It is written as a single codebase which makes it easy to iterate on, testing quickly by hosting the client and server on the local box in a single process. Then, for shipping to users, compile time variables can be used to remove all of the server specific code from the client.

The servers are hosted on small 2-core windows VM's in the Azure cloud. Azure was chosen because the team is already familiar with it. However, other cloud providers like Amazon or Google would also work fine. The VM's run a Windows service which interacts with the Unity Cloud Build system to check for new game builds and download and run them automatically. This enables quick and easy release automation. Scaling up can be done easily by adding more VM's.

Storage

For the live game service to run, it is necessary to store many kinds of data. For data storage, we are using the NoSQL database Firestore which is part of the Google Firebase suite. Firestore was chosen because it has integration with Unity and has all the necessary features needed. The following data is stored in Firestore...

  • Account information (email, wallet address)

  • Character data (level, class, stats)

  • Item data (random loot drops, resources, etc.)

  • Requests to mint items onto the blockchain

  • Global state (ex. next token id to use)

Auth

Firebase auth is used to create and authenticate user accounts. This is convenient since we are already using the Firebase suite for storage. Using Firebase we can easily create user accounts based on a player's email address. Once they log in, we can retrieve their token and use that to authenticate securely with the game server. Firebase will generate a user id for them which we use as they key to store their data in Firestore.

Blockchain

One of the core gameplay mechanics for The Etherscape is to allow players to mint random loot drops onto the blockchain. In order to do this, we use the Enjin Platform to interact with the Enjin Matrixchain. This is used to securely validate a user owns a wallet, read the tokens they own and trigger transactions to mint NFT's to their wallet. The workflow for minting a token looks like this.

  • The player finds an item in the game with random properties they like.

  • The player acquires the necessary resources in game to "craft" the item into an NFT.

  • The player triggers the minting process in game.

  • The game server writes a work item to Firestore which includes the item metadata.

  • The resources and item are deleted from the player's account.

  • A minter process running in the cloud picks up the work item to process.

  • The minter finds the next valid token id to use for the collection.

  • The minter writes the metadata for the item into Firestore at a well-known location for the token id.

  • The minter calls the Enjin Platform to create a new token which will read its attributes from the well-known location in Firestore for the token id.

  • Once the item is minted, the work item is marked complete.

  • The game server sees the work item is complete and updates the players in game items to include it.

It would be possible to adjust the platform to write the attributes directly into the token. However, this would make the token about 5x more expensive to mint since it needs a reserve for reach attribute as opposed to just a single attribute with the URI.

Last updated