|
| 1 | +<!doctype html> |
| 2 | +<!-- |
| 3 | + Copyright 2026 AgentPay / up2itnow0822 |
| 4 | + SPDX-License-Identifier: Apache-2.0 |
| 5 | +
|
| 6 | + AgentPay x402 Payment Demo |
| 7 | + Shows both declarative AND imperative WebMCP tool registration. |
| 8 | + x402 Protocol (HTTP 402 Payment Required) — Patent Pending |
| 9 | + Chain: Base (live) | Non-custodial smart contract wallet owned via NFT |
| 10 | +--> |
| 11 | +<html lang="en"> |
| 12 | + <head> |
| 13 | + <meta charset="UTF-8" /> |
| 14 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 15 | + <title>AgentPay x402 — WebMCP Payment Demo</title> |
| 16 | + <link |
| 17 | + rel="icon" |
| 18 | + href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>💳</text></svg>" |
| 19 | + /> |
| 20 | + <link href="style.css" rel="stylesheet" /> |
| 21 | + </head> |
| 22 | + <body> |
| 23 | + <header class="site-header"> |
| 24 | + <div class="logo"> |
| 25 | + <span class="logo-icon">💳</span> |
| 26 | + <div> |
| 27 | + <h1>AgentPay <span class="badge">x402</span></h1> |
| 28 | + <p class="tagline">WebMCP Payment Demo — Patent Pending</p> |
| 29 | + </div> |
| 30 | + </div> |
| 31 | + <div class="chain-badge"> |
| 32 | + <span class="dot"></span> |
| 33 | + Base Mainnet |
| 34 | + </div> |
| 35 | + </header> |
| 36 | + |
| 37 | + <main> |
| 38 | + <!-- Wallet Status Panel --> |
| 39 | + <section class="panel wallet-panel"> |
| 40 | + <h2>🔑 Agent Wallet</h2> |
| 41 | + <div class="wallet-grid"> |
| 42 | + <div class="stat-card"> |
| 43 | + <label>Wallet Address</label> |
| 44 | + <span id="wallet-address" class="mono truncate">Initializing…</span> |
| 45 | + </div> |
| 46 | + <div class="stat-card"> |
| 47 | + <label>USDC Balance</label> |
| 48 | + <span id="wallet-balance" class="mono">—</span> |
| 49 | + </div> |
| 50 | + <div class="stat-card"> |
| 51 | + <label>Session Spend Limit</label> |
| 52 | + <span id="spend-limit" class="mono">—</span> |
| 53 | + </div> |
| 54 | + <div class="stat-card"> |
| 55 | + <label>Session Spent</label> |
| 56 | + <span id="session-spent" class="mono">—</span> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + <p class="wallet-note"> |
| 60 | + Non-custodial · Smart contract wallet · Owned via NFT · |
| 61 | + <a href="https://www.npmjs.com/package/agentpay-mcp" target="_blank" rel="noopener">agentpay-mcp v4.0.0</a> |
| 62 | + </p> |
| 63 | + </section> |
| 64 | + |
| 65 | + <!-- Declarative tool: quick API fetch via form --> |
| 66 | + <section class="panel api-panel"> |
| 67 | + <h2>📡 Fetch Paid API <span class="tag declarative">Declarative</span></h2> |
| 68 | + <p class="panel-desc"> |
| 69 | + Use the declarative WebMCP tool to fetch premium market data. The agent |
| 70 | + will automatically handle HTTP 402 → sign payment → retry. |
| 71 | + </p> |
| 72 | + <form |
| 73 | + id="fetchForm" |
| 74 | + toolname="fetch_paid_api" |
| 75 | + tooldescription="Fetch a URL that may require an x402 micropayment. On HTTP 402, the agent wallet signs a payment on Base and retries automatically. Returns the JSON response body." |
| 76 | + > |
| 77 | + <div class="form-group"> |
| 78 | + <label for="api-url">API Endpoint</label> |
| 79 | + <input |
| 80 | + type="url" |
| 81 | + id="api-url" |
| 82 | + name="url" |
| 83 | + value="https://api.agentpay.demo/market-data/BTC" |
| 84 | + placeholder="https://api.example.com/paid-endpoint" |
| 85 | + toolparamdescription="The URL to fetch. If it returns 402, the agent will pay and retry." |
| 86 | + /> |
| 87 | + </div> |
| 88 | + <div class="form-group"> |
| 89 | + <label for="max-payment">Max Payment (USDC)</label> |
| 90 | + <input |
| 91 | + type="number" |
| 92 | + id="max-payment" |
| 93 | + name="max_payment_usdc" |
| 94 | + value="0.01" |
| 95 | + min="0.001" |
| 96 | + max="10" |
| 97 | + step="0.001" |
| 98 | + toolparamdescription="Maximum USDC to pay for this request. Default 0.01." |
| 99 | + /> |
| 100 | + </div> |
| 101 | + <button type="submit" class="btn-primary"> |
| 102 | + 🚀 Fetch (with x402 payment if needed) |
| 103 | + </button> |
| 104 | + </form> |
| 105 | + </section> |
| 106 | + |
| 107 | + <!-- Activity Log --> |
| 108 | + <section class="panel log-panel"> |
| 109 | + <h2>📋 Activity Log</h2> |
| 110 | + <div id="activity-log" class="log-container"> |
| 111 | + <p class="log-empty">Agent activity will appear here…</p> |
| 112 | + </div> |
| 113 | + <div class="log-controls"> |
| 114 | + <button class="btn-secondary" onclick="clearLog()">🗑 Clear</button> |
| 115 | + </div> |
| 116 | + </section> |
| 117 | + |
| 118 | + <!-- Payment History --> |
| 119 | + <section class="panel history-panel"> |
| 120 | + <h2>💰 Payment History <span class="tag imperative">Imperative</span></h2> |
| 121 | + <p class="panel-desc"> |
| 122 | + Fetched via the <code>get_payment_history</code> imperative tool. |
| 123 | + Ask the agent: <em>"Show me my payment history for this session."</em> |
| 124 | + </p> |
| 125 | + <div id="payment-history" class="history-container"> |
| 126 | + <p class="log-empty">No payments yet this session.</p> |
| 127 | + </div> |
| 128 | + </section> |
| 129 | + |
| 130 | + <!-- API Response --> |
| 131 | + <section class="panel response-panel" id="response-panel" style="display:none"> |
| 132 | + <h2>✅ API Response</h2> |
| 133 | + <pre id="response-body" class="response-body"></pre> |
| 134 | + <div class="payment-proof" id="payment-proof" style="display:none"> |
| 135 | + <h3>🔗 Payment Receipt</h3> |
| 136 | + <div id="receipt-details" class="receipt-grid"></div> |
| 137 | + </div> |
| 138 | + </section> |
| 139 | + |
| 140 | + <!-- Example prompts --> |
| 141 | + <section class="panel prompts-panel"> |
| 142 | + <h2>💬 Example Prompts</h2> |
| 143 | + <ul class="prompt-list"> |
| 144 | + <li> |
| 145 | + <button class="prompt-chip" onclick="copyPrompt(this)"> |
| 146 | + Buy premium market data from this API using x402 payment |
| 147 | + </button> |
| 148 | + </li> |
| 149 | + <li> |
| 150 | + <button class="prompt-chip" onclick="copyPrompt(this)"> |
| 151 | + Check my wallet balance and spend limits |
| 152 | + </button> |
| 153 | + </li> |
| 154 | + <li> |
| 155 | + <button class="prompt-chip" onclick="copyPrompt(this)"> |
| 156 | + Show me my payment history for this session |
| 157 | + </button> |
| 158 | + </li> |
| 159 | + <li> |
| 160 | + <button class="prompt-chip" onclick="copyPrompt(this)"> |
| 161 | + Fetch https://api.agentpay.demo/news/crypto paying up to $0.05 |
| 162 | + </button> |
| 163 | + </li> |
| 164 | + </ul> |
| 165 | + <p class="prompt-note">Click a prompt to copy it, then paste into your AI agent.</p> |
| 166 | + </section> |
| 167 | + |
| 168 | + <!-- WebMCP not available notice --> |
| 169 | + <section class="panel no-webmcp-notice" id="no-webmcp"> |
| 170 | + <h2>⚠️ WebMCP Not Detected</h2> |
| 171 | + <p> |
| 172 | + This demo requires Chrome 146+ with WebMCP enabled. Enable it at |
| 173 | + <code>chrome://flags/#webmcp-for-testing</code> (or search "WebMCP") and restart Chrome. |
| 174 | + </p> |
| 175 | + <p> |
| 176 | + Install the |
| 177 | + <a href="https://chromewebstore.google.com/detail/model-context-tool-inspec/gbpdfapgefenggkahomfgkhfehlcenpd" target="_blank" rel="noopener">Model Context Tool Inspector</a> |
| 178 | + extension to debug registered tools. |
| 179 | + </p> |
| 180 | + </section> |
| 181 | + </main> |
| 182 | + |
| 183 | + <footer> |
| 184 | + <p> |
| 185 | + Powered by |
| 186 | + <a href="https://www.npmjs.com/package/agentpay-mcp" target="_blank" rel="noopener">agentpay-mcp</a> · |
| 187 | + <a href="https://github.com/up2itnow0822/webmcp-sdk" target="_blank" rel="noopener">webmcp-sdk</a> · |
| 188 | + x402 Protocol (Patent Pending) · Built on Base |
| 189 | + </p> |
| 190 | + </footer> |
| 191 | + |
| 192 | + <script type="module" src="script.js"></script> |
| 193 | + </body> |
| 194 | +</html> |
0 commit comments