Skip to content

About

Standing orders for agents — mandate documents plus a client-side scheduler that pays per run and collects run reports

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

0 watching

Forks

x402-recurring

License x402 USDC on Base + Solana

standing orders for agents — Signed mandate documents plus a client-side scheduler that pays per run over x402 and collects signed run reports. No subscriptions, no stored cards, no server-side pulls.

Why x402 for this

Recurring billing normally means handing a merchant pull-access to your money (cards, direct debit) and hoping cancellation works. With x402 the recurrence inverts: the payer's scheduler initiates every run with a per-request USDC micropayment, so the budget cap is enforced by not paying again. Each run returns its signed report in the same response — pay, get artifact, done.

Pay in USDC on Base or Solana — your client picks the rail

Every paid route answers an unpaid request with a 402 whose accepts array carries both rails:

Rail Networks Asset payTo
EVM base-sepolia (default) · base USDC 0x40252CFDF8B20Ed757D61ff157719F33Ec332402
Solana solana-devnet (default) · solana USDC WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW

Each rail settles through its own facilitator — they are not interchangeable:

Rail Facilitator Env
EVM https://x402.org/facilitator FACILITATOR_URL
Solana https://facilitator.payai.network SOLANA_FACILITATOR_URL

The x402.org reference facilitator settles Base but not Solana, so the Solana rail defaults to PayAI's. On Solana, extra.feePayer is that facilitator's sponsor account — discovered from its /supported endpoint at boot — so a payer needs only USDC, never SOL for gas.

Quickstart

git clone https://github.com/nirholas/x402-recurring && cd x402-recurring
npm install
cp .env.example .env       # optional — every value has a working default
npm run dev

# in another terminal, the full paid flow on the EVM rail:
PRIVATE_KEY=0xYourFundedBaseSepoliaKey npm run client
# recurring paid runs on the mandate's cadence:
PRIVATE_KEY=0xYourFundedBaseSepoliaKey npm run scheduler

API

Route Price What you get back
POST /mandates free Signed mandate document
POST /execute/:mandateId $0.005 (per mandate — its own pricePerRun) Signed run report: run number, budget state, and the task artifact
GET /mandates/:id free Mandate status snapshot
GET /mandates free Mandate summaries
POST /verify free `{ valid: true
GET /health free { ok: true }
GET /.well-known/x402 free Machine-readable discovery manifest

Built-in self-contained tasks: heartbeat (liveness snapshot), counter (progress across runs), digest (sha256 + stats of a posted payload).

How x402 works here

  1. Call a paid route with no payment → 402 with accepts[] quoting the exact price on both rails.
  2. Your client picks a rail and signs: EIP-3009 transferWithAuthorization (EVM) or a serialized SPL transfer (Solana).
  3. Retry with the X-PAYMENT header. The facilitator for that rail verifies and settles.
  4. The server returns the artifact in the 200 body, plus X-PAYMENT-RESPONSE carrying { rail, network, transaction, payer }.

Mainnet: NETWORK=base, SOLANA_NETWORK=mainnet-beta, and mainnet-capable FACILITATOR_URL / SOLANA_FACILITATOR_URL.

Real backend / API keys

Fully self-contained — no external APIs and no API keys. State is file-based (data/mandates.json) and the built-in tasks compute their results locally. Artifacts are signed with HMAC-SHA256 using SIGNING_SECRET; the dev default (dev-secret-change-me) is public, so set your own in production.

For AI agents

  • skill.md: skill.md — agent-facing endpoints, prices, schemas, error codes.
  • Discovery manifest: /.well-known/x402, served live by the app, listing both networks per resource — indexable by x402scan.com, the x402 Bazaar, and agentic.market. List your deployment there so paying agents can find it.
  • MCP: examples/mcp-tool.md — wrap these routes as MCP tools for Claude.
  • Raw flow: examples/curl.md — the 402 → pay → 200 walkthrough by hand.

Docs

Full docs on GitHub Pages: https://nirholas.github.io/x402-recurring/ — tutorial · API reference · for agents

Part of the x402 Suite.

Support

nichxbt@gmail.com

License

Apache-2.0

Star History

Star History Chart

Support the project

If x402-recurring saves you time, star it on GitHub. Stars are how other developers and AI agents find the repositories worth trusting, and they cost you one click.

Know someone who would use it? Post on X · Share on Bluesky · Share on LinkedIn · Submit to Hacker News · Share on Reddit

Built for AI agents too

Coding agents and LLM tooling can read this repo directly: AGENTS.md, llms.txt, llms-full.txt. Point an agent at https://github.com/nirholas/x402-recurring and it has the context it needs.

More from the same author

Contributors

Contributors

About

Standing orders for agents — mandate documents plus a client-side scheduler that pays per run and collects run reports

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages