Contract d5e9db071dcc19721df5d6dbf70e24e93231ad9c20f4fb18ec1a5b250eff4a77

← Back to Index 📥 Download WASM

Meta

cliver 27.0.0#5a7c5fe76530bf4248477ac812fc757146b98cc4
rssdkver 26.1.0#175aa41306f383057a8cdfc84b68d931664fc34e
rsver 1.92.0

Instances

  • CATFLEE72MGX5HTIOMW35SIKJST4ZP32QNVI5QHTFMGHOA72M6JNJMYQ
  • CCZ5NLMX7OTDFDYVGU5JAZK667V5DDMDVPYL4IK6UF6MRV62R4KFIUCL

Interface

Deposit public tokens and insert one private commitment into the pool

This lightweight deposit path is used by the MVP UI before full proof orchestration is wired in. The commitment is inserted as the left leaf of a two-leaf batch, paired with a zero placeholder.

fn deposit(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    amount: i128,
    commitment: soroban_sdk::U256,
) -> Result

Upgrade the pool contract WASM in place

Arguments

  • env - The Soroban environment
  • new_wasm_hash - Hash of the already-uploaded replacement WASM
fn upgrade(
    env: soroban_sdk::Env,
    new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), ContractError>

Get the latest root of the Merkle tree that defines the pool

fn get_root(env: soroban_sdk::Env) -> Result

Register a user's public encryption key

Allows users to publish their public key so others can send them encrypted outputs for private transfers. The account owner must authorize this call

Arguments

  • env - The Soroban environment
  • account - Account data containing owner address and public key
fn register(env: soroban_sdk::Env, account: Account)

Execute a shielded transaction with deposit handling

This is the main entry point for users to interact with the pool. If ext_amount > 0, tokens are transferred from the sender to the pool before processing the transaction.

Arguments

  • env - The Soroban environment
  • proof - Zero-knowledge proof and public inputs
  • ext_data - External transaction data
  • sender - Address of the transaction sender (must authorize funding transaction)

Returns

Returns Ok(()) on success, or an error if validation fails

fn transact(
    env: soroban_sdk::Env,
    proof: Proof,
    ext_data: ExtData,
    sender: soroban_sdk::Address,
) -> Result<(), ContractError>

Get deterministic public pool configuration

fn get_config(env: soroban_sdk::Env) -> Result

Update the contract administrator

Transfers administrative control to a new address. Requires authorization from the current admin.

Arguments

  • env - The Soroban environment
  • new_admin - New address that will have administrative permissions
fn update_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), ContractError>

Constructor: initialize the privacy pool contract

Sets up the contract with the specified token, verifier, and Merkle tree configuration. This function can only be called once.

Arguments

  • env - The Soroban environment
  • admin - Address of the contract administrator
  • token - Address of the token contract for deposits/withdrawals
  • verifier - Address of the ZK proof verifier contract
  • asp_membership - Address of the ASP Membership contract
  • asp_non_membership - Address of the ASP Non-Membership contract
  • maximum_deposit_amount - Maximum allowed deposit per transaction
  • fee_recipient - Address that receives protocol fees
  • fee_bps - Protocol fee in basis points (0-10_000)
  • levels - Number of levels in the commitment Merkle tree (1-32)

The MVP keeps paused defaulted to false at deploy time.

Returns

Returns Ok(()) on success, or an error if already initialized or invalid configuration

fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    token: soroban_sdk::Address,
    verifier: soroban_sdk::Address,
    asp_membership: soroban_sdk::Address,
    asp_non_membership: soroban_sdk::Address,
    maximum_deposit_amount: soroban_sdk::U256,
    fee_recipient: soroban_sdk::Address,
    fee_bps: u32,
    levels: u32,
) -> Result<(), ContractError>

Return whether a nullifier has already been spent.

Clients can use this view for diagnostics and indexer reconciliation. Spending still happens only through shielded transactions.

fn has_nullifier(
    env: soroban_sdk::Env,
    nullifier: soroban_sdk::U256,
) -> Result

Return whether a commitment has already been inserted into the pool.

deposit returns the stable Merkle leaf index for the inserted commitment. This lightweight view lets clients and tests check the duplicate guard without reading raw contract storage.

fn has_commitment(
    env: soroban_sdk::Env,
    commitment: soroban_sdk::U256,
) -> Result

Update the ZK proof verifier contract address

Arguments

  • env - The Soroban environment
  • new_verifier - New verifier contract address
fn update_verifier(
    env: soroban_sdk::Env,
    new_verifier: soroban_sdk::Address,
) -> Result<(), ContractError>

Return the canonical external-data hash used by transact.

Off-chain proof adapters and local fixtures can call this view to verify they are binding the exact same public withdrawal/send data as the pool.

fn get_ext_data_hash(
    env: soroban_sdk::Env,
    ext_data: ExtData,
) -> soroban_sdk::BytesN<32>

Update the ASP Membership contract address

Changes the ASP Membership contract address. Requires admin authorization.

Arguments

  • env - The Soroban environment
  • new_asp_membership - New ASP Membership contract address
fn update_asp_membership(
    env: soroban_sdk::Env,
    new_asp_membership: soroban_sdk::Address,
) -> Result<(), ContractError>

Get the current Merkle root from the ASP Membership contract

Makes a cross-contract call to retrieve the current root of the membership Merkle tree.

Arguments

  • env - The Soroban environment

Returns

The current membership Merkle root as U256

fn get_asp_membership_root(
    env: soroban_sdk::Env,
) -> Result

Update the ASP Non-Membership contract address

Changes the ASP Non-Membership contract address. Requires admin authorization.

Arguments

  • env - The Soroban environment
  • new_asp_non_membership - New ASP Non-Membership contract address
fn update_asp_non_membership(
    env: soroban_sdk::Env,
    new_asp_non_membership: soroban_sdk::Address,
) -> Result<(), ContractError>

Get the current Merkle root from the ASP Non-Membership contract

Makes a cross-contract call to retrieve the current root of the non-membership Sparse Merkle tree.

Arguments

  • env - The Soroban environment

Returns

The current non-membership Merkle root as U256

fn get_asp_non_membership_root(
    env: soroban_sdk::Env,
) -> Result
fn approve(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    spender: soroban_sdk::Address,
    amount: i128,
)
fn balance(env: soroban_sdk::Env, id: soroban_sdk::Address) -> i128
fn transfer(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    to: soroban_sdk::Address,
    amount: i128,
)
fn allowance(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    spender: soroban_sdk::Address,
) -> i128
fn transfer_from(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    to: soroban_sdk::Address,
    amount: i128,
)

Imports

WebAssembly Text (WAT) ▶