Skip to main content
The Vowena contract exposes 17 functions covering the full subscription lifecycle. This reference documents every function with its parameters, authorization requirements, events, and error codes.
Write functions return assembled XDR via the SDK. You sign the transaction with your wallet and submit it to the network. Read functions query contract state directly and return data without requiring a transaction signature.

Functions by category

Setup

FunctionDescriptionAuth
initializeOne-time contract setup. Sets admin and initializes counters.None (first call only)

Plans

FunctionDescriptionAuth
create_planCreates a new billing plan with pricing, period, trials, and limits.Merchant
update_plan_amountUpdates the billing amount within the price ceiling.Merchant

Subscriptions

FunctionDescriptionAuth
subscribeSubscribes to a plan. Sets token allowance and creates the subscription.Subscriber
cancelCancels a subscription immediately. Irreversible.Subscriber or Merchant
reactivateReactivates a paused subscription. Re-approves allowance and attempts charge.Subscriber

Billing

FunctionDescriptionAuth
chargeCharges a due subscription. Permissionless - anyone can call.None
refundRefunds a subscriber from the merchant’s wallet.Merchant

Migrations

FunctionDescriptionAuth
request_migrationRequests migration of all subscribers from one plan to another.Merchant
accept_migrationAccepts a pending migration. Cancels old sub and creates new one.Subscriber
reject_migrationRejects a pending migration. Stays on current plan.Subscriber

Read-only

FunctionDescriptionAuth
get_planReturns the Plan struct for a given plan ID.None
get_subscriptionReturns the Subscription struct for a given subscription ID.None
get_merchant_plansReturns all plan IDs belonging to a merchant.None
get_subscriber_subscriptionsReturns all subscription IDs for a subscriber.None
get_plan_subscribersReturns all active subscription IDs on a plan.None
extend_ttlExtends TTL of plan and subscription entries to prevent archival.None

Authorization model

Vowena uses Soroban’s require_auth() pattern. When a function requires authorization, the caller must sign the transaction with the appropriate keypair:
  • Merchant functions - the merchant address stored on the plan must sign.
  • Subscriber functions - the subscriber address stored on the subscription must sign.
  • Permissionless functions - charge() is the only write function that requires no authorization. Anyone can call it, and the contract validates all conditions on-chain.
Read-only functions (get_plan, get_subscription, etc.) never require a signature. They query contract state directly via Soroban’s simulation endpoint.

Error codes

Every error returned by the contract maps to a numeric code:
CodeNameDescription
1AlreadyInitializedContract has already been initialized
3InvalidAmountAmount is zero or negative
4InvalidPeriodPeriod is zero
5CeilingBelowAmountPrice ceiling is less than the plan amount
6PlanNotFoundNo plan exists with the given ID
7PlanInactivePlan is not accepting new subscribers
8SubNotFoundNo subscription exists with the given ID
9UnauthorizedCaller is not authorized for this action
10AmountExceedsCeilingNew amount exceeds the plan’s price ceiling
11MerchantMismatchOld and new plans belong to different merchants
12NoMigrationPendingNo migration has been requested for this subscription
13NotPausedSubscription is not in a paused state

SDK vs CLI

Every function can be called through the TypeScript SDK or the Soroban CLI. The SDK wraps each function with a typed builder method that returns assembled XDR for signing. The CLI is useful for one-off operations and scripting.
const tx = await client.buildFunctionName({ ...params });
const signed = await signTransaction(tx);
const result = await client.submitTransaction(signed);