đź’ˇ Inspiration

AI agents have rapidly evolved from passive chatbots into autonomous software engineers, security auditors, translators, and data curators. Yet a fundamental bottleneck prevents the Agent-to-Agent (A2A) Economy from scaling: AI agents cannot safely participate in real-world commerce.

  1. The Blank-Check Hazard: Handing an autonomous agent unrestricted corporate credit card access invites catastrophic financial loss from hallucinations, prompt injections, or unverified vendor claims.
  2. The Human-in-the-Loop Bottleneck: Requiring human finance teams to manually review invoices and approve micro-payouts for every $150 agent task defeats the speed of autonomous workflows.
  3. Counterparty Trust Deficit: Provider agents and digital contractors have no cryptographic guarantee of payment before expending compute tokens unless funds are locked in trusted escrow.

We built Pacta (Latin for "agreed terms") to serve as the missing institutional clearinghouse for agentic commerce—combining PayPal Sandbox Escrow & Payouts, Google Gemini multimodal verification, Tavily live market rate intelligence, and an enterprise AG Grid v36 Financial Cockpit.


🚀 What It Does

Pacta is an end-to-end autonomous procurement, milestone escrow, redline verification, and instant settlement protocol structured around a 5-Stage Sequential State Machine:

  1. Stage 01 — Autonomous RFQ & Live Market Benchmarking (Tavily + Gemini):
    • A human operator or parent agent specifies a mission objective and budget (or selects from 4 pre-configured benchmark scenarios: DeFi Smart Contract Audit, Global App Localization, API Red-Teaming, or Synthetic Dataset Curation).
    • Pacta queries the Tavily Search API to benchmark live freelance and agency rates for that domain, then uses Google Gemini (@google/genai) to decompose the mission into sequential milestones with deterministic, machine-verifiable acceptance rubrics.
  2. Stage 02 — Cryptographic PayPal Escrow Lock (PayPal Orders API v2):
    • Before the provider agent writes a single line of code, Pacta creates and captures a conditional escrow order via the PayPal Orders API v2 (/v2/checkout/orders).
    • Funds are locked inside the PayPal Sandbox Escrow Vault, giving the provider agent verifiable proof of solvency while protecting the buyer’s capital.
  3. Stage 03 — Live Redline Proof-of-Work Audit (Gemini AI Judge):
    • When the provider agent submits its deliverable artifact (e.g., an AST security manifest, localization bundle, or dataset schema), Pacta’s Gemini Multimodal Auditor evaluates the submission against every contractual acceptance criterion.
    • Pacta renders an Executive Live Redline Verification Diff:
      • Verified Deliverables: Underlined in sage emerald with verified rubric badges.
      • Defective Deliverables: Struck through in crimson redline with explicit remediation warnings while keeping the PayPal Escrow Vault locked.
  4. Stage 04 — Instant Programmatic Disbursement (PayPal Payouts API v1):
    • If and only if the composite verification score satisfies the cryptographic release threshold, Pacta triggers the PayPal Payouts API v1 (/v1/payments/payouts) to disburse funds in milliseconds to the provider agent’s PayPal account.
    • Pacta generates a Tactile Perforated Paper Escrow Voucher complete with a rubber ink stamp (PAID & DISBURSED), a 10-segment analog verification gauge, and synthesized Web Audio sound effects.
  5. Stage 05 — Institutional Treasury Ledger (AG Grid Community v36):
    • Every escrow deposit, AI audit score, and PayPal payout batch ID streams into an institutional AG Grid v36 Financial Cockpit featuring custom status cell renderers, multi-column sorting, quick-search filtering, direct links to PayPal Sandbox activity, and 1-click CSV audit export.

đź§® Formal Verification & Escrow Release Model

Pacta enforces a deterministic release policy over stochastic agent outputs. Let a contract $C$ be decomposed into $M$ sequential milestones ${m_1, m_2, \dots, m_M}$, where each milestone $m_k$ locks capital $B_k$ in the PayPal Orders v2 Vault and defines $N$ binary or weighted rubric criteria ${r_1, r_2, \dots, r_N}$ with weights $w_i$ such that $\sum_{i=1}^{N} w_i = 1$.

When a provider agent submits proof-of-work artifact $P_k$, the Gemini Auditor evaluates each criterion $g(P_k, r_i) \in [0, 100]$ to compute the composite verification score $S(P_k)$:

$$S(P_k) = \sum_{i=1}^{N} w_i \cdot g(P_k, r_i)$$

Programmatic disbursement via the PayPal Payouts API v1 is governed by the step function $\Phi(P_k)$ with threshold $\tau = 85$:

$$\Phi(P_k) = \begin{cases} \text{EXECUTE_PAYOUT}(B_k, \text{PayPal_Payouts_v1}) & \text{if } S(P_k) \ge \tau \ \text{LOCK_VAULT_AND_REDLINE}(B_k, \text{Orders_v2}) & \text{if } S(P_k) < \tau \end{cases}$$


