{
  "markdown": "# 🛰️ M2MCent SDK — x402 Payment Wrapper for AI Agents\n\n[![npm version](https://img.shields.io/npm/v/m2mcent-sdk.svg)](https://www.npmjs.com/package/m2mcent-sdk)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Base Mainnet](https://img.shields.io/badge/Network-Base%20L2-0052FF.svg)](https://base.org)\n\n> Ultra-lightweight x402 payment interceptor for AI Agents and MCP Servers. Monetize any API in 3 lines of code.\n\n## 🚀 Quick Start\n\n```bash\nnpm install m2mcent-sdk\n```\n\n```typescript\nimport { X402Handler } from 'm2mcent-sdk';\n\nconst x402 = new X402Handler({\n  rpcUrl: 'https://mainnet.base.org',\n  privateKey: process.env.RELAYER_PRIVATE_KEY!,\n  recipient: process.env.TREASURY_ADDRESS!\n});\n\n// Protect any Express endpoint with a USDC paywall\napp.post('/api/analyze', x402.requirePayment(\"100000\"), (req, res) => {\n  res.json({ result: \"Premium analysis complete\", receipt: req.paymentTx });\n});\n```\n\n## 📐 How It Works\n\nM2MCent implements the **x402 Payment Protocol** — a machine-native payment standard inspired by HTTP 402:\n\n1. **Agent requests** a protected endpoint\n2. **Server responds** with `402 Payment Required` + payment metadata (Base64 encoded)\n3. **Agent signs** an EIP-712 typed data authorization (gasless for the payer)\n4. **Server settles** atomically on-chain via the M2MCent Escrow contract\n5. **Agent receives** the premium response + transaction receipt\n\n```\nAgent ──► API Server ──► 402 + metadata\nAgent ◄── signs EIP-712 authorization\nAgent ──► API Server + Payment-Signature header\n          └──► Escrow.settle() on Base L2\nAgent ◄── Premium Response + tx hash\n```\n\n## ⚙️ Configuration\n\n| Parameter | Description | Required |\n|:---|:---|:---|\n| `rpcUrl` | Base Mainnet RPC endpoint | ✅ |\n| `privateKey` | Relayer wallet private key (for settlement) | ✅ |\n| `recipient` | Treasury address to receive payments | ✅ |\n\n## 🔒 Security\n\n- **Non-custodial**: Funds flow directly from payer → treasury via on-chain escrow\n- **Gasless for payers**: Uses EIP-3009 `transferWithAuthorization` (USDC native)\n- **Zero-Leak**: No agent data is retained after settlement\n- **Atomic**: Payment and service delivery happen in a single request cycle\n\n## 🌐 Network Details\n\n| Parameter | Value |\n|:---|:---|\n| **Network** | Base Mainnet (Chain ID: 8453) |\n| **USDC Contract** | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |\n| **Escrow Contract** | `0xf3c3416A843d13C944554A54Ac274BB7fF264BcC` |\n| **Settlement** | Atomic, sub-second finality |\n\n## 🧩 MCP Server Integration\n\nPerfect for [Model Context Protocol](https://modelcontextprotocol.io) servers:\n\n```typescript\nimport express from 'express';\nimport { X402Handler } from 'm2mcent-sdk';\n\nconst app = express();\nconst x402 = new X402Handler({\n  rpcUrl: process.env.BASE_RPC_URL!,\n  privateKey: process.env.RELAYER_PRIVATE_KEY!,\n  recipient: process.env.TREASURY_ADDRESS!\n});\n\n// Any MCP tool endpoint becomes monetizable\napp.post('/api/tools/analyze', x402.requirePayment(\"50000\"), async (req, res) => {\n  const result = await runMCPTool(req.body);\n  res.json({ ...result, paymentTx: req.paymentTx });\n});\n```\n\n## 📊 Ecosystem\n\nM2MCent powers **100+ production MCP servers** on Base Mainnet, processing real USDC micro-payments for AI-to-AI commerce.\n\n## 📄 License\n\nMIT © [M2MCent](https://github.com/Evozim/m2mcent-sdk)\n",
  "bytes": 3354,
  "sha": "cdd8e51ad49989793c0d2304b4904c64f777d17d24c4b9c5ea50eec6a5a9805a",
  "repo_slug": "evozim/m2mcent-sdk",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_evozim_m2mcent_348d8459/readme"
}