Contract 5d934aedc1ab9ff882ad807586bd9da87996ecb040b661d2b7810f9193ce3d75

← Back to Index 📥 Download WASM

Meta

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

Instances

  • CBEI46PDXZORNHDO33Z7O6UPN65KDN7PVLHM5VGZNIGS5UT2VRP5SXIE

Interface

Find a key in the tree

Public entry point for searching the tree. Returns comprehensive information about the key including whether it exists, its value, and the Merkle path siblings required for proof generation.

fn find_key(
    env: soroban_sdk::Env,
    key: soroban_sdk::U256,
) -> Result

Get the current root of the tree

Returns the root hash of the Sparse Merkle tree.

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

Delete a key from the tree

Removes a leaf from the Sparse Merkle tree, handling both sparse branches (single child) and mixed branches (two populated children). When a leaf is deleted, its sibling may be promoted to replace the parent node, collapsing the tree structure. Requires admin authorization.

fn delete_leaf(
    env: soroban_sdk::Env,
    key: soroban_sdk::U256,
) -> Result<(), soroban_sdk::Error>

Insert a new key-value pair into the tree

Adds a new leaf to the Sparse Merkle tree, building any missing intermediate nodes. Handles collision cases where a new key shares a path prefix with an existing leaf by extending the tree depth. Requires admin authorization.

fn insert_leaf(
    env: soroban_sdk::Env,
    key: soroban_sdk::U256,
    value: soroban_sdk::U256,
) -> Result<(), soroban_sdk::Error>

Update a key-value pair in the tree

Changes the value associated with an existing key. Recomputes all nodes along the path from the leaf to the root, removing old nodes and creating new ones. Requires admin authorization.

fn update_leaf(
    env: soroban_sdk::Env,
    key: soroban_sdk::U256,
    new_value: soroban_sdk::U256,
) -> Result<(), soroban_sdk::Error>

Update the admin address

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

fn update_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)

Constructor: initialize the contract with an admin address and an empty tree

fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Verify non-membership proof for a key

Verifies that a key is NOT in the tree by checking the provided Merkle proof. The proof includes siblings along the path and collision information (not_found_key/value at the leaf). Reconstructs the root from the proof and compares it with the stored root.

fn verify_non_membership(
    env: soroban_sdk::Env,
    key: soroban_sdk::U256,
    siblings: soroban_sdk::Vec,
    not_found_key: soroban_sdk::U256,
    not_found_value: soroban_sdk::U256,
) -> 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) ▶