Getting Started
Prerequisites
- Dojo onchain game engine
- React
Setup
Install dojo via
curl -L https://install.dojoengine.org | bash
Make sure install the same version within the Scarb.toml
file.
Eternum uses a pnpm workspace and bun for scripts to allow easy npm packages to be created. So you will need pnpm installed also.
npm install -g pnpm
Easy Method (3 commands)
We have bundled up three scripts to run in three different CLI terminals. Run the scripts in order and leave the window open.
Terminal 1 - Client setup
This will set the client up, however you must run the other scripts otherwise it will not work
sh scripts/client.sh
Terminal 2 - Build the contracts and run the sequencer
sh scripts/contracts.sh
Terminal 3 - Migrate the contracts and start the indexer
<!-- to set config -->
sh scripts/indexer.sh --setConfig
<!-- to just build and index -->
sh scripts/indexer.sh
Environment Variables
For local development, create a file called .env.local
in the client repository and add the following:
VITE_PUBLIC_MASTER_ADDRESS="0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec"
VITE_PUBLIC_MASTER_PRIVATE_KEY="0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912"
VITE_PUBLIC_WORLD_ADDRESS="0x320b2713e324fe3125bbc42d85ff69cb3c0908b436fa38a35746dbc45deeb11"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2"
VITE_NETWORK_FEE_TOKEN="0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
VITE_EVENT_KEY="0x1a2f334228cee715f1f0f54053bb6b5eac54fa336e0bc1aacf7516decb0471d"
VITE_PUBLIC_TORII="http://localhost:8080"
VITE_TORII_GRAPHQL="http://localhost:8080/graphql"
VITE_TORII_WS="ws://localhost:8080/graphql/ws"
VITE_PUBLIC_NODE_URL="http://localhost:5050/"
VITE_PUBLIC_DEV=true
VITE_PUBLIC_SHOW_FPS=true
VITE_PUBLIC_GRAPHICS_DEV=false
VITE_PUBLIC_TORII_RELAY="/ip4/127.0.0.1/tcp/9092/ws"
This file is subject to change, please keep an eye on the repository for potential updates.
Stack
- Contracts: built using the Dojo framework. This leverages the ECS model, allowing us to build quick and ship fast. It revolves around 3 units: Entities, Components (called Models in Dojo) and Systems (more about this in the Dojo book).
- Client: our client is built using React with Typescript. We leverage Dojo by using DojoJS
- Eternum SDK: our SDK contains most notably the getter and setter of the configuration of Eternum, the EternumProvider and most of the constants/types of the world that needed to be transcribed to Typescript.
- Torii: Dojo's indexer, optimized for that particular framework and well integrated into the stack. From our client, we have a gRPC subscription set up through DojoJS and recs to events. Events are fired in the contracts as a way for the indexer to know what's going on in the world. Every time an entity is created, updated, or deleted, an event is fired which updated Torii's record of the world.
- DojoJS and recs: DojoJS is the SDK that allows easy integration of a Dojo app into your client/node backend. Recs are DojoJS's way of exposing the state of the world to the client. This is done via queries to the Recs state using a simple query language, which doesn't support complex queries yet (e.g. joins, gt, lt, etc...).