game-components Reference
Source: game-components
The game-components library provides modular Cairo components for building EGS-compliant contracts on Starknet. Each component is a self-contained unit that can be composed into your contract.
Package Overview
| Package | Crate Name | Purpose |
|---|---|---|
| interfaces | game_components_interfaces | All trait definitions, structs, and interface IDs |
| embeddable_game_standard | game_components_embeddable_game_standard | Token, Minigame, Metagame, Registry components |
| metagame | game_components_metagame | Leaderboard, registration, entry gating, entry fees, prizes, ticket booth |
| economy | game_components_economy | Tokenomics: buyback (Ekubo TWAMM), stream token |
| utilities | game_components_utilities | Math, distribution, encoding, SVG rendering |
| presets | game_components_presets | Ready-to-deploy contracts: LeaderboardPreset, AutonomousBuyback, StreamToken |
Dependency Graph
interfaces ◀─── embeddable_game_standard
▲ ▲
│ │
├── metagame ├── utilities
├── economy └── presets
└── utilitiesAll packages depend on interfaces for trait definitions. The embeddable_game_standard package is the most complex, composing Token, Minigame, Metagame, and Registry components.
Installation
Add the packages you need to your Scarb.toml:
[dependencies]
starknet = "2.15.1"
# Core - Token, Minigame, Metagame, Registry
game_components_embeddable_game_standard = { git = "https://github.com/Provable-Games/game-components", tag = "v1.1.0" }
# Leaderboard, registration, entry gating, entry fees, prizes
game_components_metagame = { git = "https://github.com/Provable-Games/game-components", tag = "v1.1.0" }
# Tokenomics: buyback, stream token
game_components_economy = { git = "https://github.com/Provable-Games/game-components", tag = "v1.1.0" }
# Math, distribution, encoding, SVG rendering
game_components_utilities = { git = "https://github.com/Provable-Games/game-components", tag = "v1.1.0" }
# Ready-to-deploy contracts
game_components_presets = { git = "https://github.com/Provable-Games/game-components", tag = "v1.1.0" }
# OpenZeppelin (required)
openzeppelin_token = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v3.0.0" }
openzeppelin_introspection = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v3.0.0" }
openzeppelin_access = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v3.0.0" }Reference Pages
Core Components
- MinigameToken (ERC721) — The core token contract with packed IDs and component composition
- Token Extensions — Minter, Renderer, Skills, Settings, Objectives, and Context extensions
- MinigameComponent — Game logic foundation:
IMinigameTokenData, settings, objectives - MetagameComponent — Platform foundation: context, callbacks
- RegistryComponent — Game registration, discovery, and metadata
Metagame Package
- Metagame Extensions — Leaderboard, Registration, Entry Requirements, Entry Fees, Prizes