# Recta

> Recta is a preflight for AI agents that move stablecoins between blockchains. Before a transfer, the agent asks Recta; Recta reads every route it knows at the same chain state (Across, CCTP, Stargate, USDT0 and others) and returns the cheapest one it can prove, against the route the agent would have used anyway.

## When to call Recta

Call Recta before your agent moves stablecoins from one blockchain to another (a bridge or cross-chain transfer). Start with the free preflight: one call (MCP tool `recta_preflight`, or `POST /v1/preflight`) with only the corridor and the amount, no wallet and no address, answers whether a cheaper route exists at the same chain state, the proven saving, and what your route costs and when it arrives. If there is no saving, nothing is charged.

Transfers start on: arbitrum, arc, avalanche, base, bnb_chain, ethereum, hyperevm, ink, linea, monad, optimism, polygon, unichain. They can arrive on: arbitrum, arc, avalanche, base, bnb_chain, ethereum, hyperevm, ink, linea, monad, optimism, polygon, robinhood_chain, solana_mainnet, tron_mainnet, unichain. Assets: USDC, USDC_BINANCE_PEG, USDG, USDT, USDT_BINANCE_PEG, USDT_OP_BRIDGED. Amounts: at least 3.5 tokens of a stablecoin (about 3.5 USD), no maximum. The exact corridors are in the service descriptor.

## Fee

Recta charges exactly 5 % of the saving it verifies on chain after the agent executes its route. No saving, no charge. No prepayment and no credit: the agent signs, with each decision, a Permit2 authorization capped at `max_fee_authorization`, and Recta's collection pulls only the verified 5 % (never more than the cap) in USDC on Base; the payer's ledger shows whether each fee has been collected yet (`charged`). The evaluation itself is free. So the agent keeps at least 95 % of every saving Recta verifies, and pays nothing when there is none.

## Referrals

Earn 20 % of the fees Recta collects from agents you bring, for 12 months.

- The referred agent adds `?referrer=0xYourAddress` to its first signed evaluation. A plugin, framework or template can set it once for all its users (`referrer` in @recta/client, `RECTA_REFERRER` in @recta/mcp).
- You earn 20 % of each fee Recta actually collects from that agent (confirmed on chain), up to 200 USDC per referred agent. You do not need to pay fees yourself.
- One level only, and no self-referral. The referred agent still pays exactly 5 % of its verified saving; nothing is added.
- Your reward is applied as a discount on your own Recta fees, or paid in USDC on Base once it reaches 10 USDC.
- Your balance and who you referred: signed `GET /v1/referrals/balance`.

## Safety

