Inspiration
By 2026, the global digital economy is undergoing a structural paradigm shift. Commerce is no longer exclusively human-initiated via browser checkouts or mobile apps. Autonomous AI agents acting as fiduciaries for enterprises and individuals; are actively negotiating, contracting, and purchasing GPU compute cycles, proprietary datasets, and automated services directly from other machines (Agent-to-Agent or A2A commerce).
However, existing payment rails fail machine-to-machine commerce.
The Human-in-the-Loop Bottleneck: Legacy checkout flows (3D-Secure, CAPTCHAs, SMS OTPs, redirect screens) break autonomous execution loops. Credential Sprawl & Wallet Draining: Granting an LLM agent unconstrained access to a raw credit card or crypto wallet exposes the owner to prompt injection attacks (OWASP MCP Top 10), where malicious prompts trick the agent into draining funds. The Inter-Agent Trust Deficit: How can Buyer Agent Alpha trust anonymous Seller Agent Beta to deliver assets after payment? How can Seller Beta invest costly compute without guaranteed escrow?
While tech giants wage a standards battle (Google AP2 vs. Stripe ACP vs. Coinbase x402), pyFides bridges Google’s open Agent Payments Protocol (AP2) with PayPal’s global trust graph and PYUSD stablecoin rails, establishing PayPal as the indispensable settlement and escrow custodian for the autonomous web.
What it does
pyFides is an AP2-compliant autonomous escrow and fiduciary protocol for machine-to-machine commerce:
AP2 Cryptographic Mandates: Human principals issue Ed25519-signed Intent Mandates with deterministic mathematical spend caps ($30.00 max), preventing prompt-injection wallet draining.
Dynamic API Discovery via APIMatic: Buyer Agent Alpha autonomously discovers and negotiates with Seller Agent Beta's OpenAPI 3.1 endpoints via APIMatic Context Plugins without hand-coded client wrappers.
Deterministic Two-Phase PayPal Escrow: Funds are placed into an immutable hold on PayPal Sandbox rails using Orders v2 (intent: "AUTHORIZE") with our official Partner Attribution ID.
Cryptographic Oracle Verification: Funds are captured only after an automated oracle mathematically validates the seller’s deliverable SHA-256 digest against the signed Cart Mandate.
Dual-Rail Micro-Settlement (PYUSD): Supports both PayPal Balance and instant, gas-less PayPal USD (PYUSD) stablecoin settlement with on-chain telemetry.
Apple-Grade Dual-Console Experience: View 1 (Operational Store & Copilot): A real digital services marketplace (GPU compute, datasets, APIs) paired with an action-oriented conversational Copilot displaying tactile transaction cards and downloadable AP2 settlement certificates. View 2 (Treasury & Risk Command Center): Full-width AG Grid Enterprise ledger with custom status renderers paired with AG Charts Enterprise dashboards tracking GMV, threat quarantines, and escrow velocity.
How we built it
Core Fiduciary Engine: Built with TypeScript and Node.js using @paypal/agent-toolkit/ai-sdk. Implemented an RFC 8785 canonical JSON serialization engine to guarantee byte-identical SHA-256 digests and Ed25519 digital signature verification.
PayPal Infrastructure: Integrated PayPal Orders v2 two-phase commit (AUTHORIZE → → CAPTURE / VOID) with delayed platform disbursements and partner attribution tracking.
APIMatic Context Engine: Ingested third-party OpenAPI 3.1 specifications dynamically to synthesize type-safe LLM tool schemas at runtime for A2A negotiation.
Enterprise Observability & Visuals: AG Grid Enterprise: Real-time multi-tier transaction ledger with quartz styling, custom cell renderers, sorting, and master-detail AP2 JSON drawer expansion.
AG Charts Enterprise: Visualized cumulative settlement volume over time, OWASP threat quarantine ratios (Donut Chart), and escrow hold latency (Histogram).
Apple-Grade Design System: Applied Emil Kowalski’s Apple Design principles: warm stone palette (#FAFAF9), Instrument Serif display typography, frosted glass materials (backdrop-filter: blur(24px)), and tactile pointer-down spring feedback (scale(0.98)).
Deployment & CI/CD: Fully containerized using a multi-stage Dockerfile and automated for continuous deployment on Render via render.yaml.
Challenges we ran into
- RFC 8785 Canonical JSON Serialization: Standard JSON.stringify produces non-deterministic key orderings across different agent runtimes, breaking cryptographic signature verification. We implemented a strict RFC 8785 canonicalization engine ensuring byte-identical SHA-256 digests across Buyer, Seller, and Fiduciary agents.
- Defending Against Inter-Agent Prompt Injection: Rogue seller agents attempting to double prices or capture funds early via conversational text payloads. We solved this by enforcing a strict "Verify-then-Pay" boundary: conversational LLM context is completely quarantined from the financial execution layer, and transactions are hard-capped by deterministic Intent Mandates.
- Two-Phase Platform Escrow Automation: Bridging PayPal’s Orders v2 AUTHORIZE state with automated deliverable hash verification so that funds are released or auto-refunded deterministically without human checkout friction.
Accomplishments that we're proud of
14/14 Automated Tests Passing: Comprehensive test suite covering cryptography, mandate validation, APIMatic discovery, OWASP prompt injection quarantining, PayPal Orders v2 escrow, and PYUSD settlement. Real Sandbox API Execution: An end-to-end working product making real, authenticated PayPal Sandbox Orders v2 API calls with official partner attribution. Protocol Standard Pioneer: Implementing Google's cutting-edge Agent Payments Protocol (AP2) specification and proving how PayPal can dominate the emerging A2A standards race. Apple-Caliber UX: Crafting a calm, editorial, tactile dual-console design that completely rejects generic AI/cyberpunk clichés.
What we learned
"Verify-then-Pay" is Non-Negotiable: Probabilistic LLMs should never have direct, unconstrained access to financial execution APIs. Deterministic cryptographic mandates are essential for autonomous agent safety. AP2 Solves the Trust Deficit: Isolating intent into an immutable Cart Mandate with a SHA-256 deliverable oracle eliminates counterparty risk between autonomous machines. Dynamic API Context is Transformative: APIMatic's ability to parse arbitrary OpenAPI contracts at runtime enables true autonomous interoperability without manual client engineering.
What's next for pyFides
On-Chain PYUSD Smart Contract Escrow: Deploying native Solana and Ethereum smart contract escrow contracts for on-chain PYUSD decentralized settlement. Automated Dispute Arbitration Pools: Integrating PayPal Disputes v2 APIs to automate edge-case arbitration when deliverable SLAs are contested. APIMatic MCP Package: Publishing an off-the-shelf Model Context Protocol (MCP) server allowing developers to install pyFides escrow capabilities directly into Cursor, Claude Code, and autonomous agent swarms with a single command.
Built With
- agstudio
- ap2
- apimatic
- ed25519
- mcp
- paypal
- qwencloud
- render
- typescript