Contract 14a957abbc36c85f7ee73ba8a2a04ed02d2c5cb5e468460ea3bded51ac4716a7

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.6#0c47dcfa187069d241f11fb082730f667b55e802
rsver 1.91.1

Instances

  • CAGKVGXGUPF3VGRZT5XH44FCSIDSAENXI4MWJO3EMH6UM6HY4W4XB6AN

Interface

Upgrades the contract to a new WASM hash.

Arguments

  • caller: owner or contract admin.
  • new_wasm_hash: The hash of the new WASM code.

Errors

  • ContractError::Unauthorized
fn upgrade(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), ContractError>

Adds a role member to a project.

Arguments

  • caller: owner address.
  • project_id: project identifier.
  • role: 0=super_admin, 1=admin, 2=ngo, 3=vendor, 4=beneficiary.
  • new_member: address to add.

Errors

  • ContractError::InvalidRole
  • ContractError::RoleAlreadyExists
  • ContractError::RoleLimitExceeded
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn add_role(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    role: u32,
    new_member: soroban_sdk::Address,
) -> Result<(), ContractError>

Checks if an address has a specific role in a project.

Arguments

  • project_id: The project identifier.
  • address: The address to check.
  • role: The role integer (0=super_admin, 1=admin, 2=ngo, 3=vendor, 4=beneficiary).
fn has_role(
    env: soroban_sdk::Env,
    project_id: u64,
    address: soroban_sdk::Address,
    role: u32,
) -> bool
fn get_owner(env: soroban_sdk::Env) -> soroban_sdk::Address

Gets roles for a project.

Arguments

  • project_id: project identifier.
fn get_roles(env: soroban_sdk::Env, project_id: u64) -> Roles
fn is_paused(env: soroban_sdk::Env) -> bool

Extends the TTL (Time To Live) for contract storage.

Arguments

  • caller: owner or contract admin.
  • extend_to: Number of ledgers to extend.

Errors

  • ContractError::Unauthorized
  • ContractError::InvalidInput
fn extend_ttl(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    extend_to: u32,
) -> Result<(), ContractError>

Initializes the contract owner.

Arguments

  • owner: address to set as the owner.

Errors

  • ContractError::Unauthorized
  • ContractError::AlreadyInitialized
fn initialize(
    env: soroban_sdk::Env,
    owner: soroban_sdk::Address,
) -> Result<(), ContractError>
fn get_version(env: soroban_sdk::Env) -> soroban_sdk::String

Removes a role member from a project.

Arguments

  • caller: owner address.
  • project_id: project identifier.
  • role: role integer (0=super_admin, 1=admin, 2=ngo, 3=vendor, 4=beneficiary).
  • member_to_remove: address to remove.

Errors

  • ContractError::InvalidRole
  • ContractError::Unauthorized
fn remove_role(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    role: u32,
    member_to_remove: soroban_sdk::Address,
) -> Result<(), ContractError>

Pauses the contract for a short window.

Arguments

  • caller: owner or contract admin.

Errors

  • ContractError::Unauthorized
fn pause_contract(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), ContractError>
fn add_roles_batch(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    role: u32,
    new_members: soroban_sdk::Vec,
) -> Result<(), ContractError>

returns pause expiry timestamp if paused, None otherwise.

fn get_pause_until(env: soroban_sdk::Env) -> Option

Unpauses the contract immediately.

Arguments

  • caller: owner or contract admin.

Errors

  • ContractError::Unauthorized
fn unpause_contract(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), ContractError>

Adds a global contract admin.

Arguments

  • caller: owner or contract admin.
  • new_admin: address to grant admin rights.

Errors

  • ContractError::RoleAlreadyExists
  • ContractError::RoleLimitExceeded
  • ContractError::Unauthorized
  • ContractError::InvalidInput
fn add_contract_admin(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_admin: soroban_sdk::Address,
) -> Result<(), ContractError>

Gets a cash allowance.

Arguments

  • project_id: project identifier.
  • allowee: address.
  • currency: currency code.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::InvalidInput
fn get_cash_allowance(
    env: soroban_sdk::Env,
    project_id: u64,
    allowee: soroban_sdk::Address,
    currency: soroban_sdk::String,
) -> Result

Gets an item allowance.

Arguments

  • project_id: project identifier.
  • allowee: address.
  • item_id: item identifier.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::InvalidInput
fn get_item_allowance(
    env: soroban_sdk::Env,
    project_id: u64,
    allowee: soroban_sdk::Address,
    item_id: soroban_sdk::String,
) -> Result

