@celorodrigues/x402-conformance 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @celorodrigues/x402-conformance
2
2
 
3
- [![x402-conformance](https://api.automaton-sovereign.workers.dev/v2/badge/default.svg)](https://api.automaton-sovereign.workers.dev/leaderboard)
3
+ [![x402-conformance](https://automaton-api.bfzovw.easypanel.host/v2/badge/default.svg)](https://automaton-api.bfzovw.easypanel.host/leaderboard)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
6
  > **Autonomous Linter and Conformance Suite for Official x402 Micropayments & EIP-3009**
@@ -47,9 +47,34 @@ The same package runs as an MCP stdio server:
47
47
  - Claude Desktop: Settings → Developer → Edit Config (`claude_desktop_config.json`), then restart.
48
48
  - Cursor: `.cursor/mcp.json` in the project, or `~/.cursor/mcp.json`.
49
49
 
50
- Tools: `x402_conformance_check` (free, runs locally), `simulate_base_transaction` (free, EVM dry-run via Base RPC with revert reason decoding), `security_scan` (Base token honeypot / mint-trap / contract risk), `oracle_base`, `sentiment_analysis`, `attest`, `merkle_prove`, plus free `verify_attestation`, `read_ledger`, `merkle_verify`, `pricing`, `health`. Paid tools cost 0.001 - 0.05 USDC on Base (3 free calls/day/IP).
51
-
52
- Optional env: `VALUE_API_BASE` (default `https://api.automaton-sovereign.workers.dev`), `VALUE_API_PAYMENT` (payment tx hash attached to paid calls).
50
+ ### Available MCP Tools (15 Tools)
51
+
52
+ #### 🆓 Free Diagnostics & Local Execution (No payment required)
53
+ | Tool | Description |
54
+ |---|---|
55
+ | `simulate_base_transaction` | EVM transaction dry-run with exact gas estimation and revert reason decoding on Base L2. |
56
+ | `x402_conformance_check` | Full 12-point conformance audit of any HTTP 402 API endpoint against the official spec. |
57
+ | `health` | Real-time service diagnostics, node health, and payment recipient address. |
58
+ | `pricing` | Live pricing directory across all hosted x402 services and settlement rails. |
59
+ | `read_ledger` | Query the immutable, signed ledger of attested operations. |
60
+ | `verify_attestation` | Verify cryptographic signatures and proofs offline or online. |
61
+ | `attestation_pubkey` | Retrieve the agent's public key for independent trustless verification. |
62
+ | `merkle_verify` | Validate cryptographic Merkle tree inclusion proofs. |
63
+
64
+ #### ⚡ Hosted Intelligence & Consensus (x402 Micro-payments on Base — 3 Free Trials/Day/IP)
65
+ | Tool | Price | Description |
66
+ |---|---|---|
67
+ | `oracle_base` | 0.001 USDC | Multi-RPC consensus oracle on Base (block, gas, clock, balance). |
68
+ | `security_scan` | 0.002 USDC | EVM bytecode scanner, honeypot detection, fee-traps & contract risk analysis. |
69
+ | `sentiment_analysis` | 0.001 USDC | Fast agentic financial sentiment scoring for market data. |
70
+ | `attest` | 0.05 USDC | Generate on-chain attestations signed by Agent #95791. |
71
+ | `merkle_prove` | 0.05 USDC | Cryptographic Merkle batch proof generation. |
72
+ | `hash_sha256` | 0.0001 USDC | Fast deterministic SHA-256 computation. |
73
+ | `uuid` | 0.0001 USDC | Cryptographically secure UUID generation. |
74
+
75
+ Optional environment variables:
76
+ - `VALUE_API_BASE`: Default `https://automaton-api.bfzovw.easypanel.host` (or edge mirror `https://api.automaton-sovereign.workers.dev`).
77
+ - `VALUE_API_PAYMENT`: Optional Base USDC transaction hash or EIP-3009 authorization payload.
53
78
 
54
79
  ---
55
80
 
@@ -77,13 +102,13 @@ Optional env: `VALUE_API_BASE` (default `https://api.automaton-sovereign.workers
77
102
  Services that achieve a **CONFORMANT** verdict (Grade A or A+) can request an on-chain signed attestation and permanent verification badge:
78
103
 
79
104
  ```bash
80
- curl -X POST https://api.automaton-sovereign.workers.dev/v2/conformance/certify \
105
+ curl -X POST https://automaton-api.bfzovw.easypanel.host/v2/conformance/certify \
81
106
  -H "Content-Type: application/json" \
82
107
  -H "X-PAYMENT: <txHash-or-EIP3009>" \
83
108
  -d '{"url":"https://your-service.com/v1/paid"}'
84
109
  ```
85
110
 
86
- * Certified services appear on the public [x402 Leaderboard](https://api.automaton-sovereign.workers.dev/leaderboard).
111
+ * Certified services appear on the public [x402 Leaderboard](https://automaton-api.bfzovw.easypanel.host/leaderboard).
87
112
  * Fee: 0.05 USDC settled directly on Base L2 to `0x71DEAc098914A009E3720524642A6bE6F65EE528`.
88
113
 
89
114
  ---
package/mcp-server.js CHANGED
@@ -24,7 +24,7 @@ const PKG = require('./package.json');
24
24
  const linter = require('./index.js');
25
25
  const simulator = require('./tx-simulator.js');
26
26
 
27
- const BASE = (process.env.VALUE_API_BASE || 'https://api.automaton-sovereign.workers.dev').replace(/\/+$/, '');
27
+ const BASE = (process.env.VALUE_API_BASE || 'https://automaton-api.bfzovw.easypanel.host').replace(/\/+$/, '');
28
28
  const PAYMENT = process.env.VALUE_API_PAYMENT || '';
29
29
 
30
30
  function httpJson(method, urlStr, headers, body) {
@@ -52,9 +52,9 @@ const TOOLS = [
52
52
  inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'Full URL of the x402-protected endpoint to check.' } }, required: ['url'] } },
53
53
  { name: 'simulate_base_transaction', description: 'FREE, runs locally against Base Mainnet RPC. Dry-run a transaction before sending it: eth_call + eth_estimateGas at the latest block. Predicts whether it will revert and decodes the reason (Error(string), Panic(uint256) codes, custom-error selector, or node rejection such as insufficient funds). Returns { ok, willRevert, revertReason, estimatedGas, returnData }.',
54
54
  inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Target contract or recipient address on Base (0x...).' }, data: { type: 'string', description: 'Calldata as 0x-hex (default 0x for a plain ETH transfer).' }, value: { type: 'string', description: 'ETH value in wei, decimal or 0x-hex (default 0).' }, from: { type: 'string', description: 'Optional sender address; needed for balance/allowance-dependent calls.' } }, required: ['to'] } },
55
- { name: 'security_scan', description: 'PAID 0.001 USDC/call, or free trial (3/day/IP). Base token safety analysis: honeypot detection, mint traps, selfdestruct/delegatecall, proxy and tax risks from contract bytecode, with a risk score and signed verdict. On 402, pay the accepts[] terms then retry with the payment tx hash.',
55
+ { name: 'security_scan', description: 'PAID 0.002 USDC/call, or free trial (3/day/IP). Base token safety analysis: honeypot detection, mint traps, selfdestruct/delegatecall, proxy and tax risks from contract bytecode, with a risk score and signed verdict. On 402, pay the accepts[] terms then retry with the payment tx hash.',
56
56
  inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Token or contract address on Base (0x...).' }, payment: { type: 'string', description: 'Optional X-PAYMENT base tx hash of the USDC payment.' } }, required: ['address'] } },
57
- { name: 'attest', description: 'Create a SIGNED, hash-chained, append-only attestation (verifiable proof-of-existence) for a payload. PAID: 0.001 USDC/call, or free trial (3/day/IP). On 402, pay the accepts[] terms then retry with the payment tx hash.',
57
+ { name: 'attest', description: 'Create a SIGNED, hash-chained, append-only attestation (verifiable proof-of-existence) for a payload. PAID: 0.05 USDC/call, or free trial (3/day/IP). On 402, pay the accepts[] terms then retry with the payment tx hash.',
58
58
  inputSchema: { type: 'object', properties: { data: { type: 'string', description: 'Payload to attest (any string).' }, payment: { type: 'string', description: 'Optional X-PAYMENT base tx hash of the USDC payment.' } }, required: ['data'] } },
59
59
  { name: 'verify_attestation', description: 'FREE. Verify a ledger entry by index or by data hash: recomputes hash, checks ECDSA signature and chain link.',
60
60
  inputSchema: { type: 'object', properties: { index: { type: 'integer' }, dataHash: { type: 'string' } } } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celorodrigues/x402-conformance",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Zero-dependency CLI, MCP server and testing suite for x402 AI agent micropayment protocol & EIP-3009 compliance",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -38,7 +38,7 @@
38
38
  "type": "git",
39
39
  "url": "git+https://github.com/baianomarceloeduardo-jpg/automaton-x402.git"
40
40
  },
41
- "homepage": "https://api.automaton-sovereign.workers.dev/leaderboard",
41
+ "homepage": "https://automaton-api.bfzovw.easypanel.host/leaderboard",
42
42
  "bugs": {
43
43
  "url": "https://github.com/baianomarceloeduardo-jpg/automaton-x402/issues"
44
44
  },
package/smithery.yaml CHANGED
@@ -7,20 +7,20 @@ startCommand:
7
7
  properties:
8
8
  valueApiBase:
9
9
  type: string
10
- default: https://api.automaton-sovereign.workers.dev
10
+ default: https://automaton-api.bfzovw.easypanel.host
11
11
  description: Base URL of the Automaton-Sovereign Value API used by the paid/free API tools.
12
12
  valueApiPayment:
13
13
  type: string
14
- description: Optional x402 payment (Base USDC tx hash) attached as X-PAYMENT to paid tool calls.
14
+ description: Optional x402 payment (Base USDC tx hash or EIP-3009 authorization) attached to paid tool calls.
15
15
  commandFunction:
16
16
  |-
17
17
  (config) => ({
18
18
  command: 'npx',
19
- args: ['-y', '@celorodrigues/x402-conformance', '--mcp'],
19
+ args: ['-y', '@celorodrigues/x402-conformance@2.2.0', '--mcp'],
20
20
  env: Object.assign(
21
- { VALUE_API_BASE: config.valueApiBase || 'https://api.automaton-sovereign.workers.dev' },
21
+ { VALUE_API_BASE: config.valueApiBase || 'https://automaton-api.bfzovw.easypanel.host' },
22
22
  config.valueApiPayment ? { VALUE_API_PAYMENT: config.valueApiPayment } : {}
23
23
  )
24
24
  })
25
25
  exampleConfig:
26
- valueApiBase: https://api.automaton-sovereign.workers.dev
26
+ valueApiBase: https://automaton-api.bfzovw.easypanel.host
package/tx-simulator.js CHANGED
@@ -14,7 +14,10 @@ const https = require('https');
14
14
  const http = require('http');
15
15
  const { URL } = require('url');
16
16
 
17
- const DEFAULT_RPC = process.env.BASE_RPC_URL || 'https://mainnet.base.org';
17
+ const DEFAULT_RPC = process.env.SIM_RPC_URL || process.env.BASE_RPC_URL || 'https://mainnet.base.org';
18
+ const MAX_DATA_BYTES = 65536; // well above any real tx; bounds upstream work
19
+ const MAX_DATA_HEX = 2 + MAX_DATA_BYTES * 2;
20
+ const MAX_RPC_RESPONSE = 2 * 1024 * 1024; // cap memory per upstream response
18
21
  const BASE_CHAIN_ID = '0x2105'; // 8453
19
22
 
20
23
  const PANIC_CODES = {
@@ -37,7 +40,8 @@ function rpcCall(rpcUrl, method, params) {
37
40
  const payload = JSON.stringify({ jsonrpc: '2.0', id: 1, method, params });
38
41
  const req = lib.request({ hostname: u.hostname, port: u.port || (u.protocol === 'http:' ? 80 : 443), path: u.pathname + u.search, method: 'POST',
39
42
  headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload), 'User-Agent': 'automaton-simulator/1.0' } }, (res) => {
40
- let d = ''; res.on('data', (c) => d += c);
43
+ let d = '';
44
+ res.on('data', (c) => { d += c; if (d.length > MAX_RPC_RESPONSE) req.destroy(new Error('rpc_response_too_large')); });
41
45
  res.on('end', () => {
42
46
  let j; try { j = JSON.parse(d); } catch (e) { return reject(new Error('bad_rpc_response (HTTP ' + res.statusCode + ')')); }
43
47
  resolve(j); // caller inspects j.result / j.error (a revert arrives as j.error)
@@ -94,17 +98,64 @@ function revertDataOf(err) {
94
98
  return null;
95
99
  }
96
100
 
101
+ // JSON-RPC error -> 'revert' (execution reverted), 'rejected' (node refuses the tx itself:
102
+ // funds, gas, nonce) or 'transient' (rate limit, capacity, internal: says nothing about the tx).
103
+ function classify(err) {
104
+ if (!err) return null;
105
+ if (revertDataOf(err)) return 'revert';
106
+ const msg = String(err.message || '');
107
+ if (err.code === 3 || /revert/i.test(msg)) return 'revert';
108
+ if (/insufficient funds|OutOfFunds|gas required exceeds|intrinsic gas|gas too low|exceeds block gas limit|nonce|invalid opcode|out of gas|stack (over|under)flow|InvalidFEOpcode|OpcodeNotFound/i.test(msg)) return 'rejected';
109
+ return 'transient';
110
+ }
111
+
112
+ // Returns an error string for unusable input, or null. Pure and cheap: callers run it before
113
+ // charging a payment or spending an RPC call.
114
+ function validate(input) {
115
+ input = input || {};
116
+ if (!isAddr(input.to)) return 'to must be a 0x-prefixed 20-byte address';
117
+ if (input.from !== undefined && input.from !== null && input.from !== '' && !isAddr(input.from)) return 'from must be a 0x-prefixed 20-byte address';
118
+ const data = input.data === undefined || input.data === null || input.data === '' ? '0x' : input.data;
119
+ if (typeof data !== 'string') return 'data must be a 0x-hex string';
120
+ if (data.length > MAX_DATA_HEX) return 'calldata too large (max ' + MAX_DATA_BYTES + ' bytes)';
121
+ if (!/^0x([0-9a-fA-F]{2})*$/.test(data)) return 'data must be 0x-prefixed even-length hex';
122
+ try { toQuantity(input.value); } catch (e) { return e.message; }
123
+ return null;
124
+ }
125
+
126
+ // Process-wide limiter: the free MCP tool must not turn this host into an open Base RPC proxy
127
+ // (each simulation costs 4 upstream calls, and the same public RPC verifies our payments).
128
+ const RATE_PER_MIN = parseInt(process.env.SIM_RATE_PER_MIN || '120', 10);
129
+ const MAX_CONCURRENT = parseInt(process.env.SIM_MAX_CONCURRENT || '8', 10);
130
+ let tokens = RATE_PER_MIN, refillAt = Date.now(), inFlight = 0;
131
+ function acquire() {
132
+ const now = Date.now();
133
+ tokens = Math.min(RATE_PER_MIN, tokens + ((now - refillAt) / 60000) * RATE_PER_MIN);
134
+ refillAt = now;
135
+ if (inFlight >= MAX_CONCURRENT) return 'rate_limited: too many concurrent simulations, retry shortly';
136
+ if (tokens < 1) return 'rate_limited: simulation quota exceeded (' + RATE_PER_MIN + '/min), retry shortly';
137
+ tokens -= 1; inFlight++;
138
+ return null;
139
+ }
140
+
97
141
  async function simulate(input, opts) {
98
142
  input = input || {};
99
143
  opts = opts || {};
100
- const rpcUrl = opts.rpcUrl || DEFAULT_RPC;
101
144
  const out = { ok: false, network: 'base', chainId: 8453, willRevert: null, revertReason: null, estimatedGas: null, returnData: null };
145
+ const invalid = validate(input);
146
+ if (invalid) { out.error = invalid; return out; }
147
+ // Paid HTTP calls (already metered by x402) skip the free-tier limiter but not the concurrency cap.
148
+ if (!opts.bypassLimit) {
149
+ const limited = acquire();
150
+ if (limited) { out.error = limited; out.rateLimited = true; return out; }
151
+ } else inFlight++;
152
+ try { return await run(input, opts, out); } finally { inFlight--; }
153
+ }
102
154
 
103
- if (!isAddr(input.to)) { out.error = 'to must be a 0x-prefixed 20-byte address'; return out; }
104
- if (input.from !== undefined && input.from !== null && input.from !== '' && !isAddr(input.from)) { out.error = 'from must be a 0x-prefixed 20-byte address'; return out; }
105
- const data = input.data === undefined || input.data === null || input.data === '' ? '0x' : String(input.data);
106
- if (!/^0x([0-9a-fA-F]{2})*$/.test(data)) { out.error = 'data must be 0x-prefixed even-length hex'; return out; }
107
- let value; try { value = toQuantity(input.value); } catch (e) { out.error = e.message; return out; }
155
+ async function run(input, opts, out) {
156
+ const rpcUrl = opts.rpcUrl || DEFAULT_RPC;
157
+ const data = input.data === undefined || input.data === null || input.data === '' ? '0x' : input.data;
158
+ const value = toQuantity(input.value);
108
159
 
109
160
  const tx = { to: input.to, data, value };
110
161
  if (input.from) tx.from = input.from;
@@ -120,9 +171,18 @@ async function simulate(input, opts) {
120
171
  out.tx = tx;
121
172
 
122
173
  let call, gas;
123
- try {
124
- [call, gas] = await Promise.all([rpcCall(rpcUrl, 'eth_call', [tx, block]), rpcCall(rpcUrl, 'eth_estimateGas', [tx, block])]);
125
- } catch (e) { out.error = 'rpc_unreachable: ' + e.message; return out; }
174
+ for (let attempt = 0; attempt < 2; attempt++) {
175
+ try {
176
+ [call, gas] = await Promise.all([rpcCall(rpcUrl, 'eth_call', [tx, block]), rpcCall(rpcUrl, 'eth_estimateGas', [tx, block])]);
177
+ } catch (e) { out.error = 'rpc_unreachable: ' + e.message; return out; }
178
+ // Rate limits / capacity errors are not reverts: retry once, then report ok:false.
179
+ if (classify(call.error) !== 'transient' && classify(gas.error) !== 'transient') break;
180
+ if (attempt === 0) await new Promise((r) => setTimeout(r, 400));
181
+ }
182
+ if (classify(call.error) === 'transient') {
183
+ out.error = 'rpc_error: ' + String(call.error.message || call.error.code || 'unknown').slice(0, 200);
184
+ return out;
185
+ }
126
186
 
127
187
  out.ok = true;
128
188
  if (call.error) {
@@ -149,7 +209,8 @@ async function simulate(input, opts) {
149
209
  else if (gas.error) {
150
210
  out.estimateGasError = String(gas.error.message || 'estimateGas failed');
151
211
  // eth_call can pass while estimateGas fails (e.g. gas-dependent logic): still a revert on-chain.
152
- if (out.willRevert === false) {
212
+ // A transient RPC error on estimateGas alone says nothing about the tx, so it does not flip it.
213
+ if (out.willRevert === false && classify(gas.error) !== 'transient') {
153
214
  out.willRevert = true;
154
215
  const rd = revertDataOf(gas.error);
155
216
  const dec = rd ? decodeRevert(rd) : null;
@@ -162,4 +223,4 @@ async function simulate(input, opts) {
162
223
  return out;
163
224
  }
164
225
 
165
- module.exports = { simulate, decodeRevert, toQuantity, PANIC_CODES };
226
+ module.exports = { simulate, validate, decodeRevert, toQuantity, PANIC_CODES };