One-time setup. Fails with AlreadyExists if called more than once.
fn init(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
usdc_token: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
Replace the contract's WASM with a new version.
Only callable by the admin set in init.
Storage (escrows, milestones, counter, admin, usdc token) is preserved.
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>
fn get_escrow(
env: soroban_sdk::Env,
escrow_id: u32,
) -> Result
Client transfers USDC into the contract.
fn fund_escrow(env: soroban_sdk::Env, escrow_id: u32) -> Result<(), soroban_sdk::Error>
Anyone can call this after the deadline has passed to release funds to the freelancer (client was silent). Full release minus platform fee.
fn auto_release(
env: soroban_sdk::Env,
escrow_id: u32,
) -> Result<(), soroban_sdk::Error>
Client cancels before work begins. Refunds USDC if already funded.
fn cancel_escrow(
env: soroban_sdk::Env,
escrow_id: u32,
) -> Result<(), soroban_sdk::Error>
Create a new escrow. Returns the escrow ID.
fn create_escrow(
env: soroban_sdk::Env,
client: soroban_sdk::Address,
freelancer: soroban_sdk::Address,
amount_usdc: i128,
min_guarantee_pct: u32,
deadline: u64,
title: soroban_sdk::String,
description: soroban_sdk::String,
) -> Result
Returns the milestone list, or an empty Vec if none were set (legacy single-payment escrows).
fn get_milestones(env: soroban_sdk::Env, escrow_id: u32) -> soroban_sdk::Vec
Define the milestone schedule for an escrow.
Rules:
Calling this a second time replaces the previous schedule entirely.
fn set_milestones(
env: soroban_sdk::Env,
escrow_id: u32,
titles: soroban_sdk::Vec,
amounts: soroban_sdk::Vec,
) -> Result<(), soroban_sdk::Error>
Client approves delivery; funds are released to freelancer (minus platform fee).
fn approve_release(
env: soroban_sdk::Env,
escrow_id: u32,
) -> Result<(), soroban_sdk::Error>
Admin resolves a dispute by specifying how to split the remaining funds
(after the minimum guarantee was already paid in trigger_dispute).
freelancer_pct is 0–100 representing the freelancer's share of the remainder.
fn resolve_dispute(
env: soroban_sdk::Env,
escrow_id: u32,
freelancer_pct: u32,
) -> Result<(), soroban_sdk::Error>
Freelancer submits deliverable hash.
fn submit_delivery(
env: soroban_sdk::Env,
escrow_id: u32,
delivery_hash: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>
Client or freelancer raises a dispute after delivery.
caller must be either the client or the freelancer.
fn trigger_dispute(
env: soroban_sdk::Env,
escrow_id: u32,
caller: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
fn get_escrow_count(env: soroban_sdk::Env) -> u32
Client approves a delivered milestone and releases its payment slice. Per-milestone fee = milestone.amount_usdc * platform_fee_pct / 10_000. Final milestone approval marks the escrow Completed. Returns true when this was the final milestone.
fn approve_milestone(
env: soroban_sdk::Env,
escrow_id: u32,
milestone_index: u32,
) -> Result
Freelancer acknowledges and starts work.
fn confirm_freelancer(
env: soroban_sdk::Env,
escrow_id: u32,
) -> Result<(), soroban_sdk::Error>
Freelancer submits proof-of-work for the currently Active milestone. Escrow status stays Active so the client can approve milestone-by-milestone.
fn submit_milestone_delivery(
env: soroban_sdk::Env,
escrow_id: u32,
delivery_hash: soroban_sdk::BytesN<32>,
) -> Result