Docs

Agents

Pay for x402 resources

A vault can pay for x402 resources, APIs and data that answer HTTP 402, in USDG on Robinhood Chain. The agent pays only sellers the owner listed, inside the agent's USDG cap, and a payment the seller never collects can be sent back to the vault.

How a payment works

An x402 payment is an EIP-3009 transfer signed by the payer. A vault is a contract, and the agent's key cannot sign for it, so the agent funds MortiseX402Escrow with exactly the price instead. The escrow then stands as the payer: through ERC-1271 it approves only the transfer it recorded, to that seller, for that amount, before its deadline. The seller's facilitator collects it with USDG's transferWithAuthorization, as with any other payer.

RuleWhere it is enforced
The seller's payTo address must be listed, even with open marketsX402Adapter and the Gate
The payment counts against the agent's USDG cap when it is fundedThe Gate
One payment per funding, its deadline at most one day awayMortiseX402Escrow
An uncollected payment goes back to the vault that funded it after its deadlineMortiseX402Escrow, reclaim callable by anyone

A payment sent back does not restore the cap. The escrow ignores the signature bytes, so the SDK and the MCP server send a fixed 65-byte placeholder for facilitators that parse one. Adapter: 0xa3e7A52413be4c050f9d613c00b614f5dc59cCEb.

List a seller

Give the agent the x402 adapter, list the seller's payTo address and set a USDG cap. In the app, plug in x402 payments from the catalog; with the SDK:

owner.ts
import { gate, markets, mortise } from "@mortiseagentvault/sdk";

// Once per seller, in a root user operation: the agent may pay this payTo address and nothing else.
const calls = [
  gate.setAdapterAccess(AGENT, mortise.x402, true),
  gate.setMarket(mortise.x402, markets.x402Payee(SELLER_PAY_TO), true),
  gate.setCap(AGENT, USDG, 1_000_000n, 86_400n), // 1 USDG a day
];

Pay as the agent

Over MCP, the agent calls mortise_pay_x402 with the URL, the method, an optional body and maxValue, the most it may pay in USDG raw units (100000 is 0.10 USDG). With the SDK:

agent.ts
import { payX402, X402PaymentError } from "@mortiseagentvault/sdk";

try {
  const paid = await payX402(client, agentWallet, vault, "https://seller.example/report", { maxValue: 100_000n });
  console.log(paid.status, paid.collected, paid.settlement);
} catch (err) {
  // Thrown after the payment's terms were fixed: keep err.terms.nonce to reclaim it if it was funded.
  if (err instanceof X402PaymentError) console.log(err.terms.nonce);
}

Both read the price first and refuse, before anything is sent, a price above maxValue or a seller the owner did not list. Every answer after funding carries the payment's nonce. Do not pay again for the same purchase: check whether the first payment was collected.

Which sellers accept it

The seller's facilitator decides whether a payment is valid, and it must accept a contract payer through ERC-1271. These facilitators accepted a Mortise escrow payment on Robinhood Chain mainnet:

FacilitatorHow it was proven
The official @x402/evm facilitator, run by the sellerA live payment of 0.02 USDG, verified and settled on chain
Ultravioleta's public facilitator, facilitator.ultravioletadao.xyzA funded payment verified as valid, in x402 v1 and v2
Facilitators that accept only EOA signatures

Some x402 sellers on Robinhood Chain run facilitators that check the signature against a private key only. They refuse the escrow before collecting anything, and the payment can be taken back after its deadline. A seller can accept Mortise vaults by running the official @x402/evm facilitator or by using one listed above.

Take back an uncollected payment

After the payment's validBefore, call mortise_x402_reclaim with its nonce, or send the escrow's reclaim from any account. Before the deadline the escrow refuses with StillOpen, a collected payment with AlreadyPaid, and one already sent back with AlreadyClosed.

reclaim.ts
import { x402Escrow } from "@mortiseagentvault/sdk";

// After validBefore, any account may send it; the value goes back to the vault that funded the payment.
const { to, data } = x402Escrow.reclaim(NONCE);
await wallet.sendTransaction({ to, data });