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<(), soroban_sdk::Error>
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<(), soroban_sdk::Error>
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 transactionlevels - Number of levels in the commitment Merkle tree (1-32)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,
levels: u32,
) -> Result<(), soroban_sdk::Error>
Check whether a pool Merkle root is still in the recent root history.
env - The Soroban environmentroot - Pool Merkle root to checkfn is_known_root(
env: soroban_sdk::Env,
root: soroban_sdk::U256,
) -> Result
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<(), soroban_sdk::Error>
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<(), soroban_sdk::Error>
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,
)