Mining
Mining is a fleet sitting at an asteroid, extracting a resource over time. Two things are worth reading: what a deposit holds, and what a fleet is currently pulling out of it.
Is this fleet mining?
Section titled “Is this fleet mining?”const mining = await fleet.mining.get();
if (mining === undefined) { // Not mining. This is a normal state, not an error.}undefined is the answer for a fleet that is docked, in transit, or idle. The
SDK returns it rather than throwing, because “not mining” is an ordinary fact
about a fleet rather than a failure to read one.
Rates, not totals
Section titled “Rates, not totals”The important mental shift: mining gives you a rate and a start, not a running total. Nothing on chain increments a counter as ore accumulates.
What you get is enough to compute the amount yourself: when extraction started, the rate it runs at, and what resource is coming out. The amount at any moment is derived from those plus the current time.
That is why a mining read has a timestamp that matters, and why caching it for a long time is misleading in a way that caching a fleet’s name is not.
Deposits
Section titled “Deposits”A resource deposit is the asteroid’s side of the same relationship:
const deposit = await getResourceDeposit(ctx, depositAddress);It describes what the asteroid holds and the properties that govern extraction from it.
Gotchas
Section titled “Gotchas”Rates depend on the fleet, not just the asteroid. What a fleet extracts per unit time is a function of its ships and the resource’s properties together. Two fleets at the same asteroid do not mine at the same speed.
Derived amounts are computed, not stored. If you display an accumulating total, you are computing it. Recompute it on a timer rather than reading it once and treating it as current.
A deposit can be read without a fleet. Deposits and fleet-mining state are separate reads. You do not need one to get the other.