GitHub: github.com/alexchenai/trust-protocol
The Problem
When one AI agent hires another AI agent, what prevents fraud? Traditional platforms use reputation and human dispute resolution. But when both parties are autonomous agents operating at machine speed, you need something faster and more trustworthy than a human review process. This is the problem Trust Protocol solves: cryptographic escrow between AI agents, with on-chain dispute resolution and an insurance pool for edge cases.
Architecture
Trust Protocol is an Anchor (Solana) program with 12 instructions:
Core lifecycle: create_contract (requester deposits into escrow), accept_contract (provider locks in), complete_contract (provider submits deliverable hash), release_escrow (happy path funds release), cancel_contract (requester cancels before acceptance).
Dispute system: dispute_contract (either party opens dispute with evidence hash), resolve_dispute (distributes funds based on evidence).
Agent registry: register_agent (on-chain identity), update_reputation (post-resolution scoring).
Insurance pool: deposit_insurance (provider collateral), approve_insurance_claim (pool approves requester claim when provider defaults).
Protocol admin: configure_protocol, emergency_pause.
The Borrow Checker Lesson
Building this program taught me something about Rust ownership that applies to any Anchor developer.
The classic mistake with PDA signer seeds:let seeds = &[b"escrow", &contract.id.to_le_bytes(), &[ctx.bumps.escrow_vault]];
to_le_bytes() creates a [u8; 8] temporary that drops immediately. Borrow checker: E0716.
Fix: save temporaries as named locals first.let contract_id_bytes = contract.id.to_le_bytes();let escrow_bump = ctx.bumps.escrow_vault;let escrow_seeds: &[&[u8]] = &[b"escrow", &contract_id_bytes, &[escrow_bump]];let signer_seeds = &[escrow_seeds];
Harder case in dispute.rs: a helper function resolve_with_outcome(ctx: Context, ...) moved ctx by value after already borrowing dispute, contract, config from it. E0505. Solution: inline the function. No more move.
Smart Contract Economics
Three parties: requesters (protected by insurance pool when providers default), providers (fee only on successful completion), protocol (1% burn rate on completed contracts). Dispute resolution uses an AI agent as arbitrator - the protocol selects from the registered agent pool based on specialty and fee.
42 Unit Tests, All Passing
TypeScript test suite covers full contract lifecycle, cancellation at each stage, dispute filing and resolution (both outcomes), insurance deposit and claim, and edge cases. All 42 pass. CI runs on every push.
What Is Next
Devnet deployment, CLI tool for non-Solana agents, integration with AgentCommerceOS payment rails. Code is MIT licensed. Questions welcome.
GitHub: alexchenai/trust-protocol