DEV Community

Cover image for Getting started with Smart Infrastructure in EVE Frontier
Afri
Afri

Posted on

Getting started with Smart Infrastructure in EVE Frontier

Note: At this stage, there is no publicly available information about the actual EVE Frontier game. The author solely uses all available information on the public documentation and blockchain ledgers for this article. No screenshots or mechanics of the game will be revealed in this post. Assumptions about gameplay are solely made on the base of the sister-game EVE Online.


EVE Frontier is the latest game in development by the Icelandic studio CCP Games. Since not many details are publicly known about this game, let's assume the gameplay is similar to their 21-years old space-MMORPG EVE Online which is an incredible sandbox game, if not one of the most important sandboxes of all times. A sandbox game is basically a world, where you can do whatever you want and there is no straight story arc or given path you have to follow. The entire in-game economy, from mining the smallest unit of rock to building a massive Titan is exclusively driven by players without any NPCs involved.

Now, take this idea of such a massive space sandbox and go a step further: what if you take the sandbox and put it on top of another sandbox that allows players to build the actual game back-end -- creating structures in space, offering missions, establishing security, or whatever you come up with. This is what EVE Frontier is potentially trying to achieve by having an openly programmable blockchain framework underneath. This article explores an example of such a smart assembly and outlines the technical steps required to deploy a functioning component of such in-game infrastructure.

Blockchain Sandbox: Mud & Redstone

EVE Frontier is building on top of Lattice's Redstone layer-2 blockchain, an Ethereum-based roll-up targeted at game developers. A recent playtest was deployed to the Redstone testnet Garnet with chain ID 17069 which rolls up on the Ethereum testnet Holesky. The roll-up features an Ethereum Virtual Machine (EVM) which allows users to program smart contracts with the Solidity programming language.

The blockchain back-end for the game is a set of smart contracts -- referred to as an autonomous world -- that have certain immutable logic and offer the foundation of the game's back-end. However, all the contracts have public APIs and can be extended by your own custom logic. EVE Frontier is using Paradigm's Foundry and Lattice's Mud framework which provides tooling for efficiently developing on-chain content for games.

MUD is provided with not only the game developers but also the users in mind. To retain a great user experience, it employs modern technologies such as meta transactions or account abstraction to make the gameplay as enjoyable as possible.

Mud Framework

Now, in EVE Frontier, every player is a cryptographic smart character represented by a pair of SECP256K1 keys, here: an Ethereum account, with a soul-bound token that uniquely identifies your rider. The smart character is basically an ERC-721 non-fungible token (NFT) that is non-transferable. To get an idea how many players tested the latest autonomous world in the alpha playtest, you can check out the token holder list on the blockchain contract 0xdA488adedBEbCC97702F3cc27Ff4A111728721d4 (12,291).

In-game currencies can be created using the ERC-20 token standard. EVE Frontier seemingly introduced a currency EVE that could be required to engage with certain game logic. A list of token holders and transfers for the recent playtest can be found at the token contract 0xb9039385a5c5fFf6C0794829c3149690b310ec8a. 12,326 EVE token holders transferred the token 17,689 times at the time of writing.

But all this is very basic blockchain functionality and not super exiting yet, so let's dive right into world building with smart infrastructure which fully utilizes the tools provided by Mud and potentially makes EVE Frontier a really exciting endeavor.

Smart Infrastructure: Jump Gates

EVE Frontier's smart infrastructure contains a set of smart objects that can be programmed and deployed by players. For the play test, some examples were provided by the Lattice and CCP Games teams: smart turrets that can engage ships in space, smart storage that is a sort of station hanger deployed in space, and smart gates to travel vast distances.

Smart Objects

A very powerful asset is a smart gate that allows ships to jump from one star system to another distant system, making travel not only faster but also more secure by evading potential hostile campers that just wait for you to pass through. The following assumes you are familiar with the required tools and workflows as described in EVE Frontier's quick-start documentation. For questions regarding Solidity programming, take a look at the smart-contract documentation.

EVE Online Jump Bridge

A smart gate is a system that has one obvious main use: jumping from one gate to another. To control who can jump through, we write a minimal smart contract taken from the templates:

contract MySmartGateSystem is System {
  function canJump(uint256 characterId, uint256 sourceGateId, uint256 destinationGateId) public view returns (bool) {
    return false;
  }
}
Enter fullscreen mode Exit fullscreen mode

Let's walk this through line by line:

  • MySmartGateSystem is my custom contract that handles the logic of my smart gate. It is extending the class System from the Mud framework which provides a WorldContext. Let's assume for now, that the game developers provide all context so that we can focus on building our own system.
  • canJump() is a function that handles the permissions using the gate in space. It returns a boolean indicating if a player with characterId can jump from a gate with sourceGateId to destinationGateId.
  • return false denies access to anyone calling this function. Nobody can jump.

