One-time setup. Records the admin (the deployer) and the default token (the XLM Stellar Asset Contract).
fn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
token: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
Open a new trip pool owned by organizer and denominated in token (the
XLM SAC by default). Fails if the id is already taken.
Auth: requires the organizer's signature.
fn open_trip(
env: soroban_sdk::Env,
organizer: soroban_sdk::Address,
trip_id: soroban_sdk::BytesN<32>,
token: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
Contribute amount of the trip's token into the pool, locking it in the
contract. Tracks the trip total and the member's lifetime amount;
increments the distinct-member count on a wallet's first contribution.
Returns the new lifetime pooled total.
Auth: requires the member's signature. The same authorization covers the
inner SAC transfer(member -> contract).
fn contribute(
env: soroban_sdk::Env,
member: soroban_sdk::Address,
trip_id: soroban_sdk::BytesN<32>,
amount: i128,
) -> Result
Spend amount of the held balance to payee, appending an immutable
SpendRecord (payee, amount, memo = sha256 of the payout note, ledger
sequence, kind=Spend) to the trip's on-chain spend ledger. Returns the
index of the new ledger entry.
Auth: requires the trip organizer's signature; cannot exceed the held balance.
fn spend(
env: soroban_sdk::Env,
organizer: soroban_sdk::Address,
trip_id: soroban_sdk::BytesN<32>,
payee: soroban_sdk::Address,
amount: i128,
memo: soroban_sdk::BytesN<32>,
) -> Result
Refund amount of the remaining held balance back to member at trip
end, decrementing that member's tracked contribution and appending an
immutable SpendRecord (kind=Refund) to the on-chain ledger. Returns the
index of the new ledger entry.
Auth: requires the trip organizer's signature; cannot exceed the member's remaining tracked contribution nor the held balance.
fn refund(
env: soroban_sdk::Env,
organizer: soroban_sdk::Address,
trip_id: soroban_sdk::BytesN<32>,
member: soroban_sdk::Address,
amount: i128,
memo: soroban_sdk::BytesN<32>,
) -> Result
Settle a trip: block new contributions (the organizer can still spend or refund the remaining held balance afterward). Auth: trip organizer.
fn close_trip(
env: soroban_sdk::Env,
organizer: soroban_sdk::Address,
trip_id: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>
fn get_trip(
env: soroban_sdk::Env,
trip_id: soroban_sdk::BytesN<32>,
) -> Result
fn pooled(env: soroban_sdk::Env, trip_id: soroban_sdk::BytesN<32>) -> i128
fn balance(env: soroban_sdk::Env, trip_id: soroban_sdk::BytesN<32>) -> i128
fn member_amount(
env: soroban_sdk::Env,
trip_id: soroban_sdk::BytesN<32>,
member: soroban_sdk::Address,
) -> i128
fn spend_count(env: soroban_sdk::Env, trip_id: soroban_sdk::BytesN<32>) -> u32
fn get_spends(
env: soroban_sdk::Env,
trip_id: soroban_sdk::BytesN<32>,
) -> soroban_sdk::Vec
fn total_pooled(env: soroban_sdk::Env) -> i128
fn get_token(env: soroban_sdk::Env) -> Result
fn get_admin(env: soroban_sdk::Env) -> Result
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 trip balances.
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>