Contract a5e4bc1d6777197511946fd175a455fbe6a6593a40ef724bfcbd325f3bd46ede

← Back to Index 📥 Download WASM

Meta

rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.97.1

Instances

  • CB5TCVEBQDUI2GSQZLMUA2H7FHFHCQLKVGZYJZBECPDVKZCI3PFZUGPU

Interface

Lock funds for a cross-chain atomic swap.

  • initiator: party locking funds (must auth)
  • counterparty: party who can release with the secret
  • token: SAC token address
  • amount: amount to lock
  • secret_hash: sha256(secret) — preimage is the unlock key
  • timeout_ledgers: ledgers from now until initiator can refund

Returns 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

Imports

WebAssembly Text (WAT) ▶