Menu

Explorer & Settings

Tempo Explorer Submit Project
Back to all projects

nero-x402

by nerochain · Updated 19 days ago

The first AA-native x402 payment stack on NERO Chain — facilitator, SDK, audited settlement contract, and a public playground showing AI agents paying APIs in USDC with paymaster-sponsored gas.

In the AI payments ecosystem

nero-x402 is a growing TypeScript project in the AI payments / x402 ecosystem, focused on account-abstrac, x402. It currently has 48 GitHub stars and 0 forks, and sits alongside related tools like nofx, ClawRouter, bitterbot-desktop, internet-court-skill, Franklin, daydreams.

README.md View on GitHub →

NERO 402

en pt-br es ja

The first AA-native x402 payment stack on NERO Chain — facilitator, SDK, audited settlement contract, and a public playground showing AI agents paying APIs in USDC with paymaster-sponsored gas.

The aa-native scheme

Upstream x402's default exact scheme settles via EIP-3009 transferWithAuthorization — which only EOAs can sign. Smart contract wallets can't use it (there's no private key the token contract can ecrecover). On NERO Chain every wallet is an SCW, so exact is effectively unusable. NERO 402 contributes a second scheme — aa-native — that closes that gap.

How it works

  1. Merchant API returns HTTP 402 with PAYMENT-REQUIRED, advertising scheme: "aa-native", payTo, amount, asset, network.
  2. The agent's SCW signs an ERC-4337 UserOperation whose callData decodes to:
    SettlementContract.settle(merchant, token, amount, requestHash)
    
  3. The agent retries with PAYMENT-SIGNATURE carrying the signed UserOp.
  4. The merchant forwards to a NERO 402 facilitator's /verify + /settle endpoints.
  5. The facilitator submits the UserOp via the NERO bundler. The NERO Paymaster sponsors gas (type: 0) — the agent spends zero NERO native.
  6. SettlementContract.settle() runs IERC20.transferFrom(SCW → merchant), records isSettled[settlementKey] = true (key bound to (payer, merchant, token, amount, requestHash)), emits ReceiptLog.
  7. The merchant returns 200 with PAYMENT-RESPONSE carrying the on-chain transactionHash.

The agent never holds the chain's native token. The merchant never sees the SCW's private key. Replay protection is on-chain; gas is paymaster-sponsored. Full wire format and validation rules: docs/whitepaper/whitepaper.pdf.

aa-native vs exact

exact (upstream) aa-native (NERO 402)
Wallet EOA only ERC-4337 smart contract wallet
Settlement EIP-3009 transferWithAuthorization on the token SettlementContract.settle(...) calls IERC20.transferFrom
Token requirements Must implement EIP-3009 (USDC.e, USDC.arb on NERO) Any ERC-20 the merchant accepts
Gas Agent's EOA pays in native NERO Paymaster sponsors; agent pays zero
Replay protection EIP-3009 nonce on the token contract SettlementContract.isSettled[settlementKey]

Both schemes are advertised by NERO 402's facilitator (GET /supported); merchants pick which to accept. An unmodified upstream @x402/fetch client can pay an NERO 402 merchant via exact (USDC.e or USDC.arb on mainnet) without forking.

Repository layout

Path What it is
contracts/ SettlementContract.sol (UUPS upgradeable) + Foundry tests.
apps/facilitator/ x402 V2 facilitator service (/verify, /settle, /supported).
apps/playground/ Public showcase site at x402.nerochain.io.
apps/docs/ Documentation site (Fumadocs) at docs.x402.nerochain.io.
packages/x402-types/ Wire-format types and Zod schemas for x402 V2.
packages/x402-server/ Express / Hono / Fastify / Next middleware.
packages/x402-client/ fetch + axios HTTP wrappers for paying agents.
packages/x402-aa/ ERC-4337 paymaster-sponsored signer.
packages/x402-extensions/ Access tokens + payment-identifier extensions.
examples/learn-nero/ "An agent pays NERO to learn NERO" — end-to-end demo.
examples/express-paid-api/ Minimal merchant + agent example.
examples/agent-cost-test/ Cost benchmarking script.
docs/whitepaper/ NERO 402 spec — Markdown + PDF.

Deployed contracts

Network SettlementContract proxy EntryPoint (NERO)
Mainnet (chainId 1689) 0x5eCfc64f2339992668f555918674B604F97B412D 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789
Testnet (chainId 689) 0x925dbba44570683ac8da99be08bc5ece8cf5a8c6 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789

Quickstart

git clone --recursive <this-repo>
cd nero-x402
pnpm install
pnpm -r test           # JS test suites
cd contracts && forge test    # Foundry test suite

Run the playground locally:

cd apps/playground
cp .env.example .env   # edit with your testnet config
pnpm dev

Run the facilitator locally:

cd apps/facilitator
cp .env.example .env   # edit with your NERO Paymaster API key
pnpm dev

The canonical end-to-end demo:

cd examples/learn-nero
cp .env.example .env   # set NERO_PRIVATE_KEY and NERO_PAYMASTER_API_KEY
pnpm start

Documentation

License

MIT.

All TypeScript projects →