Inspiration

Autonomous agents already draft invoices, hire contractors, negotiate rates and fill in forms. The moment money moves, a business owner faces two bad choices: hand the agent the PayPal token and hope, or keep a human in every step and become an approval button.

Escrow protects the buyer from the seller. Nothing protected a business owner from their own agent. And for freelance work, nothing protected either side from going first: the client won't pay for work it hasn't seen, and the studio won't hand over work that isn't paid.

Underneath it all is the same flaw: the rule that decides whether money may move lives in a prompt or in someone's head, not in code the owner controls. One prompt injection, one lookalike vendor, one wrong decimal, and the money is gone.

Mandate is the third option. An agent gets a wallet of authority, not a wallet of money.

What it does

Mandate is a deterministic spend-authority layer in front of PayPal. People and AI agents ask; a pure function of the owner's signed rules decides; PayPal moves exactly the cents that were locked.

  1. Anyone can ask, nobody can pay. Agents connect over the Model Context Protocol (MCP), with a key or a browser sign-in (OAuth 2.1 + PKCE). A studio's agent gets 13 tools: 8 read, 5 ask or negotiate. None can approve a payment, send money or change a rule.
  2. A pure function decides. Every charge, payout and refund gets DENY, AUTO or NEEDS_APPROVAL from decide(), with no model in the decision. It checks payees, categories, monthly caps, milestone limits, funding coverage and duplicate asks.
  3. Risk can only add friction. Velocity spikes and new evidence hosts raise AUTO to NEEDS_APPROVAL; a lookalike payee ("P. Shah" for Priya Shah) is refused and named (risk.payee_impersonation). A risk signal can never soften a refusal or skip a tap.
  4. Say yes to the rule, not the payment. A signed standing rule ("pay Mateo half of what Coastline pays") sends matching payouts with no tap, through PayPal Payouts, only from client money PayPal confirmed settled on the same job. Everything else waits for the owner.
  5. Two companies' AI agents negotiate. Each side's negotiator knows only its own private walk-away and target. A deal exists only when one side accepts the other's exact offer; the server re-checks both companies' current rules and signs it, and each side gets a debrief.
  6. Paid on approval, for project work. Paste a client's brief: a model drafts paid stages and code checks them against the brief's own budget, deadline and counts. The client approves the plan on a private link, with no account, and both sides sign it. Work goes out sealed (blurred previews, a check against the plan where an AI look at the images can only add doubt, watermarked review copies and close-ups). The client pays each stage into a PayPal hold (Orders v2 AUTHORIZE); only their approval captures it, and the studio's own Settle is refused. Silence past the review window releases it; a missed revision deadline lets the client void it.
  7. Know the worst case before it happens. Blast radius computes from the signed rules and the ledger the most that could ever leave with no tap. Attack my rules plays a hostile proposer against the real gate on a copy of the ledger and suggests the fix. A regret window lets the owner undo an automatic payment before it is sent.
  8. A refund that would leave the studio short never goes by itself. When a client wants money back after the contractor was already paid, the rules refuse to send it automatically (refund.unfunds): the owner decides, and the job shows exactly how short the studio is.
  9. On-page card payments. Clients pay with PayPal's card fields inside our page. The server re-reads the order and refuses to capture if the amount, currency or reference differ by a cent; 3-D Secure is verified against PayPal, not trusted from the browser.
  10. Every dollar has a receipt. A SHA-256 lock signed with Ed25519, PayPal's ids, the fee and a cents match. Each lock and standing rule is also a credential shaped after the Agent Payments Protocol (AP2) mandate (mandate.payment.closed.1 / open.1, compact EdDSA JWS). Any receipt verifies in the browser against public keys, without trusting our server.

How we built it

  • Server: TypeScript on Node.js 24, Hono, Zod and node:sqlite in immediate transactions. Integer cents everywhere, idempotency keys on every write, an OpenAPI document for 116 operations.
  • PayPal: Orders v2 (card fields on our own page, and AUTHORIZE holds with capture, void and reauthorize), Payouts v1, Payments v2 refunds, Invoicing through the Agent Toolkit, disputes, transaction search, and webhook signature verification.
  • Authority and cryptography: a pure gate (decide()), Ed25519-signed locks over payee, cents, proof, job and funding, WebAuthn passkeys for taps, HMAC-SHA256 machine keys.
  • AI: open-weights models on Ollama Cloud through the Vercel AI SDK: gpt-oss:120b for the two negotiators, gemma4:31b for the rules drafter and the look at delivered images, gpt-oss:20b for the clerk, the outside agent and project plans. Prompts are versioned, fenced against injected text and snapshot-tested; any sentence that claims money moved is taken back.
  • Console: React, Vite, TanStack Query and vanilla CSS; an AG Grid ledger with CSV export; a control room built on AG Studio with an AI analyst that can change the dashboard and nothing else.
  • Proof: 1,226 API tests (Vitest, fast-check property tests, 46 red-team cases), 189 browser tests in 30 Playwright specs on desktop, a Pixel 7 and a passkey profile, with an axe WCAG 2.1 AA scan on every signed-in screen.

Challenges we ran into

  1. Exactly once, under concurrency. Duplicate asks, webhook replays and the sweep racing on the same row. Solved with a stable ask-hash, duplicate.open, and one transaction per state change.
  2. Settling to the cent. A short payment must name which PayPal field explains the gap (a discount, a credit note, a fee, a partial), and only when that field equals the gap.
  3. Money that waits on the client's side. A PayPal hold is still the client's money. Only the client's release may capture it, holds past PayPal's honor period are reauthorized, and an expired or voided hold never counts as paid.
  4. The client's number is not the studio's to see. Hiding it in React was a costume; the API still returned it. Sealing it meant redacting the server and refusing the owner's write.
  5. The browser can lie about 3-D Secure. The server reads the issuer's answer from PayPal and follows PayPal's recommended-action table before it captures.

Accomplishments that we're proud of

  • 1,226 API tests across 102 files and 189 browser tests in 30 specs, all green in CI, with CodeQL and secret scanning on every pull request.
  • 26 verified guarantees, checked on every build: no payout above the contractor's share, nothing paid from money that has not arrived, no AI can reach PayPal, a buyer cannot change what is paid.
  • Real PayPal sandbox, end to end: card captures on our own page (16863006RF678602F, 79204140TH113652R), an invoice settled only when PayPal said PAID (INV2-76H8-5LLT-E4P4-C2HD), contractor payouts (SJ5B3GGM7UBAU, DKPZEQ87HG8MU), a payout sent by a standing rule with no tap (9Z37SHHD8E598), a partial refund (12C310409G863064M), and a project stage paid by card into a PayPal hold (4YT88518FR6300422) captured only when the client approved (52Y4001561811571D).
  • Offline verification: a tampered receipt fails in your browser, against public keys, with no call to our server.

What we learned

  • AI may only add friction. A model can make something need a tap; it can never remove a refusal, approve, or pay.
  • A rule in a prompt is not a rule. Versioned, signed data read by a pure function is the only version a finance person can audit.
  • Refusals are the product. Owners don't ask "how do I pay?" first; they ask "why did it say no?" So the code names the rule, the field and the number.

What's next for Mandate

  • Postgres and production multi-tenancy (a driver change, not a redesign).
  • Bind each agent's own public key into the AP2-style mandate (cnf), so a credential proves which agent it was issued to.
  • More rails behind the same gate (ACH, cards, local wallets) and quorum approval above a threshold.

Built With

Share this project:

Updates

Submission history