Skip to main content
This flow is the other side of the market: instead of paying, your agent gets paid. Point a coding agent (Claude Code, Cursor, an OpenAI agent) at your existing service and the Nevermined SDK, and it wires an x402 paywall in front of the endpoints you choose — so every call costs credits.

Useful for

  • Monetizing an existing Express, FastAPI, MCP, or A2A agent without building billing yourself.
  • Charging per request (fixed or dynamic credits) with metering and settlement handled for you.
  • Generating the registration script + middleware + a test in one pass, so you go from unpaid to paid in minutes.

Try it yourself

Run this in your project with a coding agent that can read and edit your files:
Swap the framework line for your stack — guides exist for Express, FastAPI, Strands, and generic HTTP.

How it works

1

Register an agent and a plan

Publish the service and price it. The SDK helpers build the on-chain price/credits config for you:
See Register a plan & agent for the full options (fiat pricing, time-based and pay-as-you-go plans).
2

Gate your routes with middleware

Add the payment middleware and list the routes to protect with their credit cost. Everything not listed stays public:
The middleware returns 402 with a payment-required challenge when the token is missing, verifies it when present, runs your handler, then settles (burns credits) and returns the receipt in payment-response.
3

Test the paywall

Call without a token (expect 402), then with a fresh token (expect 200):

Register a plan & agent

Publish and price the service you’re protecting.

Nevermined x402

The protocol behind the paywall: schemes, headers, verify/settle.

Check revenue

Once you’re charging, track what you earn.

Buy access

See the buyer side that mints the token your paywall checks.