Economy
Server-authoritative currency, stores, inventory, loot boxes, and energy — with one hardened grant path.
The economy is entirely server-authoritative: the client requests an action (buy, open, spend) and the server checks the price/balance/odds and applies the result. A client can never mint currency or grant an item.
The one grant path
Every reward — from a purchase, a loot box, an achievement, a daily claim — is delivered into the player's INBOX and granted exactly-once when they claim it. This is the single audited path that mutates a wallet or inventory, so a reward can't be double-granted by a retry.
const items = await tg.inbox.list();
for (const it of items) if (it.claimable) await tg.inbox.claim(it.id); Stores & idempotency
Buying is idempotent — pass a stable idem key so a network retry doesn't double-charge. Failures are typed: insufficient_funds, out_of_stock, store_limit_reached.
await tg.economy.buy('main_store', listingId, { idem: uuid }); Loot boxes & energy
Loot boxes disclose their odds (tg.economy.loot.odds) and roll server-side with verifiable RNG. Energy meters (stamina, lives) regenerate over server time; spending fails with out_of_energy. Loot and IAP are age-gated where required — see the compliance guide.
- Cloud saves
Per-slot saves with last-write-wins or conflict-safe writes, plus a durable offline queue.
- Key-value storage & collections
Structured per-player, shared, and team collections with OCC and atomic mutations.
- 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.