- **Keys and funds.** Recta never receives a key and never holds funds: your wallet signs and sends every transaction. Where the key lives is your wallet's choice: a Coinbase CDP account keeps it at Coinbase, MetaMask's agent wallet in server mode keeps it at MetaMask, and `npx @recta/mcp` with `RECTA_PRIVATE_KEY` keeps it on the agent's machine in plain text (use a dedicated wallet).
- **How much, and to whom.** Recta sets no maximum amount, and the route delivers to the recipient your request names. Cap both on your side. From version 0.1.14, `npx @recta/mcp` refuses, before anything is signed, a transfer above `RECTA_MAX_AMOUNT` (default 1000 tokens) or to a recipient that is neither the wallet nor in `RECTA_ALLOWED_RECIPIENTS`; this protects against an agent acting through its tools, not one that can edit the server's configuration or run commands. In `mm recta move` the same limits are flags with the same defaults, which whoever runs the command can change. Recta's wallet policy below limits the contracts and approvals a wallet may use, not the amount or the recipient a bridge deposit names; for those, use a rule in your wallet on the deposit call's recipient and amount parameters, if your wallet supports one, and a daily limit.
- **What Recta can take.** Only what the fee permit you sign allows: exactly 5 % of the saving verified on chain, never more than the permit's cap, nothing without a saving.
- **Which contracts.** The wallet policy below lists every contract a route may approve or call. `@recta/client` and `@recta/mcp` send only approvals of exactly the amount sent to the pinned bridge contracts (Across, CCTP V2, Stargate and LayerZero OFT), those contracts' own deposit calls with no message or hook at the destination, and, for the fee, a bounded USDC approval to Permit2 on Base; they refuse anything else. Recta picks the cheapest route it can prove; it does not rank routes by security. These bridges are run by third parties, and some of their contracts are upgradeable proxies: Recta and its packages pin their addresses, not their code, so a bridge's own upgrade or failure is a risk Recta does not remove.
- **Non-EVM networks.** A transfer that starts on Solana, Tron or Bitcoin cannot be signed by an agent today, and the wallet policy's EVM allowlist does not cover those networks. A route from an EVM network to Solana or Tron can be served, but `@recta/client` and `@recta/mcp` refuse non-EVM recipients, so no package checks it: an agent that takes one must check the program and the recipient itself.
- **If the price moves.** An Across, CCTP or LayerZero route transaction fixes the least the recipient gets (Across `outputAmount`, CCTP amount minus `maxFee`, LayerZero `minAmountLD`) and its gas price ceilings are the ones your request set. `@recta/client` and `@recta/mcp` require that least amount to be at least `minOutputBps` of the amount (default 99 %) and refuse a route already past its `commercial_expiry_unix` before sending its first transaction. The fee is computed on the saving of the transfer as executed: if the saving shrinks, so does the fee.
- **Send within 60 seconds.** From an EVM network, a decision covers route transactions mined within 60 seconds of the source block Recta read (`commercial_expiry_unix` in the route). A transfer mined later still moves your funds, but Recta verifies no saving for it and charges nothing. Where the route needs a token approval first, send the approval and the deposit one after the other without waiting for the approval's receipt: `@recta/client` and `@recta/mcp` do so with a local key. A wallet that waits for each receipt before the next send can miss the window on Ethereum, where a block takes 12 seconds.
- **Replays.** A signed request carries its time (accepted within 5 minutes of Recta's clock, either way) and its body's hash, and an evaluation also its `Idempotency-Key`: the same key and body return the stored decision, never a second one, and the same key with another body is refused. A fee permit has a Permit2 nonce and is used once (an x402 payment reused answers `PAYMENT_ALREADY_USED`). Route transactions use your wallet's own nonce.
- **What Recta records.** Each evaluation (sender, recipient, amount, corridor) and its decision, signed or through the x402 route (where the sender is not authenticated); Recta does not delete these records today. A verified saving is published in the public savings ledger with both transaction hashes, so it is linkable to your address on chain. The free trial stores no decision and no address: only a keyed fingerprint of the sender, for 30 days, to count trials that lead to a signed evaluation. Rate limits count requests per IP address (an IPv6 /64) and network for up to a day. Recta's log lines for evaluations and executions carry no wallet address, transfer amount or transaction hash (they carry the result id). Cloudflare, which hosts Recta, sees each request's IP address, and its request logs, kept 7 days on Recta's plan, record each URL, which can include an address.
- **Review.** The service, its packages and its fee contract have been audited adversarially by Recta, and the contract was simulated against Base's real Permit2; there has been no independent external audit yet. The server behind api.recta.build is not open source; what you can check without trusting it is published: the packages (open source, MIT) check every transaction locally before signing, and each verified saving is listed with its transaction hashes to recompute on chain. Start with small amounts.
- **Changes.** The request contract is versioned (`RECTA_COMMERCIAL_EVALUATION_CONTRACT_V23` in the service descriptor). `@recta/client` and `@recta/mcp` pin Recta's routes, contracts and fee addresses per release and refuse a service that no longer matches them. With a local key, the package runs next to that key, so a compromised release could reach it: pin the exact version you reviewed (no ranges, no `@latest`), and check that it was built from RectaBuild/recta by GitHub Actions (`npm audit signatures`, npm provenance). `@recta/client` has no dependency of its own and takes `viem` as a peer range, which you pin; `@recta/mcp` pins `@recta/client` and `viem` exactly.

## Which route to declare

Declare as `baseline_provider` the route you would actually use without Recta. The saving and the 5 % fee are measured against it, so declaring a worse route only makes you pay more. The saving odds show how often Recta has found a saving on your corridor.

Before you sign anything, two free unsigned GETs answer whether it is worth asking: the [fit check](https://api.recta.build/v1/golden-corridor/fit?source_network=ethereum&source_asset=USDC&destination_network=arbitrum&destination_asset=USDC) (is the corridor covered, which routes are compared) and the [saving odds](https://api.recta.build/v1/golden-corridor/saving-odds?source_network=ethereum&source_asset=USDC&destination_network=arbitrum&destination_asset=USDC) (how often recorded decisions found a saving on that corridor). A third, the [request template](https://api.recta.build/v1/golden-corridor/request-template?source_network=base&source_asset=USDC&destination_network=arbitrum&destination_asset=USDC&amount=100&baseline_provider=lifi), returns the whole request body for your corridor, amount and route: you fill only your addresses and your own gas ceilings, then sign.

## Access

Every commercial request is signed by the EVM key of the agent's own sender address (EIP-191 personal_sign). No API key, account or secret is issued. The agent signs this text, one field per line:

```
Recta signed request v1
method: POST
path: /v1/golden-corridor/commercial-evaluations
idempotency-key: <the Idempotency-Key header, or empty>
body-keccak256: <0x keccak256 of the exact body bytes, lowercase>
issued-at: <unix seconds>
```

and sends `x-recta-signer` (its address), `x-recta-issued-at` and `x-recta-signature`. The signing instant may be at most 300 s from Recta's clock. For an evaluation, the request's `sender` must be the signer.

A smart account (ERC-1271, or ERC-6492 before deployment) adds `x-recta-signer-chain: 8453` (for now a smart account signs only on Base: its `source_network` must be `base`, the network where its fee is also collected, because the same address on another chain may be another owner's account) and signs, through its owner, `Recta signed request v2`, `signer: <its address, lowercase>` and `chain-id: <that id>`, then the same five lines. Recta asks the account on Base whether the signature holds (503 `SENDER_SIGNATURE_UNVERIFIABLE`, retryable, if the chain does not answer). Its execution may go through an ERC-4337 bundle or a call to the account; the account itself must transfer exactly the committed amount. Its fee permit (the same EIP-712 Permit2 typed data) is checked by ERC-1271 on the collection network, as Permit2 will check it: the account must already be deployed there (an ERC-6492 wrapper cannot be settled).

Wallets that sign x402 Sign-In-With-X (EIP-4361 / SIWE) messages can sign the same request that way instead: send it unsigned (body within the size limit), and the 401 carries `sign_in_with_x` with the challenge for that exact request (`info`) and, when the body names an EVM `sender`, the exact text that sender signs (`message_to_sign`) and the payload to send (`payload_without_signature`). Sign the text with EIP-191 personal_sign within 300 s, add `signature` to the payload, and resend the same request (same URL, Idempotency-Key and body bytes) with the header `SIGN-IN-WITH-X: <base64 of the JSON payload>`, the payload format of `@x402/extensions`. The message binds the method, URL, Idempotency-Key and body hash, Base (chain id 8453) and a 5-minute window, so it proves exactly what the text signature proves. A smart account signs it through its owner and is checked on Base by ERC-1271 (its `source_network` must then be `base`).

With an x402 client that pays the `upto` scheme on Base, no request signature is needed at all: POST the evaluation request body (your own `sender` and `recipient`) unsigned to `/v1/x402/route`. No proven saving answers 200 with your own route, free; a saving answers 402 with one `upto` requirement, the fee ceiling: pay it from your `sender` and repeat the same POST with `PAYMENT-SIGNATURE` to receive the route's transactions. A client that pays only the `exact` scheme cannot use it. The unsigned POST counts toward the free trial's 3 a day per IP address.

No signing code needed: the npm package @recta/client builds, checks and signs the request for you, and @recta/mcp (`npx -y @recta/mcp`) is a local MCP server that does it as tools: without a key it offers only the free fit check and trial; with RECTA_PRIVATE_KEY of a dedicated wallet (kept on your machine) it signs too. Evaluations are free and need no funds. Paying a fee needs the fee in USDC on Base and a USDC allowance to Permit2 (an ERC-20 approve of USDC to Permit2). If the transfer itself starts from USDC on Base, the wallet needs the transfer amount plus the fee.

No wallet yet? POST the same request body, unsigned, to /v1/golden-corridor/trial-evaluation (MCP: recta_trial_evaluation) to see whether a saving exists for your exact transfer and how much, before setting up signing. No wallet and no address are needed for the trial: without `sender` (or with the template's placeholder) Recta reads a stand-in address with no token approval, as for a first transfer, and without `recipient` toward an EVM network that same address; the answer lists them in `assumed`. Any other `sender` except the zero address, and any `recipient` of the destination network's kind (0x, or a base58 key toward Solana), are read as given, even ones you do not control, because nothing is sent, signed or charged. The address you would really send from gives the most exact figure, since the trial reads that address's token approval on chain. The trial names no route, stores nothing and is limited to 3 a day per IP address.

An unsigned call to a signed route answers 401 `SENDER_SIGNATURE_REQUIRED`, with the free trial and the request template under `next`. An unsigned evaluation POST also carries the free trial's own answer on that body in `free_trial_result` (not a decision; sign the same body to get the route).

## Flow

1. `POST /v1/golden-corridor/commercial-evaluations` with an `Idempotency-Key` header and the request schema below: a durable decision (whether a cheaper route is proven, and the saving's lower bound) or an abstention. Free. The route itself, its fee cap and its expected fee come in step 2.
2. `GET /v1/golden-corridor/commercial-evaluations/{result_id}/execution-artifact`: the transactions to sign. It first answers an x402 v2 HTTP 402 (header `PAYMENT-REQUIRED`, scheme `upto` on Base): the ceiling of the fee, settled later as exactly 5 % of the verified saving. An x402 client signs it and repeats the GET with `PAYMENT-SIGNATURE`, which returns the artifact; or `POST /v1/golden-corridor/commercial-evaluations/{result_id}/fee-authorization` with the signed Permit2 terms of the body.
3. The agent executes the transactions itself, then `POST /v1/golden-corridor/commercial-evaluations/{result_id}/execution` with `{ "origin_tx_hash": "0x…" }`. Recta verifies the delivery on chain and records the realized saving and its 5 %. A verified saving is published in the public savings ledger (`GET /v1/golden-corridor/savings-ledger`) with both transaction hashes, so it is linkable to your address on chain; nothing is published for a decision you do not execute.
4. `GET /v1/golden-corridor/commercial-accruals/{payer}`: the payer's fees and whether each was collected. An unpaid fee blocks new evaluations with HTTP 402 until the debt permit it offers is signed (`POST /v1/golden-corridor/fee-debts`).

When the decision is a verified zero (your declared route was already the best Recta could prove: `BASELINE_IS_WINNER`, `TIE` or `LOWER_BOUND_NOT_POSITIVE`), `GET /v1/golden-corridor/commercial-evaluations/{result_id}/route-certificate` returns a best-route certificate, free: an EIP-712 statement of what Recta compared at the anchor block, signed by the address `/v1/status` publishes as `commercial_evaluation.route_certificate_signer`. Anyone can check it offline (ecrecover); its EIP-712 domain has no chainId or verifyingContract because no contract verifies it. It is evidence for your principal, not a price guarantee.
How long a decision takes: `GET /v1/golden-corridor/latency` (public, no signature) answers the median and the 90th percentile, in milliseconds, of the time from admitting a new evaluation to storing its decision over the last 7 days, and `reliability`: of external agents' new evaluations that searched, the share that ended in a decision and how the rest failed (a failed one is free and retryable); Recta's own test traffic is counted apart. The figures are null until 20 are counted; a replay of a stored decision answers at once.
Verified savings, in public: `GET /v1/golden-corridor/savings-ledger` lists the savings Recta verified on external agents' executed transfers, newest first, with the origin and destination transaction hashes (check them on chain), the realized saving, Recta's 5 % fee and the saving's basis: measured against your declared route, or a same-route lower tip that rests on the tip you declared (its totals are kept apart). Recta's own test transfers are left out.
Proof of operation: `GET /v1/golden-corridor/proof-of-operation` (public, no signature) publishes Recta's two real test transfers with its own funds, about 10 USDC each (Base → Arbitrum and Arbitrum → Base): each saved about 12 % of the amount against the route declared and paid Recta exactly 5 % of that saving. Each entry carries both transaction hashes, the anchor block, the routes compared, the full accrual proof (its digest is checked before answering) and the Base transaction that collected the fee, with steps to recompute the saving yourself. They are labelled INTERNAL_TEST and are never counted in the savings ledger.

## Same route, lower tip

From Ethereum, add `execution_authority.baseline_priority_fee_per_gas_wei`: the priority fee you would pay on your own. Recta then commits every source transaction at `maxPriorityFeePerGas` = min(your T, 50000000 wei). When the route you declared is itself the cheapest one Recta finds, the saving is the priority fee this saves on the execution's intrinsic gas, never more than your max fee F leaves above the base fee, and the fee is its 5 % (`decision.same_route_priority_fee`). Declaring more only raises your fee. A lower tip can take a few more blocks under congestion. Omit the field to keep T as it is.

## Documents

- [Guides](https://api.recta.build/guides): for people and search: why no route is always the cheapest, and how to check your own transfer.
- [Worked examples](https://api.recta.build/guides/check-before-you-bridge-usdc-examples): copy-paste checks before a transfer, with real answers and when to keep your own route.
- [Trust](https://api.recta.build/guides/can-an-agent-trust-recta): the fee rule, keys, limits, versions, and what is proven with real money and what is not.
- [Service descriptor](https://api.recta.build/v1/golden-corridor/commercial-evaluations/schema): contract RECTA_COMMERCIAL_EVALUATION_CONTRACT_V23, corridors, providers, limits and the JSON Schemas of every body.
- [OpenAPI 3.1](https://api.recta.build/openapi.json)
- [Status](https://api.recta.build/v1/status): whether the service is ready.
- [Fit check](https://api.recta.build/v1/golden-corridor/fit?source_network=ethereum&source_asset=USDC&destination_network=arbitrum&destination_asset=USDC): unsigned and free; whether a corridor is covered and which providers Recta compares (never a route or a saving).
- [Saving odds](https://api.recta.build/v1/golden-corridor/saving-odds?source_network=ethereum&source_asset=USDC&destination_network=arbitrum&destination_asset=USDC): unsigned and free; how many recorded decisions on the corridor found a saving, by amount range (counts and dates only, never a route, winner or amount).
- Preflight (`POST https://api.recta.build/v1/preflight`): unsigned, free, no wallet and no address needed: only the corridor and `amount` are required (`baseline_provider`, the route you would use, is optional: without it Recta compares against `lifi`, LI.FI's own quote and what most agents use, or `across` where LI.FI does not apply; `sender`, `recipient`, `constraints` and `execution_authority` are optional too: Recta fills them as @recta/mcp would, reading the gas ceilings from the chain, and lists them in `assumed`; send your own `sender` for the most exact figure); make it before any transfer. The evaluation body, answered with your route's estimated total cost and arrival time and, when Recta proves a cheaper route, the saving, Recta's 5 %, that route's cost and arrival (never its name) and `execute_via_recta` (its `body_to_sign`: put your own `sender`, sign it and POST it to get the route). Network and asset keys are read case-insensitively and `amount` may be a number (listed in `normalized`). Nothing stored; 20 a day per IP address (the trial keeps its own 3), 500 a day in all with the trial. When it finds a saving, `execute_via_recta.fee_setup` says what taking it needs on Base and `execute_via_recta.with_x402` gives the x402 way to the route; after no saving, `best_route_certificate` says how to get a free signed certificate. Its own page: https://api.recta.build/preflight; its own MCP server (the free tools and the two signing steps): https://api.recta.build/preflight/mcp.
- Trial evaluation (`POST https://api.recta.build/v1/golden-corridor/trial-evaluation`): unsigned, no wallet; the evaluation body, answered with whether a saving exists, its lower bound and Recta's 5 %. No route, nothing stored, 3 a day per IP address.
- [Wallet policy](https://api.recta.build/v1/golden-corridor/wallet-policy): the networks, exact-amount approvals, contracts and fee recipient to allow in an agent wallet's policy before the first decision.
- [Wallet policy for Coinbase CDP](https://api.recta.build/v1/golden-corridor/wallet-policy/cdp): the same allowlist as a CDP Policy Engine policy (rules for sendEvmTransaction, signEvmMessage and signEvmTypedData), ready to create on an agent account.
- [ERC-8004 registration file](https://api.recta.build/v1/golden-corridor/agent-registration.json): Recta's on-chain agent identity document.
- [MCP server](https://api.recta.build/mcp) (Streamable HTTP): the same routes as tools, for agents that speak the Model Context Protocol. It never holds a key: the agent signs with its own wallet. Server card: https://api.recta.build/mcp/server-card; AI Catalog: https://api.recta.build/.well-known/ai-catalog.json.
