Skip to main content
fn get_plan_subscribers(env: Env, plan_id: u64) -> Vec<u64>
Returns a vector of all subscription IDs associated with the given plan. This is a read-only function. No transaction signature is required.

Parameters

NameTypeDescription
plan_idu64The plan ID to query.

Authorization

None. This is a read-only query.

Return value

Vec<u64> - a list of subscription IDs on the plan. Returns an empty vector if the plan has no subscriptions.

Error cases

None. Returns an empty vector if the plan has no subscriptions.

Examples

import { VowenaClient, NETWORKS } from "vowena";

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

const subIds = await client.getPlanSubscribers(1);
console.log("Subscription IDs on plan 1:", subIds); // e.g., [1, 2, 4, 8]
console.log("Total subscribers:", subIds.length);

// Get details for each subscriber
for (const subId of subIds) {
  const sub = await client.getSubscription(subId);
  console.log(`Sub ${subId}: ${sub.subscriber}, status: ${sub.status}`);
}
This function is useful for building merchant dashboards that show subscriber counts and for keeper bots that need to iterate over all subscriptions on a plan to find due charges.