402 Payment Required envelope when the balance is short, and settlement debits the escrow after a successful round.
x402 (HTTP) and AgentEscrow (Solana PDA + ATA) are one product. Docs previously listed them as separate models; use this page for both.
Use x402 escrow when
- An agent needs verified data without a Molpha subscription.
- Payment should be exact USDC per round, priced by quorum.
- The agent can handle
402envelopes and fund an escrow ATA. - You want settlement through
settle_agent_round.
On-chain escrow
ATA(escrow PDA, USDC). The escrow account is created lazily on the first successful settle_agent_round.
In the common x402 loop, payer and authority are the same key:
authority can authorize requests.
Flow
- Agent calls
POST /v1/agent/executewith exactamountequal to the computed round price. - Gateway checks escrow ATA balance (minus reserved unsettled spend).
- If underfunded, gateway returns a standard x402
402 Payment Requiredenvelope withpayTo= escrow ATA. - Payer sends USDC to
payTo, signsAgentRequestAuth, and retries with the samecanonical_timestamp. - Gateway serves the round and records it in the settlement outbox.
settle_agent_roundverifiesAgentRequestAuth, transfers the locked price to the treasury, and writes an agent round-record PDA.
Feed still requires a separate permissionless submit_data_update.
Request authentication
The escrowauthority signs:
amount must equal:
ProtocolConfig. The gateway rejects any request where amount ≠ price (400, mirroring on-chain AmountMismatch).
Replay protection is the unique agent round-record PDA:
Failure handling
vs Delegate
Full HTTP schema: Gateway API.
Security notes
- Retry the identical request after payment (same
canonical_timestamp). - Treat gateway balance views as advisory until settlement finalizes.
- Verify the returned signed payload before application use.
- Enforce freshness on
canonicalTimestamp.