Ok, where do we go from here? We want to use the gate, so we need to start working towards condition handling to allow a player or a set of players to use the gate. One easy way would be to hard-code permissions in the smart contract on chain. Let's take a look.

contract MySmartGateSystem is System {
  function canJump(uint256 characterId, uint256 sourceGateId, uint256 destinationGateId) public view returns (bool) {
    if(characterId == 2112001337)
      return true;
    else
      return false;
  }
}
Enter fullscreen mode Exit fullscreen mode

So, taken straight from the Solidity 101, we implemented a very basic if-else logic. If the character is 2112001337 -- assuming that's me -- then allow me to jump. Everyone else will be denied. Now, this is very easy logic to implement and follow.

However, this is a smart contract that lives on the blockchain and can not be changed after deployment. So, each time we meet someone in game that we like and want to allow them access to our jump-bridge network, we would have to redeploy the contracts and reconfigure the gates, like this:

contract MySmartGateSystem is System {
  function canJump(uint256 characterId, uint256 sourceGateId, uint256 destinationGateId) public view returns (bool) {
    if(characterId == 2112001337)
      return true; // me
    else if(characterId == 2112002342)
      return true; // my friend
    else
      return false;
  }
}
Enter fullscreen mode Exit fullscreen mode

You get the idea. So, what if you want to add 20 friends or maybe give also your corp or alliance access with 100s if not 1000s of players? Managing such a data-set in a smart contract is absolutely not feasible.

Fortunately, the Mud framework provides us with a handy tool called Mud tables. Here, the game provides a table of all characters with some helpful attributes such as belonging to a certain corporation. So, in this case we could allow everyone who is in my corp to also use the gate, like this:

contract MySmartGateSystem is System {
  uint256 public constant MY_CORP_ID = 2000137;
  function canJump(uint256 characterId, uint256 sourceGateId, uint256 destinationGateId) public view returns (bool) {
    uint256 characterCorpId = CharactersTable.getCorpId(characterId);
    if(characterCorpId == MY_CORP_ID)
      return true;
    else
      return false;
  }
}
Enter fullscreen mode Exit fullscreen mode

Let's take a look:

  • MY_CORP_ID is a numeric identifier of my corp in game. It can be obtained from the character table generated by Mud.
  • CharactersTable is providing the world context and is generated by the Mud framework filled with data from the actual game.
  • CharactersTable.getCorpId(characterId) gets the corp identifier from the user trying to access the gate.
  • We just match characterCorpId to MY_CORP_ID and allow everyone with a matching corp ID to jump the gate.

That's it for the basic logic for now. Next steps would include adding some error handling for invalid inputs such as character Ids or missing corporation records but I'll leave this for the readers to figure out.

Or -- what's your idea such a smart assembly could offer? Rewards for reporting offline infrastructure? Missions to refuel the gates? Let me know!


After getting my hands into building these smart infrastructure components for EVE Frontier, I'm convinced I only scratched the surface of what is possible. Just from reading the documentation I'm extremely hyped about the cooperation of CCP Games and the Lattice team. It proves having a blockchain back-end is much more than just accumulating tokens and trading rare NFTs.

The EVM, Mud, and EVE Frontier give you the power to build your own game as you play it.


Full code:

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.24;

// Mud framework world context imports
import { console } from "forge-std/console.sol";
import { ResourceId } from "@latticexyz/world/src/WorldResourceId.sol";
import { WorldResourceIdLib } from "@latticexyz/world/src/WorldResourceId.sol";
import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol";
import { System } from "@latticexyz/world/src/System.sol";
import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.sol";

// Importing the generated character table
import { CharactersTable } from "../../../codegen/tables/CharactersTable.sol";

// My custom smart gate system contract logic
contract MySmartGateSystem is System {

  // A constant holding my corp ID
  uint256 public constant MY_CORP_ID = 2000137;

  // A permission handler for jump requests
  function canJump(uint256 characterId, uint256 sourceGateId, uint256 destinationGateId) public view returns (bool) {

    // Gets the corp id of the player interacting with the assembly
    uint256 characterCorpId = CharactersTable.getCorpId(characterId);

    // Only allow my corp access
    if(characterCorpId == MY_CORP_ID)
      return true;
    else
      return false;
  }
}
Enter fullscreen mode Exit fullscreen mode

Follow the Smart Gate example to learn how to compile and deploy it.

Top comments (3)

Collapse
 
wschwab profile image
wschwab

Interesting article! 12,291 players and 12,326 token holders - I'm guessing the additional token holders are smart assemblies or something like that?

Collapse
 
q9 profile image
Afri

Yes, it could be treasury accounts by the game developers, but also decentralized applications that act as intermediary temporary holding tokens in reserve for trading other assets or services.

Collapse
 
david_gratton profile image
David Gratton

I’m wondering how closely this relates to this idea of Game as Protocol?
open.substack.com/pub/davidgratton...