fn admin(env: soroban_sdk::Env) -> soroban_sdk::Address
Gateway (admin) charges a user's credit for API usage. Charged funds become treasury revenue (they stay in the contract). Returns the user's new balance.
fn debit(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
amount: i128,
) -> Result
fn token(env: soroban_sdk::Env) -> soroban_sdk::Address
fn paused(env: soroban_sdk::Env) -> bool
fn balance(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128
Admin sweeps accumulated treasury revenue to a wallet. Returns remaining treasury.
fn collect(
env: soroban_sdk::Env,
to: soroban_sdk::Address,
amount: i128,
) -> Result
Agent/user deposits USDC and receives API credit 1:1. Returns the new credit balance.
fn deposit(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
amount: i128,
) -> Result
fn treasury(env: soroban_sdk::Env) -> i128
User reclaims unused credit back to their wallet as USDC. Returns new balance.
fn withdraw(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
amount: i128,
) -> Result
Rotate the admin (gateway operator) key. Emits an event for auditability.
fn set_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
Incident switch: pausing blocks new deposits and gateway debits, but NEVER withdrawals — users can always exit with their balance.
fn set_paused(env: soroban_sdk::Env, paused: bool)
Initialize once at deploy time (Protocol 22+ constructor — cannot be re-run).
fn __constructor(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
token: soroban_sdk::Address,
)