Getting started
Installation
Install the @nerochain/x402-* packages.
The NERO 402 SDK is published as five packages under the @nerochain/ scope. Each package is independently installable; you only pull in what you use.
Choose the packages you need
| Package | When to install it |
|---|---|
@nerochain/x402-types | Always (transitively included by the others; install directly only if you build your own client/server adapter). |
@nerochain/x402-server | You are a merchant gating an HTTP endpoint behind payment. |
@nerochain/x402-client | You are an agent making paid calls. |
@nerochain/x402-aa | You sign payments from an ERC-4337 smart contract wallet (the aa-native scheme). |
@nerochain/x402-extensions | You want client-side idempotency or signed access tokens for cached access after a paid call. |
Agent-side install
pnpm add @nerochain/x402-client @nerochain/x402-aa ethersMerchant-side install (Express)
pnpm add @nerochain/x402-serverAdapters for Hono, Fastify, and Next.js App Router are subpath imports of the same package — no separate install.
Requirements
- Node 20+ for the runtime.
- TypeScript 5+ if you are using TypeScript directly. The packages ship
.d.tstypes. ethersv6 for the agent side (the SDK accepts anethers.Walletorethers.HDNodeWallet).
Verifying the install
After installing, type-check that the packages resolve:
node -e "console.log(require('@nerochain/x402-client').x402Fetch.toString().slice(0, 60))"You should see the start of the x402Fetch factory function. From there, head to the agent quickstart or the merchant quickstart.