Skip to content
0.5.0 — latest

Claim stakes

View as Markdown

A claim stake is a player’s claim on a celestial body: a hub to build infrastructure on, producing resources over time rather than in a single action.

By owner, which is the usual direction:

const stakes = await character.claimStakes.all();

Or by the body, when you want to know who holds a particular place:

const stakes = await sage.claimStakes.byBody(bodyAddress);

A stake’s state.kind is one of design, active, or deactivated. Those are genuinely different situations rather than degrees of the same one:

if (stake.state.kind === 'active') {
// Producing. Other kinds are not.
}

Reading a stake and assuming it is producing is the mistake this shape exists to prevent.

A stake is not one thing — it is a plot with infrastructure on it. The snapshot carries the whole layout:

const stakes = await character.claimStakes.all();
const layouts = stakes.map((stake) => ({
buildings: stake.buildings.length,
crew: stake.neededCrew,
underConstruction: stake.constructionRemainingSeconds > 0n,
}));

buildings is what has been placed — extraction, processing, power, storage — and each wants crew. Construction is live state: a stake can be active and still have constructionRemainingSeconds left on recent changes.

Production follows the same pattern as mining: rates against a clock, not a stored total.

const output = stake.resources.netProduction;
const held = stake.resources.inventory;

netProduction is per-resource rates (consumption nets against generation — a processing chain can make a rate negative), inventory and capacity are what the stake holds right now, and lastTickAtUnixSeconds anchors the clock you project from.

A stake occupies land and pays for it: rentBalanceRaw is what remains and lastRentAtUnixSeconds when it was last settled. A dry balance eventually means eviction, and coming back from that is a respawn, not a resume.

Like crafting processes, claim stake instances cannot be computed from the character and the body — the address is assigned at creation. That is why the reads are byCharacter and byBody rather than a derivation, and why finding one you have no reference to needs discovery.

A stake in design is not yet producing. It exists, it is yours, and it yields nothing. Filter on state before summing output.

Capacity and yield come from definitions. What a stake produces depends on the body and the Game account’s rules, not on fields stored in the stake account alone.

A body can hold stakes from several players. byBody returns an array for that reason.

  • claim-stakes — every export in this entry
  • world — the bodies stakes are placed on
  • Crafting habs — the sibling deployment system, sharing the same lifecycle and rent machinery