Contract 3b6682171f3f9cd45053245d30a293fd37f6ddfff816c18812a48089369e1f4e

← Back to Index 📥 Download WASM

Meta

cliver 23.2.0#8c559e832fd969aa469784b66e70891fadf94f0a
rssdkver 25.1.0#86c50a1ea4f87b40add3064ff9df95c7553565c5
rsver 1.92.0

Instances

  • CAHTMDGJXNCMFESUR2KBQPWOKD4LDGWHJUDMR3SI7IYNLFM2WYAJMI5L

Interface

Get the current Merkle root

Returns the current root hash of the Merkle tree.

Arguments

  • env - The Soroban environment

Returns

The current Merkle root as U256

Panics

Panics if the contract has not been initialized

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

Hash two U256 values using Poseidon2 compression

Computes the Poseidon2 hash of two field elements in compression mode. This is the core hashing function used for Merkle tree operations.

Arguments

  • env - The Soroban environment
  • left - Left input value
  • right - Right input value

Returns

The Poseidon2 hash result as U256

fn hash_pair(
    env: soroban_sdk::Env,
    left: soroban_sdk::U256,
    right: soroban_sdk::U256,
) -> soroban_sdk::U256

Insert a new leaf into the Merkle tree

Adds a new member to the Merkle tree and updates the root. The leaf is inserted at the next available index and the tree is updated efficiently by only recomputing the hashes along the path to the root. Only the admin can insert leaves.

Arguments

  • env - The Soroban environment
  • leaf - The leaf value to insert (typically a commitment or hash)

Returns

Returns Ok(()) on success, or MerkleTreeFull if the tree is at capacity

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

Update the contract administrator

Changes the admin address to a new address. Only the current admin can call this function.

Arguments

  • env - The Soroban environment
  • new_admin - Address of the new administrator
fn update_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Constructor: initialize the ASP Membership contract

Creates a new Merkle tree with the specified number of levels and sets the admin address. The tree is initialized with zero hashes at each level.

Arguments

  • env - The Soroban environment
  • admin - Address of the contract administrator
  • levels - Number of levels in the Merkle tree (must be in range [1..32])

Returns

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

Panics

Panics if levels is 0 or greater than 32

fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    levels: u32,
) -> Result<(), soroban_sdk::Error>
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) ▶