Waldrop SDK · API Reference

client.subscription

Read-side checks for plan tier, expiry, and active status. The contract's Move predicates (is_subscription_active, epochs_until_expiry) reproduced in TypeScript against parsed object state.

get

client.subscription.get({ owner: string }): Promise<SubscriptionSummary | null>

Returns the user's Subscription summary, or null if they've never called subscribe.

const sub = await client.subscription.get({ owner: "0x…" });
if (sub) console.log(`tier ${sub.planTier}, expires epoch ${sub.expiresEpoch}`);

Result

interface SubscriptionSummary {
  subscriptionId: string;   // Sui object id
  planTier: number;         // 0 = FREE, 1 = STARTER, 2 = PRO, 3 = ENTERPRISE
  startedEpoch: number;
  expiresEpoch: number;
  status: number;           // 0 = ACTIVE, 1 = CANCELLED, 2 = EXPIRED
}

isActive

client.subscription.isActive({
  owner: string;
  currentEpoch: number;
}): Promise<boolean>

true when the user has a Subscription whose status is ACTIVE or CANCELLED (cancelled subs stay active until expiry) and whose expiresEpoch is in the future. false for users with no subscription — easier for UI gating than throwing.

const epoch = (await suiClient.core.getCurrentSystemState()).systemState.epoch;
const active = await client.subscription.isActive({
  owner: "0x…",
  currentEpoch: Number(epoch),
});

epochsUntilExpiry

client.subscription.epochsUntilExpiry({
  owner: string;
  currentEpoch: number;
}): Promise<number>

Whole epochs remaining. Saturates at 0 once expired. 0 for users with no subscription.

daysUntilExpiry

client.subscription.daysUntilExpiry({
  owner: string;
  currentEpoch: number;
  epochDurationDays: number;
}): Promise<number>

epochsUntilExpiry × epochDurationDays. epochDurationDays is 1 on testnet, 14 on mainnet — read from the Walrus System object (client.cost.getPricing() .epochDays).

const { epochDays } = await client.cost.getPricing();
const days = await client.subscription.daysUntilExpiry({
  owner: "0x…",
  currentEpoch,
  epochDurationDays: epochDays || 1,
});
No write methods here

Subscribing, upgrading, cancelling, and renewing are write operations the SDK doesn't expose directly. Build the PTBs yourself with @mysten/sui

  • the exported PACKAGE_ID constant — see the dapp's lib/transactions.ts for the reference shape, or call them through the Waldrop dapp UI.
Edit this page on GitHub ↗
Waldrop · 2026cryptokarigar