Lock funds for a cross-chain atomic swap.
initiator: party locking funds (must auth)counterparty: party who can release with the secrettoken: SAC token addressamount: amount to locksecret_hash: sha256(secret) — preimage is the unlock keytimeout_ledgers: ledgers from now until initiator can refundReturns the swap_id (sha256 of secret_hash for determinism).
fn lock(
env: soroban_sdk::Env,
initiator: soroban_sdk::Address,
counterparty: soroban_sdk::Address,
token: soroban_sdk::Address,
amount: i128,
secret_hash: soroban_sdk::BytesN<32>,
timeout_ledgers: u32,
) -> soroban_sdk::BytesN<32>
Refund initiator after timeout. Anyone can call this.
fn refund(env: soroban_sdk::Env, swap_id: soroban_sdk::BytesN<32>)
Release funds to counterparty by revealing the secret.
The secret is emitted in the event — this is intentional. The counterparty's agent on chain B watches for this event and uses the revealed secret to claim funds there.
fn release(
env: soroban_sdk::Env,
swap_id: soroban_sdk::BytesN<32>,
secret: soroban_sdk::Bytes,
)
Get full swap data — view function.
fn get_swap(env: soroban_sdk::Env, swap_id: soroban_sdk::BytesN<32>) -> AtomicSwap
Get swap status — view function.
fn get_status(env: soroban_sdk::Env, swap_id: soroban_sdk::BytesN<32>) -> SwapStatus