Upgrades the contract to a new WASM hash.
caller: owner or contract admin.new_wasm_hash: The hash of the new WASM code.ContractError::Unauthorizedfn 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.
caller: owner address.project_id: project identifier.role: 0=super_admin, 1=admin, 2=ngo, 3=vendor, 4=beneficiary.new_member: address to add.ContractError::InvalidRoleContractError::RoleAlreadyExistsContractError::RoleLimitExceededContractError::InvalidInputContractError::Unauthorizedfn 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.
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.
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.
caller: owner or contract admin.extend_to: Number of ledgers to extend.ContractError::UnauthorizedContractError::InvalidInputfn extend_ttl(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
extend_to: u32,
) -> Result<(), ContractError>
Initializes the contract owner.
owner: address to set as the owner.ContractError::UnauthorizedContractError::AlreadyInitializedfn 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.
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.ContractError::InvalidRoleContractError::Unauthorizedfn 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.
caller: owner or contract admin.ContractError::Unauthorizedfn pause_contract(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
) -> Result<(), ContractError>
returns pause expiry timestamp if paused, None otherwise.
fn get_pause_until(env: soroban_sdk::Env) -> Option
Unpauses the contract immediately.
caller: owner or contract admin.ContractError::Unauthorizedfn unpause_contract(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
) -> Result<(), ContractError>
Adds a global contract admin.
caller: owner or contract admin.new_admin: address to grant admin rights.ContractError::RoleAlreadyExistsContractError::RoleLimitExceededContractError::UnauthorizedContractError::InvalidInputfn add_contract_admin(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
new_admin: soroban_sdk::Address,
) -> Result<(), ContractError>
Gets a cash allowance.
project_id: project identifier.allowee: address.currency: currency code.ContractError::AllowanceNotFoundContractError::InvalidInputfn get_cash_allowance(
env: soroban_sdk::Env,
project_id: u64,
allowee: soroban_sdk::Address,
currency: soroban_sdk::String,
) -> Result
Gets an item allowance.
project_id: project identifier.allowee: address.item_id: item identifier.ContractError::AllowanceNotFoundContractError::InvalidInputfn 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.
vendor: vendor address.project_id: optional project id (defaults to "default_project").currency: currency code.amount: amount to redeem.ContractError::AllowanceNotFoundContractError::InsufficientFundsContractError::ContractPausedContractError::InvalidInputContractError::Unauthorizedfn 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.
vendor: vendor address.project_id: optional project id (defaults to "default_project").item_id: item identifier.quantity: quantity to redeem.ContractError::AllowanceNotFoundContractError::InsufficientFundsContractError::ContractPausedContractError::InvalidInputContractError::Unauthorizedfn redeem_item_claims(
env: soroban_sdk::Env,
vendor: soroban_sdk::Address,
project_id: Option,
item_id: soroban_sdk::String,
quantity: u64,
) -> Result<(), ContractError>
Transfers contract ownership to a new address.
caller: Current owner.new_owner: New owner address.ContractError::UnauthorizedContractError::InvalidInputfn 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.
caller: beneficiary address.project_id: project identifier.currency: currency code.amount: positive amount.vendor: optional vendor to credit.ContractError::AllowanceNotFoundContractError::ExpiredAllowanceContractError::InsufficientFundsContractError::InvalidInputContractError::Unauthorizedfn 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.
caller: beneficiary address.vendor: vendor address.project_id: project identifier.item_id: item identifier.quantity: positive quantity.ContractError::AllowanceNotFoundContractError::ExpiredAllowanceContractError::InsufficientFundsContractError::InvalidInputContractError::Unauthorizedfn 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.
caller: owner or contract admin.admin: admin address to remove.ContractError::Unauthorizedfn remove_contract_admin(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
admin: soroban_sdk::Address,
) -> Result<(), ContractError>
Allocates a cash allowance.
caller: ngo address.project_id: project identifier.allowee: beneficiary/vendor.amount: positive amount.currency: currency code.expiry: future timestamp or none.ContractError::ContractPausedContractError::InvalidInputContractError::Unauthorizedfn 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.
caller: ngo address.project_id: project identifier.allowee: beneficiary/vendor.item_id: item identifier.quantity: positive quantity.expiry: future timestamp or none.ContractError::ContractPausedContractError::InvalidInputContractError::Unauthorizedfn 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.
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 all item allowances for a project.
project_id: project identifier.fn get_all_item_allowances(
env: soroban_sdk::Env,
project_id: u64,
) -> soroban_sdk::Map<(soroban_sdk::Address, soroban_sdk::String), ItemAllowance>
Transfers a cash allowance to another address.
caller: beneficiary address.project_id: project identifier.new_allowee: recipient address.currency: currency code.amount: positive amount.ContractError::AllowanceNotFoundContractError::InsufficientFundsContractError::InvalidInputContractError::UnauthorizedContractError::ExpiredAllowancefn 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.
caller: beneficiary address.project_id: project identifier.new_allowee: recipient address.item_id: item identifier.quantity: positive quantity.ContractError::AllowanceNotFoundContractError::InsufficientFundsContractError::InvalidInputContractError::UnauthorizedContractError::ExpiredAllowancefn 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.
beneficiary: address.project_ids: list of project identifiers.ContractError::InvalidInput if overflow occurs or validation failsfn 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.
beneficiary: address.project_ids: list of project identifiers.ContractError::InvalidInput if overflow occurs or validation failsfn get_total_item_allowance(
env: soroban_sdk::Env,
beneficiary: soroban_sdk::Address,
project_ids: soroban_sdk::Vec,
) -> Result
Claims multiple item allowances in a single transaction.
caller: beneficiary address.vendor: vendor address that will receive the items.project_id: project identifier.claims: vector of (item_id, quantity) tuples to claim.ContractError::AllowanceNotFoundContractError::InsufficientFundsContractError::InvalidInputContractError::UnauthorizedContractError::ExpiredAllowanceThis 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>
Allocates multiple cash allowances.
caller: ngo address.project_id: project identifier.allowances: tuples of (allowee, currency, amount, expiry).ContractError::ContractPausedContractError::InvalidInputContractError::Unauthorizedfn 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.
caller: ngo address.project_id: project identifier.allowances: tuples of (allowee, item_id, quantity, expiry).ContractError::ContractPausedContractError::InvalidInputContractError::Unauthorizedfn 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>