Claim tokens from a distribution by providing a Merkle proof.
The claimant must authorize the call. The Merkle leaf is computed as
keccak256(claimant || amount) and verified against the stored root.
Protocol fees are deducted from the claimed amount.
claimant — The address claiming tokens (must authorize).distribution_id — ID of the distribution to claim from.amount — The amount the claimant is entitled to (per the Merkle tree).proof — The Merkle proof (list of sibling hashes).fn claim(
env: soroban_sdk::Env,
claimant: soroban_sdk::Address,
distribution_id: u32,
amount: i128,
proof: soroban_sdk::Vec>,
)
Emergency upgrade — bypasses timelock. Use only in critical situations.
Admin-only.
fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Direct admin transfer (legacy, kept for backwards compatibility).
Admin-only. Prefer propose_admin + accept_admin for safety.
fn set_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
Initialize the contract with an admin address.
Must be called exactly once before any other function. The intended admin must authorize the initialization to prevent first-caller takeover attacks.
fn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
protocol_fee_address: soroban_sdk::Address,
)
Check if a user has already claimed from a distribution.
fn has_claimed(
env: soroban_sdk::Env,
distribution_id: u32,
claimant: soroban_sdk::Address,
) -> bool
Accept an admin transfer (two-step transfer, step 2).
Must be called by the address that was proposed via propose_admin().
fn accept_admin(env: soroban_sdk::Env)
Propose a new admin (two-step transfer, step 1).
Admin-only.
fn propose_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
Execute a previously proposed upgrade after the timelock has expired.
Admin-only.
fn execute_upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Propose a timelocked upgrade. The upgrade can be executed after UPGRADE_TIMELOCK_LEDGERS have passed.
Admin-only.
fn propose_upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Get the full distribution record.
fn get_distribution(env: soroban_sdk::Env, distribution_id: u32) -> DistributionRecord
Cancel a distribution and reclaim remaining (unclaimed) tokens.
The distribution creator (or contract admin) can cancel. Prevents further claims.
fn cancel_distribution(env: soroban_sdk::Env, distribution_id: u32)
Create a new Merkle distribution.
Transfers total_amount of token from the caller into this contract.
The merkle_root represents the tree of (claimant, amount) leaves.
An optional deadline (unix timestamp) can be set — after which no
more claims are accepted (0 = no deadline).
admin — The admin creating the distribution (must authorize).token — Token contract address to distribute.merkle_root — Root hash of the Merkle tree.total_amount — Total tokens to deposit into the distribution.deadline — Unix timestamp deadline (0 = no deadline).unique_ref — A unique reference identifier for this distribution.The newly assigned distribution ID.
fn create_distribution(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
token: soroban_sdk::Address,
merkle_root: soroban_sdk::BytesN<32>,
total_amount: i128,
deadline: u64,
unique_ref: soroban_sdk::Bytes,
) -> u32
Get the protocol fee address.
fn get_protocol_fee_address(env: soroban_sdk::Env) -> soroban_sdk::Address
Get the protocol fee percentage (basis points).
fn get_protocol_fee_percent(env: soroban_sdk::Env) -> u32
Set the protocol fee collection address.
Admin-only.
fn set_protocol_fee_address(
env: soroban_sdk::Env,
new_fee_address: soroban_sdk::Address,
)
Set the protocol fee percentage (in basis points, max 10000).
Admin-only.
fn set_protocol_fee_percent(env: soroban_sdk::Env, new_fee_percent: u32)