← All research and guides

x402 guide · November 2026

Accept USDC on NEAR with x402. A seller's guide.

Frits Zwager, Fizzl · 19 November 2026 · we run x402 Doctor, whose facilitator is used in the example

x402 lets an AI agent pay for your API in the same request: your route answers 402 Payment Required with a price, the agent pays and asks again, and gets the answer. Since the NEAR mechanism for x402's exact scheme (@x402/near), that payment can be USDC on NEAR. The buyer signs one transfer and a facilitator's relayer pays the gas, so nobody needs NEAR for gas.

This guide adds a NEAR option to an Express route, step by step. The code below was run against a live facilitator on 19 November 2026; the 402 it printed is shown in step 3.

How a NEAR payment works

1. Install

npm install express @x402/express @x402/core @x402/near

2. Add NEAR to your route

Register ExactNearScheme for near:mainnet on the resource server and point it at a facilitator that settles NEAR. The price is in dollars; the scheme turns $0.01 into 10000 (USDC has 6 decimals).

import express from "express";
import { paymentMiddleware, x402ResourceServer } from "@x402/express";
import { HTTPFacilitatorClient } from "@x402/core/server";
import { ExactNearScheme } from "@x402/near/exact/server";

const facilitator = new HTTPFacilitatorClient({
  url: "https://x402-doctor.fizzl.eu/facilitator",
  // Only needed after the free settles of the day (5 per payTo on NEAR):
  createAuthHeaders: async () => ({
    settle: process.env.DOCTOR_CREDIT_KEY ? { "x-credit-key": process.env.DOCTOR_CREDIT_KEY } : {},
  }),
});

const resourceServer = new x402ResourceServer(facilitator)
  .register("near:mainnet", new ExactNearScheme());

const app = express();
app.use(paymentMiddleware({
  "GET /weather": {
    accepts: [{ scheme: "exact", price: "$0.01", network: "near:mainnet", payTo: "yourname.near" }],
    description: "Today's weather for a city",
  },
}, resourceServer));

app.get("/weather", (req, res) => res.json({ city: "Amsterdam", temp_c: 8 }));
app.listen(4021);

Already selling on Base or Solana? Add NEAR as one more entry in accepts. Agents pick the network they can pay on:

accepts: [
  { scheme: "exact", price: "$0.01", network: "eip155:8453", payTo: "0xYourBaseAddress" },
  { scheme: "exact", price: "$0.01", network: "near:mainnet", payTo: "yourname.near" },
],

(Register the EVM or Solana scheme too, and use a facilitator that supports each network you list.)

3. What your 402 now offers

A request without payment gets this option in the PAYMENT-REQUIRED header (base64 JSON):

{
  "scheme": "exact",
  "network": "near:mainnet",
  "amount": "10000",
  "asset": "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1",
  "payTo": "yourname.near",
  "maxTimeoutSeconds": 300,
  "extra": {}
}

4. Register your payout account on USDC, once

On NEAR a token account has to be registered before it can receive tokens (NEP-145 storage_deposit, about 0.00125 NEAR, once). Without it every payment fails. With near-cli-rs:

near contract call-function as-transaction 17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1 \
  storage_deposit json-args '{"account_id":"yourname.near","registration_only":true}' \
  prepaid-gas '30 Tgas' attached-deposit '0.00125 NEAR' \
  sign-as yourname.near network-config mainnet sign-with-keychain send

An implicit account (a 64-character hex id) doesn't need to be created first, but still needs the registration.

5. Check it before an agent pays

Paste your route into x402 Doctor's free web check. For NEAR it checks the network and asset, the amount in 6 decimals, and that your payout account exists and is registered on the token (near-payout-registered), with the command above as the fix when it isn't.

Choosing a facilitator

Any facilitator that lists near:mainnet in its /supported works with the code above; just change the URL. Several teams run one. x402 Doctor's facilitator, used in the example:

WhatTerms
VerifyFree (60 a minute per IP)
Settle on NEARFirst 5 a day per payTo free, then 2 credits ($0.002) each from a prepaid key (x-credit-key)
GasPaid by its relayer; buyer and seller need no NEAR
ScreeningPayer and payTo against the OFAC SDN list before every settle
ReplaysEach signed payment settles once

Details and the Solana side: x402-doctor.fizzl.eu/facilitator.

For buyers: checking a NEAR payment before signing

An agent that signs NEAR transactions or NEAR Intents messages can send them to presign-guard first (type: "near"). It answers green, orange or red. It says red for a full-access key added, an account deleted, code deployed over the wallet, a fake USDC contract or a look-alike receiver.

Common questions

Can I accept x402 payments in USDC on NEAR?
Yes. The x402 exact scheme has a NEAR mechanism, @x402/near. The buyer signs a NEP-366 delegate for one ft_transfer of USDC to your payTo, and a facilitator's relayer submits it and pays the gas, so neither buyer nor seller needs NEAR for gas.

Which facilitator settles USDC on NEAR?
Any facilitator that lists near:mainnet in its /supported. x402 Doctor's facilitator (https://x402-doctor.fizzl.eu/facilitator) is one: verify is free, the first 5 settles a day per payTo are free, then $0.002 each, and every payer and payTo is screened against the OFAC SDN list first.

Why does a NEAR x402 payment fail with a storage error?
Your payTo must be registered on the USDC token contract (NEP-145 storage_deposit, about 0.00125 NEAR, once). Without it the ft_transfer can't credit your account, and a careful facilitator refuses the settle before sending anything.

More research and guides: the full list, newest first →