Key-value storage & collections
Structured per-player, shared, and team collections with OCC and atomic mutations.
Beyond save slots, storage collections hold structured key→value entries with a scope and read/write policy the developer configures (dashboard → Storage). Three scopes: player (private), shared (game-wide), and team (members only).
await tg.storage.put('decks', 'main', { cards: [] });
const { data } = await tg.storage.get('decks', 'main');
const keys = await tg.storage.list('decks'); Concurrency & atomic mutations
Writes support optimistic concurrency (If-Match → storage_conflict on a stale version). For counters and lists, avoid read-modify-write races with server-side atomic ops (incr, append) instead.
await tg.storage.incr('stats', 'wins', 1);
await tg.storage.append('decks', 'main', 'cards', 'card_9'); - Cloud saves
Per-slot saves with last-write-wins or conflict-safe writes, plus a durable offline queue.
- Achievements, dailies & progression
Achievements, daily rewards with streaks, quests, battle passes, and an XP/level curve.
- Inbox & rewards
The single audited path that grants currency, items, and stat rewards — exactly once.
- Economy
Server-authoritative currency, stores, inventory, loot boxes, and energy — with one hardened grant path.