The operating system for autonomous onchain agents.
fold. gives agents the layer beneath reasoning: identity, payments, budgets, tools, gasless execution, transparency, and a runtime that persists after the human closes the tab.
§1Introduction
Agents do not fail because they cannot think. They fail because they cannot live: they cannot pay, cannot hold gas, cannot access gated tools, cannot enforce budgets, and cannot persist as a process.
fold. is an operating system for autonomous onchain agents. The word operating system is literal: fold treats agents as first-class processes with resources, identity, permissions, budgets, and system calls. A human does not repeatedly prompt an agent; the human briefs it, fences it, funds it, and deploys it.
The earlier fold product was narrower: a deployment surface for trading agents. That first system taught the core lesson. A trading agent did not merely need a better prompt. It needed a wallet, scoped signing rights, budget enforcement, paid information, gas abstraction, and a transparent audit trail. The OS version of fold generalizes that stack beyond trading.
The thesis
The thesis is narrow and falsifiable: an agent economy does not emerge from larger models alone. It emerges when agents can buy what they need, act without human-funded gas, and operate inside constraints that are enforced below the prompt.
- Reasoning is not enough. A perfect model still dies at a
402 Payment Requiredresponse it cannot pay. - Autonomy requires infrastructure. Wallets, budgets, tools, gas, and settlement are not accessories. They are the living conditions of an agent.
- Safety belongs below the model. A mandate must bind at runtime and signing boundaries, not merely as text in a system prompt.
What fold is
fold is composed of four layers, shipped in risk order rather than narrative order.
| Layer | Status | Purpose |
|---|---|---|
| Paid service layer | live | 24 x402-paid endpoints for trading intelligence, LLM inference, search, extraction, RPC, prediction markets, and market data. |
| Execution layer | live | Flat-fee /exec endpoint so external agents can buy search, RPC, and prediction results for 0.01 USDT per paid call. |
| Kernel and shell | in development | Browser desktop where wallets, tools, apps, and resident agents are windows and processes. |
| tref deployment | testnet · audit pending | Plain-language brief → ERC-4337 smart account → session-scoped key → mandate-enforced running agent. |
Design principles
Deploy, don’t prompt. An agent is a durable process with an identity and a lifespan, not a conversation pinned to a tab.
| Principle | Meaning |
|---|---|
| Mandate as contract | The human writes the objective, constraints, budgets, and stop conditions. fold compiles them into enforceable policy. |
| Machines pay like machines | One HTTP 402 challenge, one signed payment, one result. No account dashboard, no card, no subscription gate. |
| Draw the fence | The human defines the boundary. The agent optimizes freely inside it and cannot sign outside it. |
| Show the work | Every material decision carries rationale, confidence, information spend, cumulative spend, and references. |
§2The agent as process
A fold agent is not a chatbot plus wallet. It is a process with a security principal, a private state, tools, resource limits, and a lifecycle.
An agent is represented as:
where w is the wallet, M is the mandate, π is the model-driven policy, σ is mutable private state, and T is the set of priced tools the agent can call.
Resource semantics
Every action has a cost vector. Paid tool calls have a fee. Onchain transactions transfer value. Gas is accounted separately because fold can sponsor gas through the execution layer.
This separation matters. If an agent must hold ETH to act, it inherits a liveness dependency on a human. If the platform sponsors gas and prices it into fees, the agent can act from a wallet that has never held the native token.
§3The mandate
The mandate is the central abstraction of fold. A human writes what the agent should do, how it should behave, and what it must never do. fold compiles that into an enforced envelope.
| Field | Meaning | Example |
|---|---|---|
| O | Objective: bounded utility functional the agent maximizes. | Find profitable Base opportunities while minimizing drawdown. |
| C | Hard constraints: predicates over proposed actions and current state. | Only Base spot; no token younger than 30 days; no unknown contracts. |
| B | Budget triple: per-transaction, per-day, lifetime spend ceilings. | 25 USDC per trade, 100 USDC per day, 1000 USDC lifetime. |
| H | Halt conditions: deadlines, drawdown floors, kill switches. | Stop on August 1 or after 20% drawdown. |
Three enforcement rings
Prompt-only guardrails are not guardrails. fold enforces the mandate in three concentric rings.
| Ring | Locus | Mechanism | Survives |
|---|---|---|---|
| R3 | Policy | Mandate text in model context. | Advisory only. |
| R2 | Runtime | Pre-flight check before dispatch. | Model ignores instructions. |
| R1 | Chain | Session-key policy: signable set ⊆ admissible set. | Runtime compromise. |
If every value-bearing action requires a session-key signature whose policy enforces the mandate budget at validation time, then cumulative spend cannot exceed the lifetime budget even if the model is adversarial.
From brief to policy
The brief compiler has three stages:
- Elicitation. Natural-language brief is converted into candidate objectives, constraints, budgets, and halts. Ambiguity is legal only here.
- Normalization. Confirmed components become a canonical schema: typed predicates, integer budgets, timestamps, thresholds.
- Projection. The schema is projected into prompt text, runtime checks, and the enforceable subset encoded into session-key policy.
// Normalized mandate sketch
{
"objective": { "kind": "bounded_utility", "goal": "research and act inside constraints" },
"constraints": [
{ "type": "allowlist", "field": "chain", "values": ["base"] },
{ "type": "deny", "field": "unknown_contract" }
],
"budget": { "perTx": "25e6", "daily": "100e6", "lifetime": "1000e6" },
"halts": { "deadline": "2026-08-01T00:00:00Z", "drawdownPct": 20 }
}
§4x402 payment layer
Payments are the circulatory system of the agent economy. x402 lets a machine buy one unit of computation or data with one signed payment.
The exchange is intentionally small:
| Step | Actor | Action |
|---|---|---|
| 1 | Client | POSTs to a paid endpoint without payment. |
| 2 | Server | Returns 402 Payment Required with a machine-readable challenge. |
| 3 | Client | Signs an authorization for the exact challenged amount. |
| 4 | Client | Retries the same request with an X-PAYMENT header. |
| 5 | Server | Validates the request before settlement. |
| 6 | Server | Settles onchain and executes the request. |
| 7 | Server | Returns result plus settlement reference. |
A malformed request is rejected with 400 before any value moves. The payer loses a round trip, not a fee.
Deployed service surface
The service layer exposes endpoints across trading intelligence, inference, search, extraction, chain access, prediction markets, and market data.
| Family | Representative endpoints | Scheme | Price |
|---|---|---|---|
| Trading intelligence | /signal, /scan, /setups, /divergence, /funding-scan | upto | ≤ 0.02 USD |
| Indicators | /indicators, /levels, /snapshot | exact | 0.005 USD |
| LLM inference | /llm + model routes | upto | 0.0005–2.00 USD |
| Search | /search | exact | 0.007 USD |
| Extraction | /extract, /read, /structure | exact | 0.002–0.005 USD |
| RPC | /rpc across Base, Ethereum, Arbitrum, Optimism, Polygon | exact | 0.001 USD |
| Prediction markets | /prediction | exact | 0.002 USD |
| Market data | /token-price, /trending, /holders, /pools, /yield | exact | 0.001–0.005 USD |
Permit2 self-settlement
For assets without native authorization transfer, fold uses Uniswap Permit2 signature transfer. The payer signs a permit binding token, amount, nonce, deadline, spender, and witness. The settlement signer redeems it; the identity wallet receives value.
The separation between settlement signer and identity wallet limits operational risk. The signer can redeem a valid permit, but cannot enlarge it, replay it, redirect it, or move funds outside the signed constraints.
§5The /exec endpoint
/exec is the smallest complete instance of fold: a service an external agent can discover, price, pay, and consume in one loop.
The endpoint charges a flat 0.01 USDT per paid call and supports three tools whose marginal cost remains below the flat fee.
| Tool | Input | Output |
|---|---|---|
| search | { query } | Web/news results: title, URL, date, highlights. |
| rpc | { chain, method, params } | Read-only JSON-RPC result for supported EVM chains. |
| prediction | { query, limit } | Prediction market questions, outcomes, prices, and volume. |
// /exec request body
{
"tool": "search",
"params": {
"query": "Base agents using x402 payments"
}
}
Server-side handling
1 if payment header is absent:
2 return 402 + challenge(0.01 USDT, payee, settlementSigner, nonce, deadline)
3 if tool is unsupported:
4 return 400 + supportedTools // never charged
5 if params are invalid:
6 return 400 + reason // never charged
7 settle payment
8 dispatch in process
9 return 200 + result + settlement reference
§6Gasless execution
Gas is death one for autonomous agents. fold moves gas from the agent's liveness path onto the platform's execution layer.
Agent transactions can be submitted as ERC-4337 user operations. The smart account validates the signature and the session-key policy; the paymaster sponsors gas subject to its own policy. The agent does not need the native token.
The strategic value of gaslessness is not merely cost reduction. It removes the human operation of funding a wallet with native gas before an agent can act.
§7Economics of autonomous agents
An autonomous agent must survive three deaths before it can earn: gas, data, and tools. Each failure is infrastructural, not intellectual.
If each subsystem is 70% available, conversion is only about 34%. An OS raises each factor architecturally: sponsorship for gas, x402 for paid data, and unified tools for execution.
Value of information
Agents should buy information when it changes decisions enough to exceed its cost.
In the symmetric case, the minimum decision stake is:
| Price | q=.55 | q=.60 | q=.65 | q=.75 | q=.90 |
|---|---|---|---|---|---|
| 0.001 rpc | 0.02 | 0.01 | 0.007 | 0.004 | 0.003 |
| 0.002 prediction | 0.04 | 0.02 | 0.013 | 0.008 | 0.005 |
| 0.007 search | 0.14 | 0.07 | 0.047 | 0.028 | 0.018 |
| 0.010 exec | 0.20 | 0.10 | 0.067 | 0.040 | 0.025 |
| 0.020 signal | 0.40 | 0.20 | 0.133 | 0.080 | 0.050 |
Agent unit economics
The platform's job is to make everything except judgment cheap enough that judgment is what gets tested. If infrastructure drag dominates the equation, the agent economy never starts.
Marketplace dynamics
Flat pricing is not an aesthetic choice. A buyer agent comparing services must parse the price before it evaluates quality. A single flat number reduces evaluation cost and increases discoverability. This is why /exec uses one price even though its tools have different marginal costs.
§8The fold kernel
The kernel is a computer you walk into: a browser desktop where humans and agents share the same tools through different surfaces.
Application surface
| App | Backs onto | Status |
|---|---|---|
| wallet | Base account, balances, transfer | live service-backed |
| llm | /llm model routes | live service-backed |
| search | /search + /extract | live service-backed |
| signal | trading intelligence family | live service-backed |
| markets | token price, trending, pools | live service-backed |
| rpc | /rpc, five EVM chains | live service-backed |
| x402 | service storefront + terminal | live service-backed |
| agents | registry, status, budgets | gated on tref |
| deploy | tref pipeline | gated on tref |
| console | decision-record streams | gated on tref |
The GUI and the API are views of one system. Every capability a human can click, an agent can call, subject to the same mandate and payment rules.
§9tref deployment
tref is the path from a plain-language brief to a running, funded, mandate-fenced agent.
// tref deployment pipeline
1. elicit and confirm brief β into (O, C, B, H)
2. deploy ERC-4337 smart account w
3. issue session key k with policy projection of (C, B, H)
4. register (w, k, hash(M)) onchain
5. transfer funding F from principal wallet to agent wallet
6. start runtime process π with (w, k, M)
7. begin append-only decision-record stream
tref is specified and testnet-backed, but mainnet deployment is gated on independent audit. No unaudited contract should custody user value.
Threat model
| ID | Threat | Mitigation | Residual |
|---|---|---|---|
| T1 | Compromised or adversarial policy | R1 caps spend and targets. | Bounded bad trades. |
| T2 | Compromised runtime host | R1 unchanged; keys never leave signer boundary. | Bounded as T1. |
| T3 | Session key exfiltration | Policy travels with key; caps and expiry bind. | Bounded until expiry. |
| T4 | Malicious paid service | Exact payment bounds loss to per-call fee; reputation handles repeats. | Fee per call. |
| T5 | Settlement signer compromise | Signer cannot redirect payee. | Service disruption. |
| T6 | Bad judgment inside fence | Transparency and intervention. | Mandate-bounded loss. |
| T7 | Contract bugs | Audit before mainnet funds. | Unknown until audit. |
§10Transparency
Autonomy without legibility is a liability. fold agents emit decision records so humans can read the machine’s work.
{
"n": 421,
"ts": "2026-07-08T18:42:10Z",
"action": { "kind": "call", "endpoint": "/search" },
"rationale": "Need current market context before deciding.",
"confidence": 0.74,
"informationSpend": [
{ "endpoint": "/search", "cost": "0.007e6", "settlement": "0x..." }
],
"cumulativeSpend": "12.41e6",
"refs": ["ipfs://..."]
}
Confidence is treated carefully. Until enough outcomes exist for calibration, confidence is stated confidence, not measured probability. The intended loop bins decisions, measures calibration error, and applies a monotone recalibration map before using confidence as an R2 gate.
§11Wire formats
The request lifecycle is small enough to model explicitly. Smallness is a property: fewer states mean fewer hidden edge cases.
| State | Meaning |
|---|---|
| q0 | Request received; payment header presence checked. |
| q1 | 402 issued with fresh challenge; no side effects. |
| q2 | Tool and parameters checked against schema. |
| q3 | 400 issued; no settlement attempted. |
| q4 | Permit redemption submitted onchain. |
| q5 | Settlement failed; fresh challenge required. |
| q6 | Tool execution in progress. |
| q7 | 200 served with result and settlement reference. |
| q8 | Upstream error surfaced after settlement. |
Settlement is reachable only after the request passes schema validation. Unknown tools and invalid parameters terminate before value moves.
§12Reference schemas
Mandate schema
{
"version": "1.0",
"objective": {
"name": "bounded autonomous execution",
"utility": "maximize task completion under constraints"
},
"constraints": [
{ "type": "target_allowlist", "targets": ["0xRouter..."] },
{ "type": "chain_allowlist", "chains": ["base"] }
],
"budget": {
"perTransaction": "25000000",
"perDay": "100000000",
"lifetime": "1000000000",
"asset": "USDC"
},
"halts": {
"deadline": "2026-08-01T00:00:00Z",
"killSwitch": "enabled"
}
}
402 challenge schema
{
"scheme": "exact",
"asset": "USDT",
"amount": "10000",
"payTo": "0xPayee...",
"network": "base",
"nonce": "0x...",
"expiry": "2026-07-08T18:45:00Z"
}
§13Buyer-agent quickstart
A buyer agent does not create an account. It makes a request, receives a price, signs, retries, and receives the result.
// 1. Attempt request without payment.
const body = {
tool: "prediction",
params: { query: "Will ETH ETF inflows exceed expectations this week?", limit: 5 }
};
const r1 = await fetch("https://x402.fold.computer/exec", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body)
});
// 2. If 402, parse challenge and sign the exact authorization.
const challenge = await r1.json();
// 3. Retry with X-PAYMENT.
const r2 = await fetch("https://x402.fold.computer/exec", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-PAYMENT": signedPayment
},
body: JSON.stringify(body)
});
const result = await r2.json();
§14Verification and security checklist
| Check | Expected behavior |
|---|---|
| Malformed /exec call | Returns 400 and no settlement occurs. |
| Unsupported tool | Returns supported tools list; never charged. |
| Expired challenge | Settlement fails and a fresh challenge is required. |
| Replay attempt | Nonce prevents second settlement. |
| Budget breach | Runtime blocks at R2; session key blocks at R1 when value-bearing. |
| Halt flag | Runtime stops dispatch; session key revocation prevents further signing. |
§15Roadmap
Phases ship in order, and each phase must leave a working system behind.
| Phase | Scope | Exit criterion |
|---|---|---|
| P1 · done | Paid service layer | 24 endpoints live on mainnet; external settlements. |
| P2 · done | Execution + marketplace | /exec live; independent marketplace review passed. |
| P3 · now | Kernel shell | Desktop and first-party apps operable end-to-end in browser. |
| P4 · next | Kernel apps | Wallet, LLM shell, search, markets as windows; symmetric API. |
| P5 | tref audit & mainnet | Independent audit passed; mainnet deploys under mandates. |
| P6 | Resident economy | Deployed agents buying fold services under value-of-information logic at scale. |
§16Glossary
| Term | Definition |
|---|---|
| Agent | A policy with a wallet, a mandate, and tools; a process of the fold kernel. |
| Mandate | The compiled envelope of permitted behavior: objective, constraints, budgets, and halts. |
| Ring R1 | Chain-level enforcement through session-key policy. |
| x402 | HTTP 402-based machine payment protocol. |
| Exact scheme | x402 settlement mode that charges the challenged amount exactly once. |
| Upto scheme | x402 mode authorizing a ceiling and settling actual metered usage up to it. |
| Permit2 | Signature-transfer standard used for self-settlement where native authorization transfer is unavailable. |
| Paymaster | ERC-4337 contract that sponsors gas for user operations. |
| Session key | Scoped signing key whose policy encodes the enforceable projection of a mandate. |
| tref | The fold deployment pipeline: brief → smart account → session key → running agent. |