
# Flying Money and x402

[x402](https://docs.x402.org) is HTTP 402 "Payment Required" with a standard way to name a price and pay it. Flying Money
works with it in two directions. Pick the one that matches what you are building.

| You are… | You want… | Use | Status |
|---|---|---|---|
| **An agent or its owner** | Pay *any* x402 site (one that has never heard of Flying Money) from a capped budget, with no wallet and no gas for the agent | [The bridge](/docs/bridge) | Prototype. Test networks. Tested against a real third-party x402 site |
| **A seller or API developer** | Let agents pay *you* from a budget, in the x402 flow you already use | [The `flying-money` x402 scheme](/docs/server#x402-optional) (`x402: true`) | Prototype, live on the demo seller |
| **A buyer developer** | Pay sellers that list the `flying-money` scheme | `fm.fetch`, see [Client](/docs/client#x402-sellers) | Prototype |

Both are the same Flying Money budget underneath: money set aside for one payee, spendable by one key, up to its amount,
until an end date, never cancellable early. Nothing about the contract changes for x402.

## Pay any x402 site (agents)

Most x402 sites charge by a USDC transfer signed from the buyer's own wallet. An agent's spending key holds no money, so
it can't sign that. The bridge fixes this without asking the site to change:

1. Your owner runs a **bridge** and makes a small budget for it (the budget's payee is the bridge).
2. Your agent calls the site with `fm_paid_fetch`. The result says `"via": "bridge"`.
3. The bridge reads the site's own price, the agent signs a note for exactly that, and the bridge pays the site.

The agent never holds money, never pays gas, and never signs more than the quoted price. The owner's cap is the budget.
Step by step: [Pay any x402 site](/docs/bridge).

**One caveat to say out loud:** the bridge is the budget's payee and quotes the prices the agent signs. The contract pays
only against notes the agent's key signed, so the bridge can't take the whole budget by itself, but a dishonest bridge
could over-quote each request up to the agent's price limits, and it sees every request. Run your own, keep budgets
small and short, and set a low `FM_MAX_PRICE`. This is why the bridge is self-hosted first.

## Accept budgets on your own x402 API (sellers)

Add `x402: true` to the Flying Money middleware. Every 402 then also carries a standard `PAYMENT-REQUIRED` header that
lists the `flying-money` scheme, and the payment can arrive in `PAYMENT-SIGNATURE`. The slip goes through exactly the same
checks as the native header. Details: [Sellers](/docs/server#x402-optional) and the
[scheme](https://github.com/raldblox/flying-money/blob/main/docs/design/x402-flying-money-scheme.md).

What a budget gives a seller that a plain x402 payment doesn't: the money can't be pulled back before the end date, so a
seller that has checked a budget once can accept its payments **even with no connection**, and collect many purchases in one
transaction.

## A public bridge to try

A hosted beta bridge runs at `https://flying-money-bridge.vercel.app` (Base mainnet, real USDC, small limits, not audited). Details and
limits: [the hosted bridge](/docs/bridge#the-hosted-bridge-base-mainnet-beta). Agents can also read it as a skill:
[Agent skills](/docs/skills).

## See what a bridge is doing

Every bridge publishes a read-only status, and the app shows it at [/bridge](/bridge): its wallet balance and health,
what it has paid and collected, what the contract still owes it, and a log with a transaction link for each payment. The
balance, budgets and collected totals are read from the chain, so you don't have to trust the bridge. Details:
[Check a bridge](/docs/bridge#check-a-bridge-transparency-and-monitoring).

## What works today

- **Networks:** test networks. The bridge is tested on Base Sepolia, where public x402 facilitators exist. Arc and Base
  mainnet hold the contract under immutable caps, but the bridge has not been run on a mainnet yet.
- **x402 schemes the bridge can pay:** `exact` with USDC on EVM networks you list. Not yet: Permit2, `upto`, batch
  settlement, Solana and other non-EVM networks. It refuses those with a clear reason.
- **Not audited.** Treat the bridge as a prototype.

## For AI agents

If you are an agent: read [/agent.md](/agent.md). If your owner has set `FM_BRIDGE_URL`, `fm_quote` and `fm_paid_fetch`
pay ordinary x402 sites for you. If a call answers `no_certificate` with `"via": "bridge"`, call `fm_request_budget`
**once** with a small amount, give your owner the link, and poll `fm_request_status` until it says approved.

## Questions

**Is Flying Money an x402 facilitator?** No. A facilitator verifies and submits a payer's signed transfer. The bridge is a
*payer-side* service: it signs the transfer from its own wallet, and the site's own facilitator settles it.

**Does the bridge move money between chains?** No. It pays on the network the site names, from the bridge's own wallet on that network.
Budgets are collected into the same wallet. Nothing is bridged between chains.

**Why not just give the agent a wallet?** Because a wallet is unbounded. A stolen key drains it. A budget is capped by the
contract, and the agent's key is worthless without it.
