Contract 1c8773aff502301697faca94cb81f233d3669a1cf85885810451a4c44836cf5b

← Back to Index 📥 Download WASM

Meta

rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.96.0

Instances

  • CAGOKMQMKALEIQFVVTQVLI7GLDC2PZDZGC2UZTZR4E3K74DDGWS3VZ7Q

Interface

Mint credits into user's wallet. Called by the backend's relayer only, on a confirmed UPI top-up (1 INR top-up -> 1 credit). Raises total_supply to keep total_supply == sum(balances).

fn mint(env: soroban_sdk::Env, user: soroban_sdk::Address, amount: i128)
fn pause(env: soroban_sdk::Env)

Burn credits from host's earned balance. Called by the backend's relayer only, on a confirmed off-chain payout (weekly host payout). Lowers total_supply so credits cannot be paid out twice.

fn redeem(env: soroban_sdk::Env, host: soroban_sdk::Address, amount: i128)
fn unpause(env: soroban_sdk::Env)
fn is_paused(env: soroban_sdk::Env) -> bool
fn balance_of(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128

One-time bootstrap. Sets the three privileged roles and the treasury (platform-fee sink). Idempotent-guarded: re-init reverts.

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    relayer: soroban_sdk::Address,
    upgrader: soroban_sdk::Address,
    treasury: soroban_sdk::Address,
)
fn get_session(
    env: soroban_sdk::Env,
    session_id: soroban_sdk::Bytes,
) -> Option
fn set_relayer(env: soroban_sdk::Env, new_relayer: soroban_sdk::Address)

Register session metadata. Optional pre-step; lock_deposit will also create the record if absent. Safe to call multiple times before locking (idempotent on identical terms).

fn init_session(
    env: soroban_sdk::Env,
    session_id: soroban_sdk::Bytes,
    rider: soroban_sdk::Address,
    host: soroban_sdk::Address,
    outlet: soroban_sdk::Bytes,
    deposit: i128,
    price_per_kwh_raw: i128,
    service_fee_bps: i128,
)

Lock deposit credits from the rider's wallet balance into this session and transition Created -> Locked. Idempotent: re-locking an already locked/settled session returns the stored record without moving funds again. Reverts with InsufficientBalance if the rider cannot cover deposit.

fn lock_deposit(
    env: soroban_sdk::Env,
    session_id: soroban_sdk::Bytes,
    rider: soroban_sdk::Address,
    host: soroban_sdk::Address,
    outlet: soroban_sdk::Bytes,
    deposit: i128,
    price_per_kwh_raw: i128,
    service_fee_bps: i128,
)
fn set_treasury(env: soroban_sdk::Env, new_treasury: soroban_sdk::Address)
fn set_upgrader(env: soroban_sdk::Env, new_upgrader: soroban_sdk::Address)
fn total_supply(env: soroban_sdk::Env) -> i128
fn cancel_upgrade(env: soroban_sdk::Env)

Full refund to rider's wallet balance. Only valid from Locked. Marks Refunded before the balance move (checks-effects-interactions).

fn refund_deposit(
    env: soroban_sdk::Env,
    session_id: soroban_sdk::Bytes,
    reason: soroban_sdk::Symbol,
)

Settle a locked session: recompute the split on-chain from the relayer-submitted energy reading, then distribute. The relayer may NOT specify the split — only the energy; the contract owns the math.

fn settle_session(
    env: soroban_sdk::Env,
    session_id: soroban_sdk::Bytes,
    energy_wh: i128,
    telemetry_hash: soroban_sdk::Bytes,
    reason: soroban_sdk::Symbol,
)
fn execute_upgrade(env: soroban_sdk::Env)

Propose a new WASM hash. Execution is blocked until the timelock (14 days) elapses. ADMIN can veto at any time by calling pause().

fn propose_upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)

Imports

WebAssembly Text (WAT) ▶