Contract 6879e50db141f6a2b281375e871869dcff02c935f32da13330aa2ed7738b1f19

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.11#34f7f53ae31e0fd02aab436a9872e79fa671ca02
rsver 1.93.0

Instances

  • CACWOBHPPVOLHUHT6THO4P5T6UFXQYKTGK3JSASNNGHRFGOVD5FQPJ5I

Interface

Emergency pause — halts all operations. Requires admin authentication.

fn pause(env: soroban_sdk::Env) -> Result<(), AuthError>

Revoke authorization for a merchant. Instant and permanent.

Arguments

  • user — The subscriber revoking permission
  • merchant — The merchant losing permission
  • token — Token contract address

Security

  • Requires user authentication
  • Revocation is permanent — a new authorization must be created
fn revoke(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    merchant: soroban_sdk::Address,
    token: soroban_sdk::Address,
) -> Result<(), AuthError>

Resume operations after emergency pause. Requires admin authentication.

fn unpause(env: soroban_sdk::Env) -> Result<(), AuthError>

Grant authorization for a merchant to pull funds.

Arguments

  • user — The subscriber granting permission
  • merchant — The merchant receiving permission
  • token — Token contract address (e.g., USDC)
  • max_per_payment — Maximum per individual payment
  • total_allowed — Total lifetime allowance
  • expiry — Expiration timestamp (0 = no expiry)

Security

  • Requires user authentication (require_auth)
  • Validates all input parameters
  • Prevents duplicate authorizations
fn authorize(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    merchant: soroban_sdk::Address,
    token: soroban_sdk::Address,
    max_per_payment: i128,
    total_allowed: i128,
    expiry: u64,
) -> Result

Initialize the contract with admin and payment engine addresses. Can only be called once.

Arguments

  • admin — Admin address (multi-sig recommended)
  • payment_engine — Address of the Payment Engine contract

Security

  • Sets the authorized Payment Engine address
  • Only admin can perform emergency operations
fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    payment_engine: soroban_sdk::Address,
) -> Result<(), AuthError>

Record a successful payment against an authorization. RESTRICTED: Only callable by the Payment Engine contract.

Arguments

  • user — Subscriber address
  • merchant — Merchant address
  • token — Token contract address
  • amount — Payment amount executed

Security

  • Caller must be the registered Payment Engine address
  • Uses checked_add for overflow protection
  • Updates total_spent and payment_count atomically
fn record_payment(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    merchant: soroban_sdk::Address,
    token: soroban_sdk::Address,
    amount: i128,
) -> Result<(), AuthError>

Get authorization details for a user-merchant-token tuple.

fn get_authorization(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    merchant: soroban_sdk::Address,
    token: soroban_sdk::Address,
) -> Result

Check if an authorization is valid for a given payment amount. Called by the Payment Engine before executing a payment.

Arguments

  • user — Subscriber address
  • merchant — Merchant address
  • token — Token contract address
  • amount — Payment amount to validate

Returns

true if the payment is authorized, error otherwise

Security

  • Pure read operation — no auth required
  • Validates all authorization constraints
fn check_authorization(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    merchant: soroban_sdk::Address,
    token: soroban_sdk::Address,
    amount: i128,
) -> Result

Update the Payment Engine address. Requires admin authentication.

fn update_payment_engine(
    env: soroban_sdk::Env,
    new_payment_engine: soroban_sdk::Address,
) -> Result<(), AuthError>

Get all authorizations for a user (returns list of (merchant, token) tuples).

fn get_user_authorizations(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
) -> soroban_sdk::Vec<(soroban_sdk::Address, soroban_sdk::Address)>

Get all authorizations for a merchant (returns list of (user, token) tuples).

fn get_merchant_authorizations(
    env: soroban_sdk::Env,
    merchant: soroban_sdk::Address,
) -> soroban_sdk::Vec<(soroban_sdk::Address, soroban_sdk::Address)>

Imports

WebAssembly Text (WAT) ▶