Skip to content

Fleets

A fleet is a group of ships that move and act together. Ships do not travel individually, so the fleet is the unit almost everything else attaches to: cargo, mining, scanning, combat.

const character = await sage.characters.forProfile(profileAddress);
const fleets = await character.fleets.all();

Fleet state is a union, not a status string

Section titled “Fleet state is a union, not a status string”

This is the single most important thing to understand about fleets. A fleet’s state is a discriminated union, and what data is available depends on which variant you have:

if (fleet.state.kind === 'docked') {
const system = await getStarSystem(ctx, fleet.state.system.address);
}

The variants are idle, docked, mining, warp, subwarp, respawn, and claimStakeTransfer.

The reason this matters: a fleet’s location is not a field. There is no fleet.system. Where a fleet is depends on what it is doing — a docked fleet is at a starbase, a warping fleet is between two points with an arrival time, a mining fleet is at a resource. Flattening that into one field would mean inventing a value for cases where it does not exist.

So the pattern is always: narrow on kind first, then read what that variant offers. TypeScript enforces this — reaching for state.system without narrowing is a compile error, not a runtime surprise.

const inventory = await fleet.inventory.get();
const mining = await fleet.mining.get(); // undefined when not mining

Note that mining.get() returns undefined rather than throwing when the fleet is not mining. That is a legitimate state, not an error.

Fleet names are strings, already trimmed. On chain they are fixed-width byte arrays padded with zeros. The SDK decodes and trims them, so fleet.name is "Dread Kraken", not a padded buffer.

An empty fleet list is a valid answer. A character with no fleets returns []. Do not treat it as an error.

NPC-owned fleets decode with faction: 0. Their identity comes from the owning profile, not the faction field.

Movement timings are derived, not stored. Arrival times come from the fleet’s state plus the Game account’s movement rules. Where the SDK cannot verify the arithmetic against the current program version, it declines to guess rather than reporting a number that might be wrong.

  • fleets — every export in this entry
  • cargo — what a fleet is carrying
  • world — where a fleet’s state points
  • Moving a fleet — plan and execute an explicit move