Initialize the token with initial supply to the creator (legacy method)
fn init(
env: soroban_sdk::Env,
creator: soroban_sdk::Address,
initial_supply: soroban_sdk::U256,
)
Mint new tokens (admin only)
fn mint(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: soroban_sdk::U256,
)
Get the current balance of an account (after applying demurrage)
fn balance(env: soroban_sdk::Env, account: soroban_sdk::Address) -> soroban_sdk::U256
Transfer tokens from one account to another
fn transfer(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
amount: soroban_sdk::U256,
)
Get the admin address
fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address
Voluntarily step down from a role (sociocratic role release) For governors: transfers to successor if designated, otherwise disables trust For verifiers/oracles: returns full stake (no slashing for voluntary release)
fn step_down(env: soroban_sdk::Env, address: soroban_sdk::Address, role: RoleType)
Get oracle data
fn get_oracle(env: soroban_sdk::Env, oracle: soroban_sdk::Address) -> OracleData
Join an existing trust
fn join_trust(
env: soroban_sdk::Env,
member: soroban_sdk::Address,
trust_id: soroban_sdk::Address,
)
Get full account data
fn get_account(env: soroban_sdk::Env, account: soroban_sdk::Address) -> AccountData
Leave current trust (anti-gaming: Part 2.2 - allows escaping bad governors)
fn leave_trust(env: soroban_sdk::Env, member: soroban_sdk::Address)
Get proposal details
fn get_proposal(env: soroban_sdk::Env, proposal_id: u64) -> Proposal
Get verifier data
fn get_verifier(env: soroban_sdk::Env, verifier: soroban_sdk::Address) -> VerifierData
Migrate data from an old contract after an upgrade.
During Soroban contract upgrades, instance storage is cleared while persistent storage survives. This function restores instance storage from the old contract and validates that persistent data is intact.
admin - The admin address (must match the source contract's admin)source_contract - Address of the old contract to migrate fromexpected_protocol_version - Expected version of the source contractMigrationResult - Details about the migration including validation countsfn migrate_data(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
source_contract: soroban_sdk::Address,
expected_protocol_version: u32,
) -> MigrationResult
Get the total supply
fn total_supply(env: soroban_sdk::Env) -> soroban_sdk::U256
fn __constructor(
env: soroban_sdk::Env,
creator: soroban_sdk::Address,
initial_supply: soroban_sdk::U256,
)
Set probation period for an address
fn set_probation(
env: soroban_sdk::Env,
address: soroban_sdk::Address,
role: RoleType,
duration_days: u64,
)
Get list of all registered trust IDs
fn get_all_trusts(env: soroban_sdk::Env) -> soroban_sdk::Vec
Get reputation score for a role (public)
fn get_reputation(
env: soroban_sdk::Env,
address: soroban_sdk::Address,
role: RoleType,
) -> u32
Get information about a specific trust
fn get_trust_info(env: soroban_sdk::Env, trust_id: soroban_sdk::Address) -> TrustData
Get work claim details
fn get_work_claim(env: soroban_sdk::Env, claim_id: u64) -> WorkClaim
Register a new community trust Parameters:
fn register_trust(
env: soroban_sdk::Env,
governor: soroban_sdk::Address,
name: soroban_sdk::String,
annual_rate_bps: u32,
demurrage_period_days: u64,
)
Create a governance proposal Proposer must be a trust governor for trust-specific proposals or admin for protocol-level proposals
fn create_proposal(
env: soroban_sdk::Env,
proposer: soroban_sdk::Address,
proposal_type: ProposalType,
title: soroban_sdk::String,
description: soroban_sdk::String,
trust_id: Option,
new_rate_bps: Option,
target_address: Option,
) -> u64
Check if address is in probation for a role (public)
fn is_on_probation(
env: soroban_sdk::Env,
address: soroban_sdk::Address,
role: RoleType,
) -> bool
Register as a grace period oracle Oracles can activate grace periods for accounts in hardship
fn register_oracle(env: soroban_sdk::Env, oracle: soroban_sdk::Address)
Swap tokens from source trust to destination trust Uses rate-adjusted calculation to account for different demurrage rates
fn cross_trust_swap(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
dest_trust: soroban_sdk::Address,
amount: soroban_sdk::U256,
)
Get grace period details for an account
fn get_grace_period(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
) -> Option
Process a proposal and update its status Transitions from Review to Voting, or Voting to Approved/Rejected
fn process_proposal(env: soroban_sdk::Env, proposal_id: u64)
Vote on a governance proposal Only trust members can vote on trust-specific proposals Admin can vote on protocol proposals
fn vote_on_proposal(
env: soroban_sdk::Env,
voter: soroban_sdk::Address,
proposal_id: u64,
support: bool,
)
Get the trust ID for an account
fn get_account_trust(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
) -> Option
Get all proposals
fn get_all_proposals(env: soroban_sdk::Env) -> soroban_sdk::Vec
Get the next claim ID
fn get_next_claim_id(env: soroban_sdk::Env) -> u64
Register as a verifier for a trust Must stake 100 KCHNG to become a verifier
fn register_verifier(
env: soroban_sdk::Env,
verifier: soroban_sdk::Address,
trust_id: soroban_sdk::Address,
)
Reject a work claim (verifier only)
fn reject_work_claim(
env: soroban_sdk::Env,
verifier: soroban_sdk::Address,
claim_id: u64,
)
Submit a work claim for verification Returns the claim ID
fn submit_work_claim(
env: soroban_sdk::Env,
worker: soroban_sdk::Address,
work_type: WorkType,
minutes_worked: u64,
evidence_hash: soroban_sdk::Bytes,
gps_lat: Option,
gps_lon: Option,
) -> u64
Unregister as an oracle and return stake If reputation is below 100 (removal threshold), 50% of stake is slashed If reputation is below 200 (restricted), 25% of stake is slashed
fn unregister_oracle(env: soroban_sdk::Env, oracle: soroban_sdk::Address)
Update a role-based score for a verifier
Role-based reputation allows for context-specific scoring. Hierarchy: Domain → Aspect → Role
For example:
This allows someone to have high reputation as a dinner guest but low reputation as a dinner host.
verifier - The verifier whose role score is being updatedrole_key - Compound key "aspect:role" (e.g., "dining:guest", "ride_sharing:driver")delta - The change to apply (positive or negative, e.g., +30, -50)scorer - The account submitting this score update (must authenticate)fn update_role_score(
env: soroban_sdk::Env,
verifier: soroban_sdk::Address,
role_key: soroban_sdk::Bytes,
delta: i32,
scorer: soroban_sdk::Address,
)
Approve a work claim (verifier only)
fn approve_work_claim(
env: soroban_sdk::Env,
verifier: soroban_sdk::Address,
claim_id: u64,
)
Implement an approved proposal Can only be called after implementation date has passed
fn implement_proposal(env: soroban_sdk::Env, proposal_id: u64)
Check if an account is currently in a grace period
fn is_in_grace_period(env: soroban_sdk::Env, account: soroban_sdk::Address) -> bool
Report grace period abuse Called by an oracle when a member violates grace period conditions (e.g., claims illness but is seen working elsewhere) Penalizes the abuser and ends their grace period early
fn report_grace_abuse(
env: soroban_sdk::Env,
reporter: soroban_sdk::Address,
account: soroban_sdk::Address,
reason: soroban_sdk::String,
)
Designate a successor for the governor role (sociocratic succession) Only the current governor can call this The successor must be a member of the trust
fn designate_successor(
env: soroban_sdk::Env,
governor: soroban_sdk::Address,
successor: soroban_sdk::Address,
)
Extend an existing grace period (requires community voting)
fn extend_grace_period(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
additional_days: u64,
)
Get all reputation scores for an address
fn get_all_reputations(
env: soroban_sdk::Env,
address: soroban_sdk::Address,
) -> soroban_sdk::Map
Get full reputation data for a role (public)
fn get_reputation_data(
env: soroban_sdk::Env,
address: soroban_sdk::Address,
role: RoleType,
) -> ReputationData
Unregister as a verifier and return stake If reputation is below 200, 10% of stake is slashed
fn unregister_verifier(env: soroban_sdk::Env, verifier: soroban_sdk::Address)
Get the migration status
fn get_migration_status(env: soroban_sdk::Env) -> Option
Get the next proposal ID
fn get_next_proposal_id(env: soroban_sdk::Env) -> u64
Get the protocol version
fn get_protocol_version(env: soroban_sdk::Env) -> u32
Get the total supply (raw U256)
fn get_total_supply_raw(env: soroban_sdk::Env) -> soroban_sdk::U256
Activate a grace period for an account Parameters:
fn activate_grace_period(
env: soroban_sdk::Env,
oracle: soroban_sdk::Address,
account: soroban_sdk::Address,
grace_type: GraceType,
duration_days: u64,
)
Check if verifier can verify in multiple trusts (high reputation)
fn can_multi_trust_verify(env: soroban_sdk::Env, address: soroban_sdk::Address) -> bool
Calculate exchange rate between two trusts Returns the multiplier for converting from source to destination trust Formula: (1 - r_source) / (1 - r_dest) Example: Trust A (12%) → Trust B (8%) = (1 - 0.12) / (1 - 0.08) = 0.957
fn calculate_exchange_rate(
env: soroban_sdk::Env,
source_trust: soroban_sdk::Address,
dest_trust: soroban_sdk::Address,
) -> u64
Simulate a cross-trust swap without executing it Returns the amount that would be received in the destination trust
fn simulate_cross_trust_swap(
env: soroban_sdk::Env,
source_trust: soroban_sdk::Address,
dest_trust: soroban_sdk::Address,
amount: soroban_sdk::U256,
) -> soroban_sdk::U256
Get the effective demurrage rate for an account
fn get_account_demurrage_rate(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
) -> (u32, u64)
Get pending claims for a verifier
fn get_verifier_pending_claims(
env: soroban_sdk::Env,
verifier: soroban_sdk::Address,
) -> soroban_sdk::Vec