Genesis402 is a no-code monetization layer that wraps existing APIs with pay-per-request enforcement using x402 on Stellar.
backend/: Express + TypeScript API for agent management and paid gateway routingfrontend/: Next.js UI for creating and testing paid agentsrandom-number/: Sample external API + x402 client workflow script
- Create an agent that points to an external API
- Call its generated paid endpoint (
/agent/:id) - If no payment is attached, backend returns HTTP
402+ payment requirements - Client signs payment and retries with
X-PAYMENT - Backend verifies + settles via facilitator, then proxies to the external API
Client -> /agent/:id -> x402 middleware -> external API -> response
(402 if payment missing/invalid)
- Node.js 18+
- npm
- MongoDB (local or remote)
- A Stellar wallet for signing payments (for client-side payment flows)
From repo root:
npm run install:allFrom repo root:
npm run setupThis creates:
backend/.envfrontend/.env.local
Then update values as needed (especially MongoDB/facilitator credentials).
npm run dev:backend
# http://localhost:3001npm run dev:frontend
# http://localhost:3000You can also go within /backend and /frontend folders, create and fill .env, and use npm install and run commands to work with the folders:
npm install
npm run dev- Client calls
/agent/:idwithoutX-PAYMENT - Server returns HTTP
402andX-402-VERSION: 2 - Response body includes
x402Version: 2andaccepts[0]payment requirements - Client signs and sends
X-PAYMENT: <base64 payload> - Backend verifies via facilitator
/verify - Backend settles via facilitator
/settle - Backend proxies request and returns result (
X-PAYMENT-RESPONSE: payment-received)
The random-number/ folder includes:
- a sample API server (
server.js) - a workflow client that performs x402 payment retries (
x402-client.js)
Setup:
cd random-number
npm install
npm run install:alldoes not download dependencies in random-number folder, so you need to donpm install
Run random number generator server:
node server.jsTo run agentic workflow script:
- Edit the api url (and any other input necessary)
- Run:
node x402-client.jsEdit WORKFLOW in random-number/x402-client.js to point at your generated agent endpoint(s).
