Contract 1e749dd0d04ccc61a2504641038ca9718149d1760f0b538a92da0a869266302c

← Back to Index 📥 Download WASM

Meta

rssdkver 25.1.1#94c2a3b3a5ded6b9cf9cef0c207bf8804f3eb294
rsver 1.93.1

Instances

  • CBMQYO5IMT2P2AXSOEB6ON3CA3WLOYRVHEK26CK4T7G6H7YHCM2HADQ5

Interface

Initialize the mixer contract.

  • relayer: address authorized to submit withdrawals on behalf of recipients.
  • token: SAC address for the deposited asset (native XLM on testnet: CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC).
fn init(env: soroban_sdk::Env)

Record a commitment in the Merkle tree.

The token transfer is handled separately by the frontend — the user calls the SAC's transfer() directly to fund the contract, then calls this function to store the commitment on-chain.

This keeps the deposit function free of amount information.

fn deposit(
    env: soroban_sdk::Env,
    depositor: soroban_sdk::Address,
    commitment: soroban_sdk::BytesN<32>,
) -> u32
fn is_spent(env: soroban_sdk::Env, nullifier_hash: soroban_sdk::BytesN<32>) -> bool

Withdraw XLM from the mixer to a recipient.

Called by the relayer AFTER verifying the ZK proof off-chain.

proof_amount is the BN254 field element from the ZK proof's public inputs that encodes the withdrawal amount in stroops. The contract derives the actual i128 amount by interpreting the lower 16 bytes of the 32-byte big-endian field element.

The contract:

  1. Verifies the caller is the authorized relayer
  2. Derives the amount from proof_amount
  3. Ensures the nullifier has not been spent (prevents double-withdraw)
  4. Marks the nullifier as spent
  5. Transfers XLM from the contract to the recipient via SAC
fn withdraw(
    env: soroban_sdk::Env,
    nullifier_hash: soroban_sdk::BytesN<32>,
    recipient: soroban_sdk::Address,
    proof_amount: soroban_sdk::BytesN<32>,
)
fn get_token(env: soroban_sdk::Env) -> soroban_sdk::Address
fn get_balance(env: soroban_sdk::Env) -> i128
fn is_valid_root(env: soroban_sdk::Env, root: soroban_sdk::BytesN<32>) -> bool
fn get_next_index(env: soroban_sdk::Env) -> u32
fn get_latest_root(env: soroban_sdk::Env) -> soroban_sdk::BytesN<32>

Imports

WebAssembly Text (WAT) ▶