Skip to main content
fn initialize(env: Env, admin: Address)
Sets the admin address and initializes the auto-incrementing counters (NextPlanId = 1, NextSubId = 1). This function can only be called once - subsequent calls will fail with AlreadyInitialized.
This is a one-time setup function. Once called, it cannot be called again. Make sure the admin address is correct before deploying.

Parameters

NameTypeDescription
adminAddressThe admin address that will be stored in instance storage.

Authorization

None. This function has no require_auth() call - it relies on the fact that it can only succeed once. The first caller sets the admin.

Return value

None (void).

Events emitted

None.

Error cases

CodeNameDescription
1AlreadyInitializedThe contract has already been initialized.

Examples

This is typically a one-time setup performed via the CLI immediately after contract deployment.
soroban contract invoke \
  --id CONTRACT_ID \
  --network testnet \
  --source DEPLOYER_SECRET \
  -- \
  initialize \
  --admin GADMIN...ADDR
After initialization, the admin address is stored in instance storage and shares the contract’s TTL. The counters start at 1, so the first plan created will have plan_id = 1 and the first subscription will have sub_id = 1.