sla-escrow-api 0.3.0

SLA-Escrow: Service Level Agreement Enforcer for AI Agents
Documentation

sla-escrow-api

Rust types, instruction codecs, PDA helpers, and EscrowSdk builders for the SLA-Escrow Solana program.

Crates.io · Apache-2.0

Role

  • declare_id! — Must match the deployed program (rebuild clients after ID changes).
  • instruction — Binary layouts for every opcode (FundPayment, ConfirmOracle, UpdateConfig, …).
  • stateBank, Config, Escrow, Payment (Payment includes oracle_authority_set_at, resolution_hash, timing snapshots, etc.).
  • sdk::EscrowSdk — Instruction builders aligned with the on-chain account order.
  • event — Log-friendly event structs (e.g. PaymentOracleConfirmedEvent includes resolution_hash).
  • consts — Fee caps, timing validation bounds, seeds, optional precomputed PDAs for integrators.

Participants

  • Buyer — Funds the payment.
  • Seller — Fulfills and submits delivery_hash.
  • Oraclepayment.oracle_authority; signs ConfirmOracle with delivery_hash, optional resolution_hash, and resolution/reason.
  • Bank authority — Admin path: init, open escrow, withdraw fees, pause, update config, authority rotation, etc.

SDK examples

Gross quote (fees + oracle tip)

use sla_escrow_api::sdk::EscrowSdk;

let desired_net = 1_000_000u64; // e.g. 1 USDC (6 decimals)
let gross = EscrowSdk::calculate_gross_quote(
    desired_net,
    100,    // protocol fee_bps
    10_000, // min protocol fee raw
    50,     // oracle_fee_bps
);

Fund payment (SPL)

use sla_escrow_api::sdk::EscrowSdk;

let ix = EscrowSdk::fund_payment(
    buyer,
    Some(buyer_ata),
    seller,
    mint,
    amount_raw,
    86_400,
    "payment-uid",
    sla_hash,
    oracle_authority,
);

Use buyer_tokens: None and mint: Pubkey::default() for native SOL (see fund_payment rustdoc).

Confirm oracle (with attestation hash)

use sla_escrow_api::sdk::EscrowSdk;

let ix = EscrowSdk::confirm_oracle(
    oracle_authority,
    mint,
    "payment-uid",
    delivery_hash,
    resolution_hash, // [0u8; 32] if unused
    1,               // approved
    0,               // resolution_reason
);

Update global config (admin)

use sla_escrow_api::sdk::EscrowSdk;

let ix = EscrowSdk::update_config(
    admin,
    closure_delay_seconds,
    refund_cooldown_seconds,
    delivery_cutoff_seconds,
);

Newly funded payments snapshot these values; existing payments keep their stored copies.

License

Apache License, Version 2.0.