|
| 1 | +# Token Lite Module — CoreTokenLiteComponent (ERC721) |
| 2 | + |
| 3 | +Gas-optimized single-game variant of the `token` module ("denshokan lite"). |
| 4 | +Built for deployments that embed exactly one game, never used the multi-game |
| 5 | +registry/objectives/context/skills/per-token renderer features, and keep |
| 6 | +game-over / objective-completion authority in the game contract itself. |
| 7 | + |
| 8 | +## Design Rules |
| 9 | + |
| 10 | +| Rule | Consequence | |
| 11 | +| --- | --- | |
| 12 | +| One game, configured at init | No registry, no `game_id` resolution, no SRC5 probes on mint | |
| 13 | +| No mutable token state | No `update_game`, no metagame callbacks; `is_playable` = lifecycle window only, zero storage reads | |
| 14 | +| Token id layout is canonical | Reuses `token::structs::pack_token_id` (251-bit) bit-for-bit; unused fields (`game_id`, `objective_id`, `has_context`, `paymaster`, `metadata`) are written as zero | |
| 15 | +| `mint` is ABI-compatible with `IMinigameToken::mint` | Existing call sites and the `minigame::mint` helper work unchanged; unsupported params are rejected loudly, never silently ignored | |
| 16 | +| Game contract is the authority | Games gate dead/finished runs themselves and call `refresh_metadata` (ERC-4906) after actions | |
| 17 | + |
| 18 | +## Interface (IMinigameTokenLite) |
| 19 | + |
| 20 | +**Interface ID:** `IMINIGAME_TOKEN_LITE_ID = 0x3ea3d599077fbe09ddbe82ff33c1abc87aef52d8609d8bf3508fdba8dd92056` |
| 21 | + |
| 22 | +Defined in `packages/interfaces/src/token/lite.cairo`. The initializer also |
| 23 | +registers `IMINIGAME_TOKEN_ID` so `MinigameComponent::initializer` (which |
| 24 | +hard-asserts it and then queries `game_registry_address()`) accepts a lite |
| 25 | +token; `game_registry_address()` always returns zero. |
| 26 | + |
| 27 | +| Method | Cost | Notes | |
| 28 | +| --- | --- | --- | |
| 29 | +| `mint(...)` | 1 minter-map read (warm), optional name write, ERC721 mint | Same 15-arg signature as the full token | |
| 30 | +| `assert_owner_and_playable(token_id, expected_owner)` | 1 storage read (owner) | Combined guard — replaces `owner_of` + `assert_is_playable` (two calls) with one | |
| 31 | +| `is_playable` / `assert_is_playable` | 0 storage reads | Lifecycle window only — no game_over latch | |
| 32 | +| `token_metadata`, `settings_id`, `minted_by`, `is_soulbound` | 0 storage reads | Pure unpack of the token id | |
| 33 | +| `player_name`, `minted_by_address` | 1 storage read | | |
| 34 | +| `refresh_metadata(_batch)` | event only | Same advisory/no-existence-check semantics as the full token | |
| 35 | +| `update_player_name` | owner-gated write | | |
| 36 | + |
| 37 | +Not present (reverts with ENTRYPOINT_NOT_FOUND): `update_game`, all other |
| 38 | +`*_batch` views, `mint_batch_recipients`, objectives/settings/context/ |
| 39 | +renderer/skills/enumerable surfaces. |
| 40 | + |
| 41 | +## Composition |
| 42 | + |
| 43 | +Requires: `ERC721Component`, `SRC5Component`, an `OptionalMinter` impl |
| 44 | +(`MinterComponent::MinterOptionalImpl` — minter ids gate reward claims in |
| 45 | +consumers), and an `ERC721HooksTrait` (enforce soulbound in `before_update` |
| 46 | +via `unpack_soulbound` — pure, no storage). |
| 47 | + |
| 48 | +See `tests/examples/token_lite_contract.cairo` for a full wiring example. |
| 49 | + |
| 50 | +## Testing |
| 51 | + |
| 52 | +```bash |
| 53 | +snforge test -p game_components_embeddable_game_standard "::token_lite::" |
| 54 | +``` |
0 commit comments