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
env - The Soroban environmentnew_wasm_hash - Hash of the already-uploaded replacement WASMfn 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
env - The Soroban environmentaccount - Account data containing owner address and public keyfn 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.
env - The Soroban environmentproof - Zero-knowledge proof and public inputsext_data - External transaction datasender - Address of the transaction sender (must authorize funding
transaction)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.
env - The Soroban environmentnew_admin - New address that will have administrative permissionsfn 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.
env - The Soroban environmentadmin - Address of the contract administratortoken - Address of the token contract for deposits/withdrawalsverifier - Address of the ZK proof verifier contractasp_membership - Address of the ASP Membership contractasp_non_membership - Address of the ASP Non-Membership contractmaximum_deposit_amount - Maximum allowed deposit per transactionfee_recipient - Address that receives protocol feesfee_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 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
env - The Soroban environmentnew_verifier - New verifier contract addressfn 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.
env - The Soroban environmentnew_asp_membership - New ASP Membership contract addressfn 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.
env - The Soroban environmentThe 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.
env - The Soroban environmentnew_asp_non_membership - New ASP Non-Membership contract addressfn 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.
env - The Soroban environmentThe 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,
)