Skip to main content
fn get_subscription(env: Env, sub_id: u64) -> Subscription
Returns the full Subscription struct for the given subscription ID. This is a read-only function that queries contract state directly - no transaction signature is required.

Parameters

NameTypeDescription
sub_idu64The ID of the subscription to retrieve.

Authorization

None. This is a read-only query.

Return value

Subscription struct with the following fields:
FieldTypeDescription
idu64Unique subscription identifier
plan_idu64The plan this subscription belongs to
subscriberAddressSubscriber’s wallet address
statusSubscriptionStatusCurrent lifecycle state (Active, Paused, Cancelled, Expired)
created_atu64Ledger timestamp at creation
periods_billedu32Number of periods successfully charged
next_billing_timeu64Timestamp when next charge is due
failed_atu64Timestamp of last failed charge (0 = none)
migration_targetu64Target plan ID for pending migration (0 = none)
cancelled_atu64Timestamp of cancellation (0 = not cancelled)

Error cases

CodeNameDescription
8SubNotFoundNo subscription exists with the given sub_id.

Examples

import { VowenaClient, NETWORKS } from "vowena";

const client = new VowenaClient({
  contractId: NETWORKS.testnet.contractId,
  rpcUrl: NETWORKS.testnet.rpcUrl,
  networkPassphrase: NETWORKS.testnet.networkPassphrase,
});

const sub = await client.getSubscription(1);

console.log("Plan ID:", sub.planId);
console.log("Subscriber:", sub.subscriber);
console.log("Status:", sub.status);
console.log("Periods billed:", sub.periodsBilled);
console.log("Next billing:", new Date(sub.nextBillingTime * 1000));

if (sub.migrationTarget > 0) {
  console.log("Migration pending to plan:", sub.migrationTarget);
}