Contract e9efa31e13da7dbd92dabf4cd9d6653be3d48efb83498f1d7209a2d6772e664a

← Back to Index 📥 Download WASM

Meta

cliver 27.0.0#5a7c5fe76530bf4248477ac812fc757146b98cc4
rssdkver 26.0.0#e1bf74ba6c3ddb591593f5eb5dfb85458ff714c1
rsver 1.92.0

Instances

  • CCYY3LLTVD2UW3Z4QD76PICZNIUH3PXKWJSKJVAENBIYON7QVAQIW5PP

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. If admin_insert_only is enabled (the default), only the admin can insert leaves; otherwise, anyone can call this function.

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>

Set whether admin permission is required to insert a leaf

When admin_only is true (default), only the admin can insert leaves. When false, anyone can insert leaves. Only the admin can change this setting.

Arguments

  • env - The Soroban environment
  • admin_only - Whether admin permission is required for leaf insertion
fn set_admin_insert_only(
    env: soroban_sdk::Env,
    admin_only: bool,
) -> 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) ▶