{"slug": "show-hn-i-built-an-m2m-payment-loop-where-ai-agents-pay-for-data-via-x402", "title": "Show HN: I built an M2M payment loop where AI Agents pay for data via x402", "summary": "A developer has built a machine-to-machine (M2M) payment loop where AI agents pay for data via the x402 v2 protocol, successfully completing a 0.005 USDC transaction on the Base blockchain (Chain ID 8453) for China's National Bureau of Statistics GDP data. The API server at api.060504.shop offers 96 assets and 8 MCP tools, with endpoints priced from $0.003 to $9.99 USDC, and the settled transaction is recorded in block #49848412. The system uses EIP-3009 gasless transfer authorization, enabling AI agents to autonomously purchase data without human intervention.", "body_md": "AI Agent 链上签名支付 0.005 USDC，后端验证结算，国家统计局 GDP 数据交付完成。M2M (Machine to Machine) 微支付商业闭环已落地跑通。\n\n| Item | Value |\n|---|---|\n| API Base | `https://api.060504.shop` |\n| Payment Protocol | x402 v2 (EIP-3009, USDC on Base) |\n| Wallet | `0x1630c8E0833c367F39f0ca909b6b67f5159d7A00` |\n| Chain | Base (Chain ID 8453) |\n| Settled TX | Block #49848412, 0.005 USDC |\n| Assets | 96 |\n| MCP Tools | 8 (4 free + 3 paid + 1 payment) |\n| API Paths | 12 |\n\n| Endpoint | Method | Price | Description |\n|---|---|---|---|\n`/health` |\nGET | Free | Health check |\n`/openapi.json` |\nGET | Free | OpenAPI spec (12 paths) |\n`/catalog.json` |\nGET | Free | 96 assets catalog |\n`/llms.txt` |\nGET | Free | LLM-readable API docs |\n`/.well-known/mcp/server-card.json` |\nGET | Free | MCP server identity card |\n`/v1/api/industry` |\nPOST | $0.005 USDC | China NBS statistics (GDP, CPI, PPI) |\n`/v1/api/policy` |\nPOST | $0.005 USDC | China government policy search |\n`/v1/api/company` |\nPOST | $0.003 USDC | China enterprise credit info |\n`/v1/fetch/dynamic` |\nPOST | $0.008 USDC | Dynamic web content fetch |\n`/v1/assets/{id}` |\nGET | $0.01-$9.99 USDC | Asset delivery |\n\n```\n1. Agent calls POST /v1/api/industry (no payment header)\n2. Server returns 402 Payment Required (x402 v2 challenge)\n   - x402Version: 2\n   - paymentRequirements: {scheme, network, asset, payTo, maxAmountRequired, ...}\n3. Agent signs EIP-3009 TransferWithAuthorization (no gas needed)\n4. Agent retries with X-Payment header\n5. Server verifies signature → settles on-chain → returns 200 + data\n6. On-chain: 0.005 USDC transferred to wallet\n```\n\n**Transaction Hash**:`0xef8d49e88cb58651e9bf30465597b50863dcc363f6e1f227779292149818ae28`\n\n**Method**: Transfer With Authorization (EIP-3009, gasless)** Amount**: 0.005 USDC** Block**: #49848412** Token**: USDC (`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`\n\n)**From**:`0xc4217BD72b4dea480ed4879fcec530d92637C800`\n\n**Recipient**:`0x1630c8E0833c367F39f0ca909b6b67f5159d7A00`\n\n**Scheme**: EIP-3009 (gasless transfer authorization)\n\nVerify on Basescan (Base Mainnet):\n\n```\nTransaction: https://basescan.org/tx/0xef8d49e88cb58651e9bf30465597b50863dcc363f6e1f227779292149818ae28\nWallet: https://basescan.org/address/0x1630c8E0833c367F39f0ca909b6b67f5159d7A00\n```\n\nMCP Server provides 8 tools for AI agents:\n\n`discover_capabilities`\n\n- List all API endpoints`discover_china_data_apis`\n\n- List China Data APIs with pricing`get_capability_info`\n\n- Get details for specific capability`get_payment_instructions`\n\n- Step-by-step x402 payment guide\n\n`query_industry_statistics`\n\n($0.005) - NBS statistics`search_china_policies`\n\n($0.005) - Government policy search`query_company_credit`\n\n($0.003) - Enterprise credit info\n\n`purchase_capability`\n\n- Initiate x402 payment for any endpoint\n\n```\n# 1. Discover the API (free)\ncurl https://api.060504.shop/health\ncurl https://api.060504.shop/openapi.json\ncurl https://api.060504.shop/llms.txt\n\n# 2. Trigger 402 payment challenge\ncurl -X POST https://api.060504.shop/v1/api/industry \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"keyword\":\"GDP\"}'\n# Returns 402 with x402 payment requirements\n\n# 3. Sign EIP-3009 and retry with payment\n# See examples/agent_client.py for full implementation\n# See examples/agent_client.py for complete x402 payment client\npython examples/agent_client.py\n```\n\n| API | Source | Compliance |\n|---|---|---|\n| Industry | data.stats.gov.cn | Rate limited 3s/req, respects robots.txt |\n| Policy | sousuo.\n|\n\n```\nAI Agent / User\n    │\n    ├── GitHub Pages (frontend catalog)\n    │\n    └── API Server (api.060504.shop)\n            │\n            ├── China Data APIs (3 endpoints)\n            ├── x402 Payment (USDC on Base, EIP-3009)\n            └── MCP Server (8 tools)\n```\n\n**Backend**: FastAPI + Uvicorn (Python)** Service**: Windows NSSM (NETWORK SERVICE account)** Payment**: x402 v2 protocol, USDC on Base** MCP**: Model Context Protocol (SSE & stdio)** Frontend**: GitHub Pages** Data**: Chinese government public platforms\n\n- v1.0 (2026-08-07): Initial deployment, 76 assets\n- v2.0 (2026-08-16): 5 new guides, cleanup, 94 assets\n- v3.0 (2026-08-16): China Data APIs + MCP Server, 96 assets\n- v3.1 (2026-08-17): x402 end-to-end payment verified, 0.005 USDC settled\n\nCommercial. All data sourced from public government platforms.", "url": "https://wpnews.pro/news/show-hn-i-built-an-m2m-payment-loop-where-ai-agents-pay-for-data-via-x402", "canonical_source": "https://github.com/tianzizhiming-svg/agentbridge", "published_at": "2026-08-18 07:07:00+00:00", "updated_at": "2026-08-18 07:41:23.798588+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "ai-infrastructure", "ai-products", "ai-tools"], "entities": ["x402", "Base", "USDC", "EIP-3009", "MCP", "FastAPI", "GitHub Pages", "api.060504.shop"], "alternates": {"html": "https://wpnews.pro/news/show-hn-i-built-an-m2m-payment-loop-where-ai-agents-pay-for-data-via-x402", "markdown": "https://wpnews.pro/news/show-hn-i-built-an-m2m-payment-loop-where-ai-agents-pay-for-data-via-x402.md", "text": "https://wpnews.pro/news/show-hn-i-built-an-m2m-payment-loop-where-ai-agents-pay-for-data-via-x402.txt", "jsonld": "https://wpnews.pro/news/show-hn-i-built-an-m2m-payment-loop-where-ai-agents-pay-for-data-via-x402.jsonld"}}