Replaces this contract's WASM. The new code takes effect after this
invocation completes. Fails once [Self::disable_upgrades] has run, and
while a migration is in progress.
fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Single entrypoint: verifies circuits/main.circom Groth16 proof and public signals, checks
tree root and nullifiers, appends new output commitments (with ephemeral keys, not in Merkle),
then applies public token deposits / withdrawals: publicDepositedAssets + publicDeposits
pull from from, and publicWithdrawnAssets + publicWithdrawals send to the Stellar
account from withdrawAddressHi / withdrawAddressLo.
The proof-bound escrow recipient reconstructed from public signals is the only
authorization subject. Both limbs zero means a non-sweep: both sweep output owner
coordinates must also be zero. A nonzero pair is a sweep: that account must
require_auth() (host account credentials, so multisig and rotated signers work; a
revoked key cannot), must already have a private address in the registry, and both
sweep output owner coordinates must equal that registry key.
Asset ids: Stellar contract token C... addresses encoded as two field elements (same 32-byte
split as account keys — see `cir
fn transact(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
nonce: u64,
proof_bytes: soroban_sdk::Bytes,
pub_signals_bytes: soroban_sdk::Bytes,
ciphertext_bytes: soroban_sdk::Bytes,
kyt_authorization: Option,
) -> Result<(), soroban_sdk::Error>
Gets the owner address recorded by OpenZeppelin Ownable.
fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address
Returns Some(Address) if ownership is set, or None if ownership has
been renounced.
e - Access to the Soroban environment.fn get_owner(env: soroban_sdk::Env) -> Option
fn get_registry(env: soroban_sdk::Env) -> Option
fn set_registry(env: soroban_sdk::Env, registry: soroban_sdk::Address)
fn __constructor(env: soroban_sdk::Env, tree_depth: u32, admin: soroban_sdk::Address)
Registers a new per-nonce ZK circuit configuration (VK + full circuit shape). Owner-only;
fails if nonce already has a config. Validates n_outs is even (leaves are inserted
pairwise via PairwiseLeanIMT::insert_two), n_audit_slots >= n_ins + n_outs, that
audit_offset/output_note_offset match the formula-derived layout, and that the VK's
ic length matches the resulting total public-signal count.
fn add_zk_config(
env: soroban_sdk::Env,
nonce: u64,
vk_bytes: soroban_sdk::Bytes,
n_ins: u32,
n_outs: u32,
public_n_inputs: u32,
public_n_outputs: u32,
n_audit_slots: u32,
note_audit_len: u32,
audit_offset: u32,
note_output_len: u32,
output_note_offset: u32,
) -> Result<(), soroban_sdk::Error>
Reads a registered ZK config (extending its persistent TTL), or None if absent.
fn get_zk_config(env: soroban_sdk::Env, nonce: u64) -> Option
Returns true if root appears in the recent root history (ring buffer).
All-zero bytes are never accepted.
fn is_known_root(env: soroban_sdk::Env, root: soroban_sdk::BytesN<32>) -> bool
Copies up to max_items leaves, then the frontier, then root-history
slots. Missing null-like gaps in the root ring are skipped. Re-calling
continues from the stored cursor.
fn migrate_range(env: soroban_sdk::Env, max_items: u32) -> u32
Lifts the pause without bumping the schema. Copied keys stay unread.
fn abort_migration(env: soroban_sdk::Env)
Pauses user and owner mutations and opens a batched copy into the
migration namespace. to_version must be the current schema plus one.
fn begin_migration(env: soroban_sdk::Env, to_version: u32)
Gets all commitments (leaves) in the merkle tree. Read-only view helper (not called from
transact/add_zk_config or any other state-mutating entrypoint) intended for off-chain
simulation/queries; its cost scales with count, which grows with real pool usage rather
than with a single caller-controlled input, so it does not let one transaction consume a
disproportionate share of a block's resources the way an admin/user-controlled shape
parameter would. Acknowledged dos-unbounded-operation finding.
leaves is a local in-memory Vec (vec![&env]), not persistent contract storage, so
there is no storage-side access-control concern in the push_back below either;
acknowledged dos-unexpected-revert-with-storage false positive. Both acknowledgments are
function-level because neither detector respects a #[allow] placed on the loop/statement
itself.
fn get_commitments(env: soroban_sdk::Env) -> soroban_sdk::Vec>
Gets the current merkle root of the commitment tree.
fn get_merkle_root(env: soroban_sdk::Env) -> soroban_sdk::BytesN<32>
Accepts a pending ownership transfer.
e - Access to the Soroban environment.crate::role_transfer::RoleTransferError::NoPendingTransfer] - If
there is no pending transfer to accept.["ownership_transfer_completed"][new_owner: Address]fn accept_ownership(env: soroban_sdk::Env)
Permanently disables WASM replacement. Operational owner calls stay available. Cannot be undone, and cannot run during a migration.
fn disable_upgrades(env: soroban_sdk::Env)
fn get_kyt_registry(env: soroban_sdk::Env) -> Option
Gets the current depth of the merkle tree
fn get_merkle_depth(env: soroban_sdk::Env) -> u32
fn set_kyt_registry(env: soroban_sdk::Env, kyt_registry: soroban_sdk::Address)
fn upgrades_enabled(env: soroban_sdk::Env) -> bool
Token balance held by this contract for a Stellar asset contract (C...).
fn get_token_balance(env: soroban_sdk::Env, token: soroban_sdk::Address) -> i128
Bumps the schema version and lifts the pause after the leaf replay root matches the stored Merkle root and the range cursor is finished.
fn finalize_migration(env: soroban_sdk::Env)
Ephemeral key (x, y) for a leaf index, if present.
fn get_leaf_ephemeral(
env: soroban_sdk::Env,
leaf_index: u32,
) -> Option
fn get_migrated_count(env: soroban_sdk::Env) -> u64
fn get_schema_version(env: soroban_sdk::Env) -> u32
Copies nullifier flags for the supplied hashes. Unknown hashes and repeats are no-ops. The caller does not supply the stored value.
fn migrate_nullifiers(
env: soroban_sdk::Env,
nullifiers: soroban_sdk::Vec>,
) -> u32
fn renounce_ownership(env: soroban_sdk::Env)
Initiates a 2-step ownership transfer to a new address.
Requires authorization from the current owner. The new owner must later
call accept_ownership() to complete the transfer.
e - Access to the Soroban environment.new_owner - The proposed new owner.live_until_ledger - Ledger number until which the new owner can
accept. A value of 0 cancels any pending transfer.OwnableError::OwnerNotSet] - If the owner is not set.crate::role_transfer::RoleTransferError::NoPendingTransfer] - If
trying to cancel a transfer that doesn't exist.crate::role_transfer::RoleTransferError::InvalidLiveUntilLedger] -
If the specified ledger is in the past.crate::role_transfer::RoleTransferError::InvalidPendingAccount] -
If the specified pending account is not the same as the provided new
address.fn transfer_ownership(
env: soroban_sdk::Env,
new_owner: soroban_sdk::Address,
live_until_ledger: u32,
)
Marks a registered ZK config as deprecated; subsequent transact calls referencing this
nonce fail with [Error::ZkConfigDeprecated]. Owner-only.
fn deprecate_zk_config(
env: soroban_sdk::Env,
nonce: u64,
) -> Result<(), soroban_sdk::Error>
fn require_kyt_passage(
env: soroban_sdk::Env,
passage_id: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>
Gets the number of commitments (leaves) in the merkle tree
fn get_commitment_count(env: soroban_sdk::Env) -> u32
Filled-subtree frontier after the last pairwise insert (reload on the next deposit).
fn get_pairwise_frontier(
env: soroban_sdk::Env,
) -> soroban_sdk::Vec>
publicNInputs / publicNOutputs for the nonce-0 ("standard") ZK config.
Panics with [Error::ZkConfigNotFound] when nonce 0 is unregistered. Prefer
[Self::get_zk_config] for a specific nonce.
fn get_public_slot_config(env: soroban_sdk::Env) -> (u32, u32)
Returns true if the given nullifier hash has already been consumed (used in a withdrawal).
fn is_nulifier_hash_consumed(
env: soroban_sdk::Env,
hash: soroban_sdk::BytesN<32>,
) -> bool