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 campaign with a fundraising goal, owned by organizer and
denominated in token (the XLM SAC by default). Fails if the id is taken.
Auth: requires the organizer's signature.
fn open_campaign(
env: soroban_sdk::Env,
organizer: soroban_sdk::Address,
campaign_id: soroban_sdk::BytesN<32>,
token: soroban_sdk::Address,
goal: i128,
) -> Result<(), soroban_sdk::Error>
Donate amount of the campaign's token toward campaign_id, locking it in
the contract. Tracks the campaign total and the donor's lifetime amount;
increments the distinct-donor count on a wallet's first gift. Returns the
new lifetime raised total.
Auth: requires the donor's signature. The same authorization covers the
inner SAC transfer(donor -> contract).
fn donate(
env: soroban_sdk::Env,
donor: soroban_sdk::Address,
campaign_id: soroban_sdk::BytesN<32>,
amount: i128,
) -> Result
Disburse amount of the held balance to recipient, appending an
immutable SpendRecord (recipient, amount, memo = sha256 of the payout
note, ledger sequence) to the campaign's on-chain spend ledger. Returns
the index of the new ledger entry.
Auth: requires the campaign organizer's signature; cannot exceed the held balance.
fn disburse(
env: soroban_sdk::Env,
organizer: soroban_sdk::Address,
campaign_id: soroban_sdk::BytesN<32>,
recipient: soroban_sdk::Address,
amount: i128,
memo: soroban_sdk::BytesN<32>,
) -> Result
Close a campaign to new donations (the organizer can still disburse the remaining held balance afterward). Auth: campaign organizer.
fn close_campaign(
env: soroban_sdk::Env,
organizer: soroban_sdk::Address,
campaign_id: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>
fn get_campaign(
env: soroban_sdk::Env,
campaign_id: soroban_sdk::BytesN<32>,
) -> Result
fn raised(env: soroban_sdk::Env, campaign_id: soroban_sdk::BytesN<32>) -> i128
fn balance(env: soroban_sdk::Env, campaign_id: soroban_sdk::BytesN<32>) -> i128
fn donor_amount(
env: soroban_sdk::Env,
campaign_id: soroban_sdk::BytesN<32>,
donor: soroban_sdk::Address,
) -> i128
fn spend_count(env: soroban_sdk::Env, campaign_id: soroban_sdk::BytesN<32>) -> u32
fn get_spends(
env: soroban_sdk::Env,
campaign_id: soroban_sdk::BytesN<32>,
) -> soroban_sdk::Vec
fn total_raised(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 campaign balances.
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>