Skip to content
Next — unreleased

Loyalty points

View as Markdown

Loyalty tracks what a player has contributed to their faction over a period, and what that has accumulated. Reads and actions are separate capability-only entries; neither is composed into the root client.

import {
getLoyaltyEpoch,
getLoyaltyContributionsByProfile,
} from '@aephia/atlas-kit/loyalty';

A loyalty epoch is a window. Contributions belong to one, and reading a contribution without knowing its epoch tells you less than it looks like it does.

const epochs = await getLoyaltyEpochsByFaction(ctx, factionId);
const contributions = await getLoyaltyContributionsByProfile(
ctx,
profileAddress,
);

An epoch’s state — upcoming, running, concluded — is derived deterministically from the epoch’s own timing rather than read from a status field. The SDK computes it so that every consumer computes it the same way, rather than each application inventing slightly different boundary handling.

Accumulated rewards sit in a bank:

const bank = await maybeGetLoyaltyAtlasBank(ctx, profileAddress, factionId);

maybe because a profile that has never contributed has no bank. Absence is an answer.

The action entry plans one full-balance claim. It deliberately has no amount input: the loaded Bank’s exact raw balance is the claim amount. Supply an explicit Unix timestamp for deterministic expiry validation and address-only authorization:

import { planClaimLoyaltyAtlas } from '@aephia/atlas-kit/loyalty/actions';
if (bank) {
const plan = await planClaimLoyaltyAtlas(ctx, bank, {
atUnixSeconds: 1_786_000_000n,
authorization,
});
console.log(plan.describe());
}

The result is an inert Plan; planning does not sign or submit. Permission, final freshness, and concurrent claims remain chain-authoritative.

Contributions are per epoch. Summing across epochs is your job, and whether that sum is meaningful depends on what you are asking.

Amounts are bigint. ATLAS values in particular are large.

A concluded epoch still reads. Its data does not disappear when it ends. Check the projected lifecycle rather than assuming a readable epoch is the current one.

  • loyalty — every export in this entry
  • loyalty/actions — full-balance claim planning
  • factions — the faction being contributed to
  • rewards — the other ATLAS-denominated capability