Autonomous outcome underwriting
Let AI agents buy outcomes.
Margin402 lets autonomous agents negotiate, pay, verify, and retry specialized services through x402 — so software can purchase reliable outcomes without human intervention. Humans watch. Agents transact.
Diagram: a task becomes a quote, capital is committed to a strategy, work is executed and verified, and the outcome settles — payment particles flow through each stage.
- Canonical quote
- $1.20
- First workload
- parseDuration()
- Verification
- 6 visible + hidden tests
- Settlement
- Algorand Testnet · USDC
01The problem
Machines can't open accounts, hold cards, or ask for help.
Autonomous software needs to purchase work the way it makes any other call: programmatically, per-request, without a human approving checkout. Margin402 is the counterparty that makes that possible — it sells outcomes and manages everything underneath.
Agents buy work, not API calls
A task may require several paid attempts before it succeeds — and the agent carries a budget, not infinite money.
The cheapest provider is rarely the cheapest path
A cheap provider that fails half the time can cost more in expectation than an expensive one that rarely fails.
Every failed attempt is sunk cost
Pay-per-call means the agent bears 100% of provider-failure risk on every single request, with no recourse.
Nobody is watching
No human can review each micro-decision of a fleet of agents in real time — payment and selection logic has to be trustworthy on its own.
02The core mechanism
Quote → pay → execute → verify → decide → settle.
The loop repeats per attempt until the outcome verifies or Margin402 refunds. Follow a single pass:
QUOTE
One fixed price
The customer submits a task and its tests. Margin402 answers with a single all-in quote for the verified outcome — not an hourly meter.
03The moment that matters
It could afford the payment. It chose not to make it.
$0.85
REJECTED
“Payment rejected: economically inferior to available alternative.”
Affordable does not mean economical. That distinction is the product.
04Verification
Verified against tests the provider never saw.
Providers are shown only the 6 visible tests. The other 2 exist to catch work that special-cases what it can see instead of solving the problem. Every attempt faces all 8 — there is no looser check for what the provider was shown.
Visible suite · provider saw these
Hidden suite · never exposed to providers
05Autonomous economics
Not a payment forwarder. An underwriter.
Selection by expected cost
Every round, remaining strategies are ranked by expected cost-to-success — price and failure probability together, never price alone.
Affordability is a separate check
Being able to pay is never the reason to pay. A strategy that fits the budget can still lose to a cheaper expectation.
The honouring rule
If the only path to done costs more than what remains of the budget, Margin402 pays anyway while losing less than a refund would cost. Delivery beats retreat.
| Strategy | Price curve | p (pass) | Attempt cap |
|---|---|---|---|
| Draft | $0.05 flat | 0.35 | |
| Repair | $0.09 flat | 0.45 | |
| Premium | $0.55 → $0.85 → $1.05 | 0.85 |
The cheapest option isn't always the cheapest outcome — a $0.05 attempt failing 65% of the time can cost more than it looks.
06How agentic payments work
Payment is part of the request.
A machine can't hold a card or approve a checkout. x402 turns “pay for this” into one HTTP round trip — no session, no stored credentials, no human. That is what lets Margin402 pay per attempt, per strategy, entirely under its own economic logic.
- 01402Provider answers an unpaid request with 402 Payment Required and its terms.
- 02SIGNMargin402's treasury wallet signs the exact quoted amount (@x402/avm).
- 03RETRYThe same request is retried with the signed X-PAYMENT header attached.
- 04VERIFYThe GoPlausible facilitator verifies the payload against the challenge.
- 05SETTLEThe facilitator settles on-chain — USDC moves on Algorand Testnet.
- 06RECEIPTThe paid response carries the real transaction ID, linked to this attempt forever.
07The machine customer
No UI required.
Everything this product does is available over plain HTTP — the same engine, the same payments, the same proof. A CI pipeline or an autonomous agent never needs to see this website.
- →POST /api/quote — price the outcome
- →POST /api/quote { offer } — one sealed counteroffer
- →GET /api/jobs/execute?revenue=… — stream the run as SSE
# quote the outcomecurl -s -X POST localhost:3000/api/quote \ -H 'Content-Type: application/json' \ -d '{"task":"Implement parseDuration()"}' # → {"quote":1.20,"validSeconds":60,…} # one sealed counteroffercurl -s -X POST localhost:3000/api/quote \ -H 'Content-Type: application/json' \ -d '{"offer":1.05}'# → {"decision":"ACCEPT","offer":1.05,…} # execute — decisions, x402 payments,# verification and settlement, streamed livecurl -N "localhost:3000/api/jobs/execute?revenue=1.05"# event: decision → payment → verification# → closed { outcome:"VERIFIED", settlements:[…] }08The economic statement
The loss is not hidden. The loss is the point.
Revenue
$1.05
Execution cost
$1.28
Margin
−$0.23
Margin402 had already accepted the job at $1.05. When the only remaining path to a verified outcome cost more than the budget that was left, it paid anyway — delivering at a loss cost less than refunding after sunk spend. Reproduce it: npm run machine:smoke.
Margin402 doesn't guarantee profit. It guarantees the outcome.
09Protocol architecture
One deployable unit. Every layer owned.
Customer agent
Margin402
Draft
Repair
Premium
Algorand Testnet
No database, no queue, no cache — a single Next.js application. The verifier is in-house and free, and is deliberately not for sale: it is the oracle the economics are judged against.
The agent doesn't need to know how the work gets done.
It only needs to know the outcome will be delivered.
Buy outcomes. Not tokens, not hours, not hope.