Skip to content

BibliothecaDAO/eternum

Repository files navigation

discord License: MIT

Realms: Eternum

Eternum is the foundational game for Realms World - a living digital ecosystem that evolves through player interaction. It serves as both a game and an open platform.

Eternum as a Game

A high-stakes game played in seasons where players forge their own path to victory. On an infinite hexagonal map, players:

  • Build resource stockpiles
  • Train troops
  • Explore the map
  • Trade resources
  • Form alliances
  • Compete for dominance

Access requires a Season Pass minted from Loot Realms NFTs. Players use $LORDS tokens to trade in the game's free market on Starknet.

Eternum as a Platform

Eternum provides the core infrastructure for building games and applications. It includes:

  • Core functional systems
  • Fungible resource framework
  • Extensible architecture
Click to expand

Open World Philosophy

Eternum is built as an Autonomous World with two core principles:

  1. Radical Openness
  • No gatekeepers or central control
  • Anyone can build and contribute
  • Open source and extensible
  1. Persistence
  • Fully onchain game state
  • Immutable seasons
  • Player-driven evolution

The platform is designed to be forked and extended by the community, serving as the foundation for an expanding ecosystem of games and applications.

Project Structure

  • Client - React apps built with Vite
  • Contracts - Cairo/Dojo smart contracts
    • Game contracts
    • Season Pass contracts
    • Season Resources contracts
  • Packages - Shared libraries
    • Core - Eternum SDK
    • Provider - Game contract interactions
    • React - React hooks and components
    • Torii - On-chain data querying
    • Types - Type definitions
  • Config - Configuration and deployment scripts

Eternum Packages Overview

The Eternum ecosystem is composed of several core packages, each serving a specific role in the development and operation of the game and platform:

Core (@bibliothecadao/eternum)

The foundation of the Eternum SDK, providing essential building blocks for applications on Starknet & Dojo. Includes the main provider implementation, core data structures, utility functions (such as hex map and resource management), and specialized managers for game logic. Enables seamless blockchain integration and protocol interaction.

Provider (@bibliothecadao/provider)

A comprehensive, type-safe interface for interacting with Eternum game contracts. Manages all game transactions (army, battle, trading, guild, structure, resource, and quest operations), contract calls, and event handling. Features a smart promise queue that batches and optimizes transaction execution for performance and reliability.

React (@bibliothecadao/react)

A collection of shared React hooks and stores designed for Eternum game applications. Provides easy access to game state, player data, and contract interactions within React components. Simplifies frontend development by offering hooks for realms, resources, and player-owned data, ensuring smooth integration with the Eternum backend.

Torii (@bibliothecadao/torii)

Enables advanced querying of on-chain Eternum data. Supports both gRPC-based queries (via the torii-client) and direct SQL queries (via the sql folder), allowing developers to fetch, filter, and aggregate game data efficiently. Ideal for analytics, dashboards, and any application requiring rich data access.

Types (@bibliothecadao/types)

A centralized collection of type definitions and constants used throughout the Eternum ecosystem. Ensures type safety and consistency across all packages, covering entities, resources, transactions, and system properties. Essential for maintaining a robust and reliable codebase.

Package Description
Core Foundation for Eternum apps: provider, data structures, utilities, and managers.
Provider Type-safe interface for all game contract interactions and transaction management.
React Shared React hooks and stores for easy frontend integration with Eternum game state.
Torii Advanced on-chain data querying via gRPC and SQL for analytics and dashboards.
Types Centralized type definitions and constants for consistency and type safety.

Prerequisites

Core Dependencies

Setup

  1. Install Dojo:
curl -L https://install.dojoengine.org | bash
  1. Install pnpm:
npm install -g pnpm
  1. Install project dependencies:
pnpm install
  1. Build shared packages:
pnpm run build:packages

Game App

This is the main game application for Eternum, built with React, TypeScript, and Vite.

Running Locally

To run the game locally:

  1. Navigate to the game client directory:
    cd client/apps/game
  2. Make a copy of .env.local.sample and rename it to .env.local
  3. Update the following environment variables in .env.local based on your target environment:
    • VITE_PUBLIC_TORII="http://127.0.0.1:8080"
    • VITE_PUBLIC_NODE_URL="http://127.0.0.1:5050"
  4. Run pnpm run dev to start the development server

Development of Eternum

Development of Eternum is open-source. If you would like to contribute comment on an open issue.

Available Scripts

Development

  • pnpm dev - Start game development server
  • pnpm dev:docs - Start documentation development server
  • pnpm dev:landing - Start landing page development server

Building

  • pnpm build - Build game client
  • pnpm build:docs - Build documentation
  • pnpm build:landing - Build landing page
  • pnpm build:packages - Build shared packages

Testing & Linting

  • pnpm test - Run all tests
  • pnpm lint - Run linting
  • pnpm format - Format code
  • pnpm format:check - Check code formatting

Contract Deployment

Eternum supports multiple deployment environments:

Environment Description
Local For development and testing
Slot Staging environment
Sepolia Public testnet
Mainnet Production environment

Deploying to Local

Before deploying to any environment, confirm that you have a .env.{environment} file in the contracts/common directory, as well as in the client/apps/game directory.

To deploy and run the game locally:

# Start local game contracts
pnpm run contract:start:local

Deploying to Sepolia

To deploy the contracts to Sepolia testnet, run these commands in order:

  1. Deploy game contracts:
pnpm run game:migrate:sepolia
  1. Deploy season pass contracts:
pnpm run seasonpass:deploy:sepolia
  1. Deploy season resources contracts:
pnpm run seasonresources:deploy:sepolia
  1. Update TOML configuration:
pnpm run toml:update:sepolia
  1. Start the indexer:
pnpm run indexer:start:sepolia
  1. Deploy game configuration:
pnpm run config:deploy:sepolia

License

This project is licensed under the MIT License. See the LICENSE file for more information.