Skip to main content
fn get_plan(env: Env, plan_id: u64) -> Plan
Returns the full Plan struct for the given plan ID. This is a read-only function that queries contract state directly. No transaction signature is required.

Parameters

NameTypeDescription
plan_idu64The ID of the plan to retrieve.

Authorization

None. This is a read-only query.

Return value

Plan struct with the following fields:
FieldTypeDescription
idu64Unique plan identifier
merchantAddressMerchant who created the plan
tokenAddressToken contract address (e.g., USDC)
amounti128Amount charged per period (in stroops)
periodu64Billing period in seconds
trial_periodsu32Number of free trial periods
max_periodsu32Max billing periods (0 = unlimited)
grace_periodu64Grace window in seconds after failed charge
price_ceilingi128Maximum amount the plan can ever charge
created_atu64Ledger timestamp at creation
activeboolWhether the plan accepts new subscribers

Error cases

CodeNameDescription
6PlanNotFoundNo plan exists with the given plan_id.

Examples

import { VowenaClient, NETWORKS, fromStroops } from "vowena";

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

const plan = await client.getPlan(1);

console.log("Merchant:", plan.merchant);
console.log("Amount:", fromStroops(plan.amount), "USDC");
console.log("Period:", plan.period / 86400, "days");
console.log("Trial periods:", plan.trialPeriods);
console.log("Active:", plan.active);