Redeems cash claims credited to a vendor.

Arguments

  • vendor: vendor address.
  • project_id: optional project id (defaults to "default_project").
  • currency: currency code.
  • amount: amount to redeem.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::InsufficientFunds
  • ContractError::ContractPaused
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn redeem_cash_claims(
    env: soroban_sdk::Env,
    vendor: soroban_sdk::Address,
    project_id: Option,
    currency: soroban_sdk::String,
    amount: u64,
) -> Result<(), ContractError>

Redeems item claims credited to a vendor.

Arguments

  • vendor: vendor address.
  • project_id: optional project id (defaults to "default_project").
  • item_id: item identifier.
  • quantity: quantity to redeem.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::InsufficientFunds
  • ContractError::ContractPaused
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn redeem_item_claims(
    env: soroban_sdk::Env,
    vendor: soroban_sdk::Address,
    project_id: Option,
    item_id: soroban_sdk::String,
    quantity: u64,
) -> Result<(), ContractError>
fn remove_roles_batch(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    role: u32,
    members_to_remove: soroban_sdk::Vec,
) -> Result<(), ContractError>

Transfers contract ownership to a new address.

Arguments

  • caller: Current owner.
  • new_owner: New owner address.

Errors

  • ContractError::Unauthorized
  • ContractError::InvalidInput
fn transfer_ownership(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_owner: soroban_sdk::Address,
) -> Result<(), ContractError>
fn get_contract_admins(env: soroban_sdk::Env) -> soroban_sdk::Vec

Claims a cash allowance, optionally crediting a vendor.

Arguments

  • caller: beneficiary address.
  • project_id: project identifier.
  • currency: currency code.
  • amount: positive amount.
  • vendor: optional vendor to credit.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::ExpiredAllowance
  • ContractError::InsufficientFunds
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn claim_cash_allowance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    currency: soroban_sdk::String,
    amount: u64,
    vendor: Option,
) -> Result<(), ContractError>

Claims an item allowance and credits a vendor.

Arguments

  • caller: beneficiary address.
  • vendor: vendor address.
  • project_id: project identifier.
  • item_id: item identifier.
  • quantity: positive quantity.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::ExpiredAllowance
  • ContractError::InsufficientFunds
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn claim_item_allowance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    vendor: soroban_sdk::Address,
    project_id: u64,
    item_id: soroban_sdk::String,
    quantity: u64,
) -> Result<(), ContractError>

Removes a global contract admin.

Arguments

  • caller: owner or contract admin.
  • admin: admin address to remove.

Errors

  • ContractError::Unauthorized
fn remove_contract_admin(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    admin: soroban_sdk::Address,
) -> Result<(), ContractError>

Allocates a cash allowance.

Arguments

  • caller: ngo address.
  • project_id: project identifier.
  • allowee: beneficiary/vendor.
  • amount: positive amount.
  • currency: currency code.
  • expiry: future timestamp or none.

Errors

  • ContractError::ContractPaused
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn allocate_cash_allowance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    allowee: soroban_sdk::Address,
    amount: u64,
    currency: soroban_sdk::String,
    expiry: Option,
) -> Result<(), ContractError>

Allocates an item allowance.

Arguments

  • caller: ngo address.
  • project_id: project identifier.
  • allowee: beneficiary/vendor.
  • item_id: item identifier.
  • quantity: positive quantity.
  • expiry: future timestamp or none.

Errors

  • ContractError::ContractPaused
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn allocate_item_allowance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    allowee: soroban_sdk::Address,
    item_id: soroban_sdk::String,
    quantity: u64,
    expiry: Option,
) -> Result<(), ContractError>

Lists all cash allowances for a project.

Arguments

  • project_id: project identifier.
fn get_all_cash_allowances(
    env: soroban_sdk::Env,
    project_id: u64,
) -> soroban_sdk::Map<(soroban_sdk::Address, soroban_sdk::String), CashAllowance>

Lists item allowances for specific addresses and items in a project. Returns a vector of tuples: (address, item_id, allowance).

Arguments

  • project_id: project identifier.
  • addresses: list of addresses to query.
  • item_ids: list of item identifiers to query.
fn get_all_item_allowances(
    env: soroban_sdk::Env,
    project_id: u64,
    addresses: soroban_sdk::Vec,
    item_ids: soroban_sdk::Vec,
) -> soroban_sdk::Vec<(soroban_sdk::Address, soroban_sdk::String, ItemAllowance)>

Transfers a cash allowance to another address.

