One-time setup. Records the admin (the deployer) and the default token (the XLM Stellar Asset Contract), and unpauses the contract.
fn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
token: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
Deposit amount of token toward the (saver, goal_id) goal, locking it
in the contract. Creates the goal on first deposit (binding its target
and token); accumulates on subsequent deposits. Returns the new balance.
Auth: requires the saver's signature. The same authorization covers the
inner SAC transfer(saver -> contract).
fn deposit(
env: soroban_sdk::Env,
saver: soroban_sdk::Address,
goal_id: soroban_sdk::BytesN<32>,
token: soroban_sdk::Address,
target: i128,
amount: i128,
) -> Result
Withdraw the full held balance of (saver, goal_id) back to the saver and
close the goal. Allowed at any time by the goal's owner. Returns the amount
paid out. Pausing the contract never blocks this — funds can't be trapped.
Auth: requires the saver's signature.
fn withdraw(
env: soroban_sdk::Env,
saver: soroban_sdk::Address,
goal_id: soroban_sdk::BytesN<32>,
) -> Result
fn get_goal(
env: soroban_sdk::Env,
saver: soroban_sdk::Address,
goal_id: soroban_sdk::BytesN<32>,
) -> Result
fn balance(
env: soroban_sdk::Env,
saver: soroban_sdk::Address,
goal_id: soroban_sdk::BytesN<32>,
) -> i128
fn total_saved(env: soroban_sdk::Env) -> i128
fn is_paused(env: soroban_sdk::Env) -> bool
fn get_token(env: soroban_sdk::Env) -> Result
fn get_admin(env: soroban_sdk::Env) -> Result
fn pause(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn unpause(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn set_admin(
env: soroban_sdk::Env,
new_admin: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
Replace the contract's own code (admin-gated). Enables shipping fixes without migrating saver balances.
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>