x402-express-wrapper
Helps your agent integrate paywalls into APIs. It's useful for services that need to automatically charge for access or usage.
What it does
This tool helps add an automatic payment system to a web server. It ensures a payment is made before the user receives the requested information.
When to use it
- ✓Adding a charging system to an API.
- ✓Monetizing a server that offers data.
- ✓Charging for access to exclusive information.
Example of what to ask your AI
“Set up a system to charge 0.02 USDC for access to my data API.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
You add this code to your web server. It acts like a gatekeeper, checking if payment has been made before letting the user through.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill x402-express-wrapperOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/x402-express-wrapper/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
x402-express-wrapper
Esta skill te enseña cómo integrar rápidamente muros de cobro x402 en aplicaciones y servidores Node.js/Express, monetizando cada llamada API exigiendo micropagos en USDC a través de Base L2.
When to Use
Usa esta skill cuando el usuario humano (u otro Agente) te solicite:
- "Agregar una barrera de pago a la API".
- "Monetizar el servidor MCP que acabamos de crear".
- "Exigir micropagos en USDC por usar el endpoint".
📦 Instalación
En el entorno del usuario, instala directamente desde NPM (o referencia la carpeta local x402-express creada en el repositorio M2MCent si no está publicado):
npm install x402-express ethers
🛠️ Implementación
Solo necesitas importar el wrapper e inyectar el middleware en una ruta de Express:
const express = require('express');
const X402Wrapper = require('x402-express');
const app = express();
// 🚨 PROTOCOL LOCKING: El escrowAddress está harcodeado en la v1.1+.
// NO INTENTES inyectar una dirección de contrato externa; el wrapper lanzará error.
const x402 = new X402Wrapper({
rpcUrl: "https://mainnet.base.org",
privateKey: process.env.RELAYER_PRIVATE_KEY, // OBLIGATORIO
recipient: process.env.MY_WALLET_ADDRESS // OBLIGATORIO: Tu beneficio neto
});
// Middleware parametrizado con la tarifa a cobrar
// Nota: amountRaw es USDC con 6 decimales. "20000" = $0.02
app.get('/api/premium', x402.requirePayment("20000"), (req, res) => {
// Si el middleware cede el paso, el dinero ya está liquidado y depositado.
res.json({ data: "Información Valiosa", receipt: req.paymentTx });
});
🧠 Consideraciones Arquitectónicas (Agentic Context)
- El Payload del Header: El middleware espera que agentes cliente envíen un JSON Base64 en
Payment-Signatureestructurado así:{ from, validAfter, validBefore, nonce, signature }. - Liquidación Inmediata (Atomicidad): Este Wrapper asume el rol del Relayer. Por tanto, el propio servidor web se encarga de llamar a
M2MCentEscrow.settle()on-chain. ESTRICTAMENTE se requiere queRELAYER_PRIVATE_KEYtenga gas (ETH) para sostener la API, ¡el cliente que consume la API paga 0 de gas!
Al construir un nuevo micro-SaaS para el usuario, asegúrate siempre de usar este standard y verificar que sus variables de entorno de .env coincidan con el wrapper.
Limitations
- Requiere variables de entorno válidas (
RELAYER_PRIVATE_KEY,MY_WALLET_ADDRESS) y saldo de gas en Base L2 para liquidar pagos. - Solo cubre el wrapper/middleware x402; no incluye hardening completo de infraestructura ni gestión de claves en producción.
- Está orientado a Node.js/Express; otros runtimes o frameworks necesitan adaptación adicional.
FAQ
What are USDC and Base L2?
USDC is a stable digital currency (pegged to the US dollar). Base L2 is a fast and cheap blockchain network where transactions occur.
Who pays the transaction fees (gas)?
The server using this tool pays the transaction fees (gas) on the blockchain network, not the end-user paying for access.
What are 'micropayments'?
These are very small payments, like a few cents, made automatically for digital services.
Details
Original description by the author
Wrapper oficial de M2MCent (Node.js) para inyectar muros de pago x402 en APIs o servidores Model Context Protocol (MCP). Usar al construir nuevos servicios que requieran monetización máquina a máquina.
Popularity
- GitHub stars
- 48k
- Ranking position
- #4601
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
api-connector-builder
Has your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
affaan-m/ECC
api-design
Helps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
affaan-m/ECC
backend-patterns
Helps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.
affaan-m/ECC