Arguments

  • caller: beneficiary address.
  • project_id: project identifier.
  • new_allowee: recipient address.
  • currency: currency code.
  • amount: positive amount.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::InsufficientFunds
  • ContractError::InvalidInput
  • ContractError::Unauthorized
  • ContractError::ExpiredAllowance
fn transfer_cash_allowance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    new_allowee: soroban_sdk::Address,
    currency: soroban_sdk::String,
    amount: u64,
) -> Result<(), ContractError>

Transfers an item allowance to another address.

Arguments

  • caller: beneficiary address.
  • project_id: project identifier.
  • new_allowee: recipient address.
  • item_id: item identifier.
  • quantity: positive quantity.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::InsufficientFunds
  • ContractError::InvalidInput
  • ContractError::Unauthorized
  • ContractError::ExpiredAllowance
fn transfer_item_allowance(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    new_allowee: soroban_sdk::Address,
    item_id: soroban_sdk::String,
    quantity: u64,
) -> Result<(), ContractError>

Sums total cash allowance across projects for a beneficiary.

Arguments

  • beneficiary: address.
  • project_ids: list of project identifiers.

Errors

  • ContractError::InvalidInput if overflow occurs or validation fails
fn get_total_cash_allowance(
    env: soroban_sdk::Env,
    beneficiary: soroban_sdk::Address,
    project_ids: soroban_sdk::Vec,
) -> Result

Sums total item allowance across projects for a beneficiary.

Arguments

  • beneficiary: address.
  • project_ids: list of project identifiers.
  • item_ids: list of item identifiers to sum across.

Errors

  • ContractError::InvalidInput if overflow occurs or validation fails
fn get_total_item_allowance(
    env: soroban_sdk::Env,
    beneficiary: soroban_sdk::Address,
    project_ids: soroban_sdk::Vec,
    item_ids: soroban_sdk::Vec,
) -> Result

Claims multiple item allowances in a single transaction.

Arguments

  • caller: beneficiary address.
  • vendor: vendor address that will receive the items.
  • project_id: project identifier.
  • claims: vector of (item_id, quantity) tuples to claim.

Errors

  • ContractError::AllowanceNotFound
  • ContractError::InsufficientFunds
  • ContractError::InvalidInput
  • ContractError::Unauthorized
  • ContractError::ExpiredAllowance

Behavior

This function validates ALL claims before making ANY changes (atomic). If any validation fails, the entire batch is rejected and no state changes occur.

fn claim_item_allowances_batch(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    vendor: soroban_sdk::Address,
    project_id: u64,
    claims: soroban_sdk::Vec<(soroban_sdk::String, u64)>,
) -> Result<(), ContractError>

Revokes multiple cash allowances (compensation function).

Removes cash allowances entirely. Used for compensating failed transactions.

Arguments

  • caller: ngo address.
  • project_id: project identifier.
  • revocations: tuples of (allowee, currency) to revoke.

Errors

  • ContractError::ContractPaused
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn revoke_cash_allowances_batch(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    revocations: soroban_sdk::Vec<(soroban_sdk::Address, soroban_sdk::String)>,
) -> Result<(), ContractError>

Revokes multiple item allowances (compensation function).

Sets allowances to zero or removes them entirely. Used for compensating failed transactions.

Arguments

  • caller: ngo address.
  • project_id: project identifier.
  • revocations: tuples of (allowee, item_id) to revoke.

Errors

  • ContractError::ContractPaused
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn revoke_item_allowances_batch(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    revocations: soroban_sdk::Vec<(soroban_sdk::Address, soroban_sdk::String)>,
) -> Result<(), ContractError>

Allocates multiple cash allowances.

Arguments

  • caller: ngo address.
  • project_id: project identifier.
  • allowances: tuples of (allowee, currency, amount, expiry).

Errors

  • ContractError::ContractPaused
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn allocate_cash_allowances_batch(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    allowances: soroban_sdk::Vec<
        (soroban_sdk::Address, soroban_sdk::String, u64, Option),
    >,
) -> Result<(), ContractError>

Allocates multiple item allowances.

Arguments

  • caller: ngo address.
  • project_id: project identifier.
  • allowances: tuples of (allowee, item_id, quantity, expiry).

Errors

  • ContractError::ContractPaused
  • ContractError::InvalidInput
  • ContractError::Unauthorized
fn allocate_item_allowances_batch(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    project_id: u64,
    allowances: soroban_sdk::Vec<
        (soroban_sdk::Address, soroban_sdk::String, u64, Option),
    >,
) -> Result<(), ContractError>

Imports

WebAssembly Text (WAT) ▶