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
| Name | Type | Description |
|---|
plan_id | u64 | The 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}`);
}
soroban contract invoke \
--id CONTRACT_ID \
--network testnet \
-- \
get_plan_subscribers \
--plan_id 1
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.