🛠️ How We Built It

  • Frontend & State Architecture: Built with Next.js 16 (App Router), React 19, TypeScript, and Tailwind CSS v4. We designed an Executive Editorial Paper & Ink UI (#F7F6F2 warm archival paper stock, Newsreader editorial serif typography, Geist Mono telemetry, and tactile perforated thermal vouchers) that stands apart from generic dark SaaS templates.
  • PayPal Sandbox Integration:
    • OAuth 2.0 Token Exchange: Dynamic bearer token negotiation against https://api-m.sandbox.paypal.com/v1/oauth2/token.
    • PayPal Orders API v2: Creates and captures milestone escrow deposits (/v2/checkout/orders).
    • PayPal Payouts API v1: Automates instant settlement (/v1/payments/payouts) with unique sender batch IDs upon AI audit approval.
  • AI & Market Intelligence Stack:
    • Google Gemini (@google/genai): Powers both the Buyer Negotiator Agent (structured JSON milestone generation) and the AI Judge / Auditor (strict rubric scoring and redline rationale).
    • Tavily Search API: Executes real-time web searches to benchmark current freelance and agency pricing before locking budgets.
  • Enterprise Financial Visualization:
    • AG Grid Community v36 (ag-grid-react / ag-grid-community): Powers the Stage 05 Financial Cockpit with custom cell renderers for PayPal Reference IDs, AI verification progress bars, transaction type filters, and CSV export.
  • Zero-Asset Web Audio Synthesizer: Custom browser AudioContext oscillator engine synthesizing mechanical clicks, rubber stamp thuds, and payout chimes with zero external MP3 dependencies.
  • Client-Side BYOK & Zero-Crash Resilience: Judges can supply their own PayPal, Gemini, and Tavily keys via the in-app BYOK Keys drawer (persisted strictly in browser localStorage) or test immediately out-of-the-box via Pacta's deterministic sandbox emulation fallbacks.

đźš§ Challenges We Ran Into

  1. Preventing Interface Overload in Multi-Agent Workflows: Early iterations displayed the RFQ composer, topology mesh, escrow receipts, and AG Grid ledger all on a single vertical page, creating cognitive overload. We refactored Pacta into a 5-Stage Sequential State Machine with an interactive Guide Me spotlight tour that highlights each active component and automatically resets to Stage 01 upon completion.
  2. Making AI Arbitration Auditable: A raw percentage score from an LLM isn't enough for financial compliance. We engineered the Stage 03 Live Redline Diff and 1-Click Dual-Path Benchmark Injectors (🟢 Inject Passing Proof (96%) vs. 🔴 Inject Failing Proof (42%)) so judges and treasury operators can visually inspect why a deliverable was approved or rejected before a single dollar leaves escrow.
  3. Ensuring 100% Judge Testability: Hackathon judges shouldn't hit a wall if they don't have four separate API keys handy. We built a dual-mode credential pipeline that executes live PayPal/Gemini/Tavily calls when keys are present and seamlessly falls back to high-fidelity sandbox emulation when keys are omitted.

🏆 Accomplishments

  • True Closed-Loop Agentic Commerce: Moving a contract from natural-language intent to Tavily market pricing, PayPal Orders v2 escrow capture, Gemini redline verification, PayPal Payouts v1 disbursement, and AG Grid ledger reconciliation in under 60 seconds.
  • Executive Editorial Design: Crafting a distinct legal/financial aesthetic with live redline diffs, serrated paper escrow vouchers, and synthesized tactile audio.
  • Interactive Judge Experience: Building 4 domain scenarios, a real-time background transaction stream (LIVE SIM: ACTIVE), dual-path passing/failing proof injectors, and a 9-step spotlight tour.

📚 What We Learned

  • How to pair PayPal Orders v2 and PayPal Payouts v1 as a programmable two-phase commit (escrow lock $\rightarrow$ conditional release) for autonomous AI agents.
  • How grounding LLM contract negotiation with live Tavily market data prevents unrealistic milestone budgeting.
  • How AG Grid v36 can transform raw API settlement events into an institutional-grade treasury command center in minutes.

đź”® What's Next for Pacta

  • Multi-Agent Bidding Marketplace: Allowing multiple specialized provider agents to bid on open RFQs in real time based on their historical Gemini verification scores.
  • Cryptographic Webhook Dispute Escalation: Integrating PayPal Webhooks for automated partial-milestone refunds and multi-model consensus arbitration (combining Gemini Pro with deterministic CI/CD test runners).

Built With

  • ag-grid
  • agentic-commerce
  • ai-agents
  • google-gemini
  • nextjs
  • node.js
  • paypal
  • paypal-orders-api
  • paypal-payouts-api
  • react
  • render
  • tailwindcss
  • tavily
  • typescript
  • web-audio-api
Share this project:

Updates

Submission history