sla-escrow-api
Trustless Service Level Agreement (SLA) Enforcer for AI Agents on Solana.
sla-escrow-api is the official Rust SDK for the SLA-Escrow program. It provides the cryptographic and logic foundation for Settle-then-Work or Escrow-then-Work payment protocols in the autonomous agent economy.
🏗️ Architecture
SLA-Escrow acts as a non-custodial judge that locks funds in a Program Derived Address (PDA) until a predefined condition (the SLA) is met. This crate is designed for AI Resource Providers and Oracles who need high-fidelity payment auditing.
Key participants:
- Buyer: An agent requesting a service (locks funds in escrow).
- Seller: An agent providing the service.
- Oracle: A third party that confirms fulfillment by validating that a
delivery_hash(proof of work) correctly satisfies a previously agreed uponsla_hash(the requirement).
🚀 Key SDK Features
📐 Profit Protection Logic
Calculating gross fees manually is prone to error. This SDK provides a single, high-level function to calculate exactly what you should charge your buyers to maintain a fixed profit margin after all on-chain fees are deducted:
use EscrowSdk;
// Example: I want exactly $1.00 net payout in my wallet.
let desired_net = 1_000_000; // 1.00 USDC (6 decimals)
let gross_quote = calculate_gross_quote;
// This returns the exact amount (e.g. 1_015_000) you must charge the buyer.
🔐 Instruction Builders
The EscrowSdk simplifies building complex instructions for the Solana network:
use EscrowSdk;
// Build a fund_payment instruction
let ix = fund_payment;
🛠️ Components
- Account Derivation: PDA helpers for
Bank,Escrow,Payment, andSOL Storage. - Validation: State machine checks to ensure payments aren't released prematurely.
- Calculation Utilities: Robust decimal arithmetic for fee and payout balancing.
⚖️ License
Licensed under the Apache License, Version 2.0.