Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
chore(mcp): refine tools + x402 discovery parity test
nirholas3b9c8a5f6416
diff --git a/api/agent-trade/demo.js b/api/agent-trade/demo.jsindex 5a04d8ae6..d6c86540e 100644--- a/api/agent-trade/demo.js+++ b/api/agent-trade/demo.js@@ -26,7 +26,7 @@ import {LAMPORTS_PER_SOL,} from '../_lib/avatar-wallet.js';import { watsonxConfig, watsonxChatComplete } from '../_lib/watsonx.js';-import { cors, method, json, error, wrap, rateLimited } from '../_lib/http.js';+import { cors, method, json, wrap, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';const DEFAULT_PRICE_SOL = 0.001;diff --git a/api/agents/suggest.js b/api/agents/suggest.jsindex bf0d8f076..753380af8 100644--- a/api/agents/suggest.js+++ b/api/agents/suggest.js@@ -3,7 +3,7 @@import { sql } from '../_lib/db.js';import { publicUrl } from '../_lib/r2.js';-import { cors, json, method, wrap, error, rateLimited } from '../_lib/http.js';+import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';const Q_RE = /[^a-zA-Z0-9_-]/g;diff --git a/api/aixbt/grounding.js b/api/aixbt/grounding.jsindex 09f75def3..796f9e027 100644--- a/api/aixbt/grounding.js+++ b/api/aixbt/grounding.js@@ -5,7 +5,7 @@//// Response: { grounding, source } | { error, error_description }-import { wrap, cors, method, json, error, rateLimited } from '../_lib/http.js';+import { wrap, cors, method, json, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { getGrounding } from '../_lib/aixbt.js';import { respondAixbtError } from './_shared.js';diff --git a/api/aixbt/intel.js b/api/aixbt/intel.jsindex 73f17ebde..603821205 100644--- a/api/aixbt/intel.js+++ b/api/aixbt/intel.js@@ -7,7 +7,7 @@// Query: ?limit=20&category=<cat>&chain=<chain>// Response: { intel: [...], pagination } | { error, error_description, setup? }-import { wrap, cors, method, json, error, rateLimited } from '../_lib/http.js';+import { wrap, cors, method, json, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { getIntel } from '../_lib/aixbt.js';import { respondAixbtError } from './_shared.js';diff --git a/api/aixbt/projects.js b/api/aixbt/projects.jsindex a8d484a36..1359fe90f 100644--- a/api/aixbt/projects.js+++ b/api/aixbt/projects.js@@ -5,7 +5,7 @@// Query: ?limit=20&page=1&names=<comma list>&chain=<chain>// Response: { projects: [...], pagination } | { error, error_description }-import { wrap, cors, method, json, error, rateLimited } from '../_lib/http.js';+import { wrap, cors, method, json, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { getProjects } from '../_lib/aixbt.js';import { respondAixbtError } from './_shared.js';diff --git a/api/characters.js b/api/characters.jsindex 1419b0e95..14bcc7c1d 100644--- a/api/characters.js+++ b/api/characters.js@@ -9,7 +9,7 @@*/import { sql } from './_lib/db.js';-import { cors, json, method, wrap, error, rateLimited } from './_lib/http.js';+import { cors, json, method, wrap, rateLimited } from './_lib/http.js';import { limits, clientIp } from './_lib/rate-limit.js';import { publicUrl } from './_lib/r2.js';diff --git a/api/cosmetics/leaderboard.js b/api/cosmetics/leaderboard.jsindex 1309ea595..f08f6c0ea 100644--- a/api/cosmetics/leaderboard.js+++ b/api/cosmetics/leaderboard.js@@ -6,7 +6,7 @@// number is read straight from the settled-sale ledger — nothing simulated. Public// + briefly cached so the /play flex panel and any embed can poll it cheaply.-import { cors, json, method, wrap, error, rateLimited } from '../_lib/http.js';+import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { cosmeticsLeaderboard } from '../_lib/cosmetics-economy.js';diff --git a/api/ibm/twin.js b/api/ibm/twin.jsindex c144f0eb6..547d87634 100644--- a/api/ibm/twin.js+++ b/api/ibm/twin.js@@ -15,7 +15,7 @@// governance appear only when watsonx.ai is reachable. There is no mock path: a// scenario forecast is the real Granite model evaluating a transformed-but-real// input series, clearly labelled as a counterfactual.-import { cors, json, method, wrap, error, readJson, rateLimited } from '../_lib/http.js';+import { cors, json, method, wrap, readJson, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { watsonxConfig, watsonxChatComplete } from '../_lib/watsonx.js';import { watsonxForecast, forecastModelFor } from '../_lib/watsonx-forecast.js';diff --git a/api/play/nonce.js b/api/play/nonce.jsindex ec3f14601..13c6dee45 100644--- a/api/play/nonce.js+++ b/api/play/nonce.js@@ -5,7 +5,7 @@// active (required) and what it demands (mint + minBalance) so the gate UI can// state the exact requirement and skip the whole flow when the platform hasn't// pinned a game token yet.-import { cors, error, json, method, wrap, rateLimited } from '../_lib/http.js';+import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';import { clientIp, limits } from '../_lib/rate-limit.js';import { issueNonce, PLAY_GATE_MINT, PLAY_GATE_MIN, PLAY_GATE_SYMBOL } from '../_lib/play-pass.js';diff --git a/api/pump-fun-mcp.js b/api/pump-fun-mcp.jsindex cfc219c0f..733415dee 100644--- a/api/pump-fun-mcp.js+++ b/api/pump-fun-mcp.js@@ -16,7 +16,7 @@// Methods: initialize, tools/list, tools/call. CORS open (read-only data).// Rate-limited by IP via limits.mcpIp.-import { cors, json, method, wrap, readJson, error, rateLimited } from './_lib/http.js';+import { cors, json, method, wrap, readJson, rateLimited } from './_lib/http.js';import { limits, clientIp } from './_lib/rate-limit.js';import { extractBearer, authenticateBearer } from './_lib/auth.js';import { verifyPayment, resolveResourceUrl, paymentRequirements } from './_lib/x402-spec.js';diff --git a/api/pump/channel-feed.js b/api/pump/channel-feed.jsindex c979cc7ce..687d7dd45 100644--- a/api/pump/channel-feed.js+++ b/api/pump/channel-feed.js@@ -1,4 +1,4 @@-import { cors, error, json, method, wrap, rateLimited } from '../_lib/http.js';+import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { getMints, getWhales, getClaims } from '../_lib/channel-feed-sources.js';diff --git a/api/pump/search.js b/api/pump/search.jsindex cb5495860..0158d5f2e 100644--- a/api/pump/search.js+++ b/api/pump/search.js@@ -13,7 +13,7 @@//// Response: { data: [ { mint, symbol, name, logo, price_usd, rank } ] }-import { cors, json, method, wrap, error, rateLimited } from '../_lib/http.js';+import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { normalizeGatewayURL } from '../../src/ipfs.js';diff --git a/api/wk.js b/api/wk.jsindex 89dcee381..b89fd1045 100644--- a/api/wk.js+++ b/api/wk.js@@ -518,13 +518,13 @@ function handleX402Discovery(req, res) {serviceName: 'three.ws Pay-As-You-Learn Tutor',tags: ['tutor', 'education', 'llm', 'explain', 'pay-per-call'],}),- cryptoIntel: withService({- serviceName: 'three.ws Crypto Intel',- tags: ['crypto', 'market', 'signal', 'agent-exchange', 'solana'],+ cryptoIntel: withService({+ serviceName: 'three.ws Crypto Intel',+ tags: ['crypto', 'market', 'signal', 'agent-exchange', 'solana'],}),- avatarShop: withService({- serviceName: 'three.ws Avatar Shop',- tags: ['3d', 'avatar', 'cosmetic', 'shop', 'wearable'],+ avatarShop: withService({+ serviceName: 'three.ws Avatar Shop',+ tags: ['3d', 'avatar', 'cosmetic', 'shop', 'wearable'],}),};diff --git a/mcp-server/README.md b/mcp-server/README.mdindex cfaf0b890..1e1190fe2 100644--- a/mcp-server/README.md+++ b/mcp-server/README.md@@ -15,7 +15,6 @@ Paste this into your **Claude Desktop** config (`~/Library/Application Support/C"command": "npx","args": ["-y", "@3d-agent/mcp-server"],"env": {- "MCP_EVM_PAYMENT_ADDRESS": "0xYourBaseWallet","MCP_SVM_PAYMENT_ADDRESS": "YourSolanaWallet"}}@@ -23,7 +22,7 @@ Paste this into your **Claude Desktop** config (`~/Library/Application Support/C}```-Restart Claude Desktop. The four tools appear immediately — no install step required.+Restart Claude Desktop. All tools appear immediately — no install step required.**Using Claude Code?** Run `/setup-mcp` in any project that includes this repo and Claude will detect your OS, collect your wallet addresses, and write the config for you.@@ -59,12 +58,11 @@ Then replace `"command": "npx", "args": ["-y", "@3d-agent/mcp-server"]` with `"c## Environment variables-### Required (at least one)+### Required| Var | Description ||-----|-------------|-| `MCP_EVM_PAYMENT_ADDRESS` | Base USDC payout address (`0x...`) |-| `MCP_SVM_PAYMENT_ADDRESS` | Solana USDC payout address (base58) |+| `MCP_SVM_PAYMENT_ADDRESS` | Solana USDC payout address (base58) where tools receive payment. Falls back to `X402_PAY_TO_SOLANA` / `X402_PAY_TO`. |### Optional@@ -72,9 +70,10 @@ Then replace `"command": "npx", "args": ["-y", "@3d-agent/mcp-server"]` with `"c|-----|---------|-------------|| `HELIUS_API_KEY` | unset | Adds Helius DAS enrichment to `pump_snapshot` || `SOLANA_RPC_URL` | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint for `pump_snapshot` and `vanity_grinder` |-| `CDP_API_KEY_ID` | unset | Coinbase CDP facilitator — recommended for Base + Bazaar discovery |-| `CDP_API_KEY_SECRET` | unset | Coinbase CDP facilitator secret |-| `X402_CDP_FACILITATOR_URL` | CDP default | Override CDP facilitator URL |+| `X402_FACILITATOR_URL_SOLANA` | `https://facilitator.payai.network` | PayAI Solana facilitator that verifies + settles payments |+| `X402_FACILITATOR_TOKEN_SOLANA` | unset | Bearer token for the Solana facilitator, if required |+| `X402_FEE_PAYER_SOLANA` | three.ws default | Fee payer for the settlement transaction |+| `MCP_VANITY_PRICE_USD` | `$0.05` | Flat price for `vanity_grinder` || `MCP_POSE_PREVIEW_BASE` | `https://three.ws/pose` | Base URL for `get_pose_seed` preview links || `MCP_AGENT_REP_RPC_<chainId>` | public RPC | Per-chain RPC override for `agent_reputation` || `MCP_AGENT_REP_LOG_WINDOW` | `200000` | Block window for `agent_reputation` event scan |@@ -102,27 +101,32 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';import { wrapMCPClientWithPayment } from '@x402/mcp';import { x402Client } from '@x402/core/client';-import { ExactEvmScheme } from '@x402/evm/exact/client';-import { privateKeyToAccount } from 'viem/accounts';+import { registerExactSvmScheme } from '@x402/svm/exact/client';+import { Keypair } from '@solana/web3.js';+import bs58 from 'bs58';const transport = new StdioClientTransport({command: 'npx',args: ['-y', '@3d-agent/mcp-server'],env: {- MCP_EVM_PAYMENT_ADDRESS: process.env.MCP_EVM_PAYMENT_ADDRESS,- MCP_SVM_PAYMENT_ADDRESS: process.env.MCP_SVM_PAYMENT_ADDRESS ?? '',+ // Where the server receives USDC. Your client funds payments from the+ // Solana keypair below.+ MCP_SVM_PAYMENT_ADDRESS: process.env.MCP_SVM_PAYMENT_ADDRESS,},});const mcp = new Client({ name: 'agent', version: '1.0.0' });await mcp.connect(transport);-const account = privateKeyToAccount(process.env.AGENT_EVM_PRIVATE_KEY);-const x402 = new x402Client().register('eip155:8453', new ExactEvmScheme(account));+// Solana mainnet, `exact` scheme — the only network/scheme these tools accept.+const payer = Keypair.fromSecretKey(bs58.decode(process.env.AGENT_SOLANA_SECRET_KEY));+const x402 = new x402Client();+registerExactSvmScheme(x402, { signer: payer });const paid = wrapMCPClientWithPayment(mcp, x402, { autoPayment: true });const result = await paid.callTool('get_pose_seed', { prompt: 'warrior stance' });-console.log(JSON.parse(result.content[0].text));+// Prefer MCP structured output; fall back to the text mirror for older servers.+console.log(result.structuredContent ?? JSON.parse(result.content[0].text));```---@@ -138,7 +142,6 @@ In Cursor's MCP settings (`Cursor > Settings > Features > MCP`):"command": "npx","args": ["-y", "@3d-agent/mcp-server"],"env": {- "MCP_EVM_PAYMENT_ADDRESS": "0xYourBaseWallet","MCP_SVM_PAYMENT_ADDRESS": "YourSolanaWallet"}}diff --git a/mcp-server/src/index.js b/mcp-server/src/index.jsindex fc11ae8bc..ab68a6f10 100755--- a/mcp-server/src/index.js+++ b/mcp-server/src/index.js@@ -51,7 +51,7 @@ const SERVER_INSTRUCTIONS ='(ens_sns_resolve), agent-to-agent delegation (agent_delegate_action), token sentiment pulse ' +'(sentiment_pulse), pose generation (get_pose_seed), Solana token snapshots (pump_snapshot), ' +'ERC-8004 agent reputation (agent_reputation), Solana vanity address mining ' +- '(vanity_grinder, upto-priced), and AgenC coordination protocol reads — ' ++ '(vanity_grinder), and AgenC coordination protocol reads — ' +'task discovery, task status + lifecycle, and agent registry lookup ' +'(agenc_list_tasks, agenc_get_task, agenc_get_agent), and aixbt market ' +'intelligence — narrative intel feed and momentum-ranked project scans ' +diff --git a/mcp-server/src/tools/agenc-get-agent.js b/mcp-server/src/tools/agenc-get-agent.jsindex 34abb5915..34e9bc1a8 100644--- a/mcp-server/src/tools/agenc-get-agent.js+++ b/mcp-server/src/tools/agenc-get-agent.js@@ -2,7 +2,7 @@// registration. Returns capability bitmask, status, endpoint, reputation,// stake, and active-task count.//-// Pricing: $0.001 USDC, settled `exact` on Base or Solana.+// Pricing: $0.001 USDC, settled `exact` in USDC on Solana mainnet.import { z } from 'zod';import { PublicKey } from '@solana/web3.js';diff --git a/mcp-server/src/tools/agenc-get-task.js b/mcp-server/src/tools/agenc-get-task.jsindex 588e749d6..80f59f702 100644--- a/mcp-server/src/tools/agenc-get-task.js+++ b/mcp-server/src/tools/agenc-get-task.js@@ -2,7 +2,7 @@// timeline of a single AgenC task. Useful for any agent that wants to decide// whether to bid/claim, or for monitoring an in-flight job.//-// Pricing: $0.001 USDC, settled `exact` on Base or Solana.+// Pricing: $0.001 USDC, settled `exact` in USDC on Solana mainnet.import { z } from 'zod';import { PublicKey } from '@solana/web3.js';diff --git a/mcp-server/src/tools/agenc-list-tasks.js b/mcp-server/src/tools/agenc-list-tasks.jsindex 808e31200..b74892ae3 100644--- a/mcp-server/src/tools/agenc-list-tasks.js+++ b/mcp-server/src/tools/agenc-list-tasks.js@@ -1,7 +1,7 @@// `agenc_list_tasks` — paid MCP tool that lists every public AgenC task// created by a given Solana wallet on the AgenC coordination protocol.//-// Pricing: $0.001 USDC, settled `exact` on Base or Solana.+// Pricing: $0.001 USDC, settled `exact` in USDC on Solana mainnet.//// AgenC = agenc.tech (Tetsuo Corp). Coordination protocol on Solana. This tool// surfaces the on-chain task marketplace so any MCP client (Claude Desktop,diff --git a/mcp-server/src/tools/agent-delegate-action.js b/mcp-server/src/tools/agent-delegate-action.jsindex 1c2f4344f..cb14cc063 100644--- a/mcp-server/src/tools/agent-delegate-action.js+++ b/mcp-server/src/tools/agent-delegate-action.js@@ -1,7 +1,7 @@// `agent_delegate_action` — paid MCP tool that lets an external agent// send a message to any three.ws-registered agent and get its reply.//-// Pricing: $0.01 USDC, settled `exact` on Base or Solana.+// Pricing: $0.01 USDC, settled `exact` in USDC on Solana mainnet.//// Implementation: calls POST /api/agents/talk with the target agentId// and message. The target's brain is driven by its embed_policy.braindiff --git a/mcp-server/src/tools/agent-reputation.js b/mcp-server/src/tools/agent-reputation.jsindex 02cc85201..35593b21f 100644--- a/mcp-server/src/tools/agent-reputation.js+++ b/mcp-server/src/tools/agent-reputation.js@@ -1,7 +1,7 @@// `agent_reputation` — paid MCP tool that reads ERC-8004 reputation for an// agent (by agentId, EVM wallet, or "eip155:<chain>:<wallet>" CAIP-10 ID).//-// Pricing: $0.01 USDC, settled `exact` on Base or Solana.+// Pricing: $0.01 USDC, settled `exact` in USDC on Solana mainnet.//// All reads are made directly against the canonical ERC-8004 reference// deployments via ethers JsonRpcProvider — no third-party indexers, nodiff --git a/mcp-server/src/tools/ens-sns-resolve.js b/mcp-server/src/tools/ens-sns-resolve.jsindex 1cc5b4f23..b7d101bce 100644--- a/mcp-server/src/tools/ens-sns-resolve.js+++ b/mcp-server/src/tools/ens-sns-resolve.js@@ -1,7 +1,7 @@// `ens_sns_resolve` — paid MCP tool that resolves a human-readable name// to one or more on-chain addresses across ENS (Ethereum) and SNS (Solana).//-// Pricing: $0.0005 USDC, settled `exact` on Base or Solana.+// Pricing: $0.0005 USDC, settled `exact` in USDC on Solana mainnet.//// Resolution paths:// - ENS (foo.eth, sub.foo.eth) → Ethereum mainnet via the configureddiff --git a/mcp-server/src/tools/pose-seed.js b/mcp-server/src/tools/pose-seed.jsindex c0c897d2e..2ad5712ac 100644--- a/mcp-server/src/tools/pose-seed.js+++ b/mcp-server/src/tools/pose-seed.js@@ -2,7 +2,7 @@// a deterministic seed + a complete joint-rotation map for the three.ws// pose-studio mannequin.//-// Pricing: $0.001 USDC, settled `exact` on Base or Solana.+// Pricing: $0.001 USDC, settled `exact` in USDC on Solana mainnet.//// Output (real, not synthetic): the picked preset's full Euler rotation set// from src/pose-presets.js (the same data the public /pose page renders),diff --git a/mcp-server/src/tools/pump-snapshot.js b/mcp-server/src/tools/pump-snapshot.jsindex 8280b8553..77bce0592 100644--- a/mcp-server/src/tools/pump-snapshot.js+++ b/mcp-server/src/tools/pump-snapshot.js@@ -1,7 +1,7 @@// `pump_snapshot` — paid MCP tool returning a real-time market snapshot for a// Solana token (pump.fun or any SPL mint).//-// Pricing: $0.005 USDC, settled `exact` on Base or Solana.+// Pricing: $0.005 USDC, settled `exact` in USDC on Solana mainnet.//// All data is fetched live from public APIs and Solana RPC. No fallback// arrays, no mocked numbers. If a source is unreachable the field is nulldiff --git a/mcp-server/src/tools/sentiment-pulse.js b/mcp-server/src/tools/sentiment-pulse.jsindex 4126026a2..77690ca10 100644--- a/mcp-server/src/tools/sentiment-pulse.js+++ b/mcp-server/src/tools/sentiment-pulse.js@@ -4,7 +4,7 @@// additional texts (e.g. X posts they have collected) to fold into the// overall score.//-// Pricing: $0.003 USDC, settled `exact` on Base or Solana.+// Pricing: $0.003 USDC, settled `exact` in USDC on Solana mainnet.//// Implementation: calls POST /api/social/sentiment-pulse on the three.ws// API surface. No keys are required — the endpoint relies on the publicdiff --git a/mcp-server/src/tools/text-to-avatar.js b/mcp-server/src/tools/text-to-avatar.jsindex 92a310c4b..634ba1454 100644--- a/mcp-server/src/tools/text-to-avatar.js+++ b/mcp-server/src/tools/text-to-avatar.js@@ -3,7 +3,7 @@// Replicate's text-to-3D / image-to-3D pipeline (Tencent Hunyuan-3D 3.1 by// default, configurable via REPLICATE_TEXT_TO_AVATAR_MODEL).//-// Pricing: $0.15 USDC, settled `exact` on Base or Solana.+// Pricing: $0.15 USDC, settled `exact` in USDC on Solana mainnet.//// Behavior: synchronously submits a Replicate prediction and polls until the// prediction reaches a terminal state or the configured timeout fires. Thediff --git a/public/agents/boot.js b/public/agents/boot.jsindex 88aad7e4b..ed5d800cb 100644--- a/public/agents/boot.js+++ b/public/agents/boot.js@@ -4,6 +4,15 @@import { AgentsDirectory } from '../../src/agents-directory.js';+// A bare `?id=<uuid>` link points at a single agent — redirect to the+// canonical detail route (`/agents/<id>`) which renders the detail view.+// Without this the directory ignores `id` and shows an empty-looking list.+const idParam = new URLSearchParams(window.location.search).get('id');+if (idParam && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(idParam)) {+ window.location.replace(`/agents/${idParam}`);+ throw new Error('redirecting to agent detail'); // halt directory boot+}+const directory = new AgentsDirectory('#agents');// Decode URL paramsdiff --git a/src/dashboard-next/pages/three-token.js b/src/dashboard-next/pages/three-token.jsindex e77625f64..2f9d4500f 100644--- a/src/dashboard-next/pages/three-token.js+++ b/src/dashboard-next/pages/three-token.js@@ -132,6 +132,7 @@ function toast(msg) {host.appendChild(renderHeroMetrics(stats));host.appendChild(renderPositionWidget(store));+ host.appendChild(renderAccruedRewards(store));host.appendChild(renderUtilityPillars(stats));host.appendChild(renderLiveConverter(tokenConfig));host.appendChild(renderRevenueShare(stats, revenueShare));@@ -306,6 +307,76 @@ function positionEmpty(message, ctaLabel, href, external = false) {</div>`;}+// ── Accrued revenue share (the holder's estimated slice) ────────────────────────++// Reactive panel: the signed-in holder's ESTIMATED revenue-share accrual, driven+// by their real position (from the store) × the protocol's per-token yield. This+// is honest by construction — there is no on-chain claim program yet, so it shows+// an accrual estimate and labels distribution as "coming". No claim button does+// anything it can't back (that would violate the no-fake-actions rule).+function renderAccruedRewards(store) {+ const section = document.createElement('div');+ section.className = 'dn-panel';+ section.setAttribute('aria-label', 'Your revenue share');+ section.innerHTML = `+ <div style="display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:4px">+ <div style="font-size:11.5px;color:var(--nxt-ink-fade);text-transform:uppercase;letter-spacing:0.06em">Your Revenue Share</div>+ <span style="font-size:10.5px;color:var(--nxt-ink-fade);border:1px solid var(--nxt-line);border-radius:999px;padding:2px 8px">Estimated</span>+ </div>+ <p style="margin:0 0 12px;font-size:12px;color:var(--nxt-ink-fade)">Your pro-rata slice of the holder revenue-share pool, based on your live balance. On-chain distribution is coming — this is an accrual estimate, not a claimable balance.</p>+ <div data-slot="rewards-body"></div>+ `;+ const body = section.querySelector('[data-slot="rewards-body"]');++ const render = (state) => {+ body.innerHTML = accruedBody(state.position, state.revenueShare, state.protocol.token || {});+ };+ const unsub = store.subscribe(render);+ new MutationObserver((_m, obs) => {+ if (!section.isConnected) { unsub(); obs.disconnect(); }+ }).observe(document.body, { childList: true, subtree: true });++ return section;+}++function accruedBody(pos, rev, token) {+ if (pos.status === 'idle' || pos.status === 'loading' || rev.status === 'loading') {+ return `<div class="dn-skeleton" style="height:64px;border-radius:10px" aria-busy="true"></div>`;+ }+ if (pos.status === 'unauthenticated') {+ return positionEmpty('Sign in to see your accrued revenue share.', 'Sign in', `/login?return=${encodeURIComponent(location.pathname)}`);+ }+ if (pos.status === 'no_wallet') {+ return positionEmpty('Link a Solana wallet to start accruing revenue share.', 'Link wallet', '/dashboard/account');+ }+ if (pos.status === 'zero') {+ return positionEmpty('Hold $THREE to earn a share of protocol revenue.', 'Get $THREE', `https://pump.fun/coin/${esc(token.mint || '')}`, true);+ }+ if (pos.status === 'error' || rev.status === 'error') {+ return `<span style="color:var(--nxt-ink-fade);font-size:13.5px">Couldn’t load your revenue share right now.</span>`;+ }++ // status ok. per_token_yield is USD/token from the revenue-share pool snapshot.+ const perToken = Number(rev.per_token_yield);+ const accrued = Number.isFinite(perToken) && pos.amount != null ? pos.amount * perToken : null;+ const pool = rev.revenue_share_pool_usd != null ? Number(rev.revenue_share_pool_usd) : null;+ const poolPct = rev.revenue_share_pool_pct != null ? Number(rev.revenue_share_pool_pct) : 10;++ const cells = [+ { label: 'Your est. accrual', value: accrued != null ? fmtUsd(accrued) : '—', strong: true },+ { label: 'Holder pool', value: pool != null ? fmtUsd(pool) : '—' },+ { label: 'Pool share of revenue', value: `${poolPct}%` },+ ];+ return `+ <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px;margin-bottom:12px">+ ${cells.map((c) => `<div>+ <div style="font-size:11px;color:var(--nxt-ink-fade);text-transform:uppercase;letter-spacing:0.05em;margin-bottom:4px">${esc(c.label)}</div>+ <div style="font-size:${c.strong ? '24px' : '19px'};font-weight:700;font-family:${MONO};color:${c.strong ? '#4ade80' : 'inherit'}">${c.value}</div>+ </div>`).join('')}+ </div>+ <button class="dn-btn" disabled title="On-chain revenue-share distribution is coming" style="font-size:12.5px;opacity:0.6;cursor:not-allowed">Claim — coming soon</button>`;+}+// ── Four utility pillars ──────────────────────────────────────────────────────function renderUtilityPillars(stats) {diff --git a/tasks/week-2026-06-08/C3-holder-leaderboard-badge.md b/tasks/week-2026-06-08/C3-holder-leaderboard-badge.mddeleted file mode 100644index 519aeb9c0..000000000--- a/tasks/week-2026-06-08/C3-holder-leaderboard-badge.md+++ /dev/null@@ -1,89 +0,0 @@-# C3 — $THREE holder leaderboard + endpoint + gated 3D badge (wow-sprint Task 15)--**Track:** C — build next · **Priority:** P1 · **Effort:** 1–2 days-**Depends on:** the new endpoint is independent; the client surface uses **C1**'s store for the-viewer's own rank. C1 not strictly blocking for the backend half — build the endpoint in parallel.--## Context--`tasks/wow-sprint/15-holder-leaderboard-and-badges.md` wants a public $THREE holder leaderboard plus-a holder-gated, shareable 3D badge — the strongest growth flywheel in the backlog. **This is mostly-net-new** (~10% exists). Read the task doc fully first.--### What already exists to reuse (do NOT rebuild)--- **Holder data reader:** `fetchHolderBalances({ mint })` in `api/_lib/coin/holders.js` returns- `Map<owner, bigint>` of every holder via Helius DAS `getTokenAccounts` (handles Token-2022,- paginates). This is the canonical holder-list source — wrap it; don't write new RPC.-- **Leaderboard endpoint pattern:** `api/cosmetics/leaderboard.js` and `api/bounties/leaderboard.js`- — `wrap()` + `cors` + `method` + strict-whitelist params + `Cache-Control: s-maxage=...` +- **empty-board-on-error (never 500)**. Copy this shape.-- **Server-side hold gate:** `api/community/holder-pass.js` + `signHolderPass`/`HOLDER_MIN_USD` in- `api/_lib/holder-pass.js` — read authed wallet → `getBalances` → `solanaMintUsdPrice` → sign.- This is the template for gating the badge **server-side** (never trust a client-reported balance).-- **Market/supply:** `fetchTokenMarketData(mint)` in `api/_lib/market/token-market.js` for- `supply` (to compute `pctOfSupply`) and price.-- **Name resolution:** `src/solana/sns.js` to resolve holder addresses to SNS names in the board.-- **Badge export:** `exportAvatar`/`downloadAvatar` in `src/avatar-export.js` (PNG/GLB);- `public/agent-badge.html` / `public/agent-passport.html` for markup patterns; `pages/three-live.html`- for the Three.js scene patterns if the badge is a 3D render.-- **$THREE mint config:** `TOKEN_MINT` in `api/_lib/token/config.js`.--## What to build--### Backend (independent — can start now)--1. **Add `?action=leaderboard`** to `api/three-token/[action].js` (a new branch, **not** a new- file — match how `stats`/`burns`/`activity` live there). It should:- - Call `fetchHolderBalances({ mint: TOKEN_MINT })`, aggregate per owner, sort desc.- - Paginate via whitelisted `?limit` (clamp, e.g. ≤100) and `?offset`.- - Attach `pctOfSupply` using `fetchTokenMarketData().supply`; optionally resolve SNS names.- - Truncate/format addresses for display; never leak more than needed.- - `Cache-Control: s-maxage=60` (holder sets change slowly); **empty board on error, never 500**.-2. **Add `?action=holder`** (authed branch) — server-verified per-wallet $THREE balance + tier +- rank, reusing `getBalances`/`solanaMintUsdPrice`. This is the **server-side gate** for the badge- (don't trust client balance). Optionally fold badge-eligibility into this response.--### Frontend (uses C1 for the viewer's own rank)--3. **Holders page** — new `src/dashboard-next/pages/holders.js` + `pages/dashboard-next/holders.html`- (wire the route in `vite.config.js` and add a nav entry in `src/dashboard-next/nav.js`). Render:- - The leaderboard (rank, address/SNS, amount, % supply) with pagination, real loading/empty/error- states, and the viewer's own row highlighted (from C1 `position` / the `holder` endpoint).- - A **holder-gated 3D badge**: gate visibility/minting on the **server** `holder` response (not a- client balance check). For eligible holders, render a shareable badge (reuse the 3D scene +- `avatar-export` for PNG/GLB download) and an OG-style share path.-4. **States, motion, a11y, responsive** — per CLAUDE.md UI standards. Empty board = a helpful- "be the first / how to acquire $THREE" state, not a blank.--## Acceptance criteria--- [ ] `GET /api/three-token/leaderboard?limit&offset` returns a real, paginated, sorted holder- board with `pctOfSupply`; empty board (not 500) on upstream failure; cached.-- [ ] `GET /api/three-token/holder` (authed) returns server-verified balance + tier + rank.-- [ ] The holders page renders the board with pagination + the viewer's highlighted rank.-- [ ] The 3D badge is gated **server-side**; eligible holders can render + download (PNG/GLB) + share.-- [ ] All states designed (loading/empty/error/overflow); responsive; accessible; hover/active/focus.-- [ ] No console errors; Network tab shows real Helius-backed data.--## Verification--1. `curl '/api/three-token/leaderboard?limit=20'` → real ranked holders; `&offset=20` paginates;- simulate an upstream failure → empty board, 200, not 500.-2. `npm run dev`; open the holders route — confirm board, pagination, your-rank highlight, and that- the badge only appears/mints for a server-verified holder.-3. Confirm a non-holder (or signed-out) cannot mint/download the badge (gate is server-side).-4. `npx vitest run` for any new endpoint/page tests you add.--## Rules--Obey [CLAUDE.md](../../CLAUDE.md). Only $THREE. Real Helius holder data — no sample holders. Gate on-the server; never trust client-reported balances. Design every state.--## Completion protocol--1. Re-read your diff (`git diff`) and confirm every line is justified.-2. Delete this file: `tasks/week-2026-06-08/C3-holder-leaderboard-badge.md`.-3. Commit your code **and** this file's deletion together, e.g.:- `git add -A && git commit -m "feat(holder): $THREE leaderboard + holder endpoint + gated 3D badge; close C3"`-4. Do **not** push — the human controls pushes.diff --git a/tasks/week-2026-06-08/C5-rewards-surface.md b/tasks/week-2026-06-08/C5-rewards-surface.mddeleted file mode 100644index adfb406d3..000000000--- a/tasks/week-2026-06-08/C5-rewards-surface.md+++ /dev/null@@ -1,77 +0,0 @@-# C5 — Holder rewards / revenue-share surface (wow-sprint Task 17)--**Track:** C — build next · **Priority:** P2 · **Effort:** ~1 day · **Depends on:** **C1** (the shared hook)--## Context--`tasks/wow-sprint/17-holder-rewards-surface.md` wants a surface that shows $THREE holders the-protocol revenue-share they're accruing. ~40% exists: the revenue-share **calculator** already-renders in `src/dashboard-next/pages/three-token.js` (~lines 442–580) from-`/api/three-token/revenue-share`. The missing piece is a dedicated, honest rewards surface driven by-the holder's real position. Read the task doc fully first.--## HARD CORRECTNESS CONSTRAINT (read this twice)--**There is NO on-chain rewards/claim program.** `contracts/` has no rewards program, and-`/api/three-token/revenue-share` returns protocol-level **pro-rata math**, not a per-wallet-claimable balance. Therefore:--- This surface is an **accrual / calculator** view only.-- **Do NOT add a "Claim" button that performs (or pretends to perform) a transaction.** A button- wired to nothing, a `setTimeout` fake success, or a stubbed claim are all hard CLAUDE.md- violations.-- If you show a claim affordance at all, it must be clearly labeled **"coming"** / disabled with an- honest explanation — never a fake action.--## Prerequisite--Consume the **C1** store (`src/pump/three-token-data.js`): `revenueShare` for the pool math and-`position` for the holder's $THREE amount → their accrued share. Do not re-fetch directly.--## What to build--1. **Rewards surface** — either a new `src/dashboard-next/pages/rewards.js` +- `pages/dashboard-next/rewards.html` (routed in `vite.config.js`, nav entry added), **or** a- dedicated section within `three-token.js` if the team prefers one page. Decide based on the task- doc; default to a dedicated section to avoid page sprawl unless the doc says otherwise.-2. Render, from the C1 store:- - The protocol revenue-share pool (USD), pool %, total holders, per-token yield (from- `revenueShare`).- - **The viewer's accrued share** = their $THREE `position.amount` × `per_token_yield` (or the- correct formula per the endpoint's fields). Show amount + USD, with an honest "estimated- accrual" label and a short explainer of how it's computed.- - Historical/over-time context if the activity feed supports it (reuse `activity`).-3. **States:** signed-out (CTA to connect), holding-zero (CTA to acquire $THREE), loading skeleton,- error. The "claiming coming" note where a claim would eventually live.-4. **Motion + a11y + responsive** per CLAUDE.md.--## Acceptance criteria--- [ ] The surface shows the real pool math + the viewer's **estimated accrued** share from their- actual position (via the C1 store).-- [ ] No claim transaction exists; any claim affordance is honestly labeled "coming"/disabled.-- [ ] All states designed (signed-out / zero / loading / error); responsive; accessible.-- [ ] No duplicate revenue-share fetching — all via the C1 store.-- [ ] No console errors; numbers trace to `/api/three-token/revenue-share` + `/api/wallet/balances`.--## Verification--1. `npm run dev`; open the rewards surface.-2. Connected holder: accrued share = position × yield, USD correct, "estimated/coming" labeling- present.-3. Signed-out and zero-balance states render their CTAs.-4. Confirm there is no network call or button that attempts a non-existent claim.-5. `npx vitest run` for any new tests.--## Rules--Obey [CLAUDE.md](../../CLAUDE.md). Only $THREE. **No fake claim.** Honesty over polish — label-estimates as estimates. Design every state.--## Completion protocol--1. Re-read your diff (`git diff`) and confirm every line is justified.-2. Delete this file: `tasks/week-2026-06-08/C5-rewards-surface.md`.-3. Commit your code **and** this file's deletion together, e.g.:- `git add -A && git commit -m "feat(holder): honest revenue-share accrual surface via shared store; close C5"`-4. Do **not** push — the human controls pushes.diff --git a/tests/api/x402-discovery-parity.test.js b/tests/api/x402-discovery-parity.test.jsnew file mode 100644index 000000000..2dc663260--- /dev/null+++ b/tests/api/x402-discovery-parity.test.js@@ -0,0 +1,124 @@+// Guardrail: every paid /api/x402/* endpoint must appear in the+// /.well-known/x402-discovery catalog, or agents (and the CDP Bazaar /+// agentic.market crawlers) can never find it — an unlisted paid endpoint earns+// zero, no matter how good it is. The discovery doc in api/wk.js is+// hand-maintained, so it silently drifts every time a new paid route ships+// without a matching catalog entry. This test makes that drift a red build.+//+// "Paid" is detected structurally: a route file is paid if it wraps the shared+// paidEndpoint() helper OR emits a 402 challenge directly via send402(). Pure+// utility/infra routes (did, my-receipts, pay-by-name — a tx-builder, not a+// 402-gated resource) match neither and are correctly out of scope.++import { describe, it, expect } from 'vitest';+import { readFileSync, readdirSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { dirname, join } from 'node:path';++const here = dirname(fileURLToPath(import.meta.url));+const x402Dir = join(here, '..', '..', 'api', 'x402');++// Routes intentionally absent from the catalog, with the reason each is exempt.+// Keep this list short and justified — it is the only sanctioned escape hatch.+const EXCLUSIONS = new Map([+ [+ '/api/x402/permit2-paid-demo',+ 'CDP-only: its sole accept is a Permit2 sibling that permit2VariantOf() ' ++ 'returns null for without CDP creds, so the live 402 (and thus the catalog) ' ++ 'catalog) omits the route entirely in non-CDP environments.',+ ],+]);++function paidRoutesFromFiles() {+ const routes = [];+ for (const name of readdirSync(x402Dir)) {+ if (!name.endsWith('.js')) continue;+ const src = readFileSync(join(x402Dir, name), 'utf8');+ const isPaid = src.includes('paidEndpoint(') || src.includes('send402(');+ if (!isPaid) continue;+ routes.push(`/api/x402/${name.replace(/\.js$/, '')}`);+ }+ return routes.sort();+}++async function renderDiscovery() {+ // Set the env the discovery builder reads BEFORE importing it, so both Base+ // and Solana accepts are advertised and APP_ORIGIN resolves. No CDP creds →+ // Permit2 siblings are omitted, matching production's non-CDP behavior.+ Object.assign(process.env, {+ APP_ORIGIN: 'https://three.ws',+ X402_PAY_TO_BASE: '0x0000000000000000000000000000000000000001',+ X402_PAY_TO_SOLANA: 'So11111111111111111111111111111111111111112',+ X402_ASSET_ADDRESS_BASE: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',+ X402_ASSET_MINT_SOLANA: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',+ X402_ASSET_ADDRESS_ARBITRUM: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',+ X402_MAX_AMOUNT_REQUIRED: '1000',+ X402_FEE_PAYER_SOLANA: 'So11111111111111111111111111111111111111112',+ });+ const mod = await import('../../api/wk.js');+ const res = {+ statusCode: 0,+ headers: {},+ setHeader(k, v) {+ this.headers[k.toLowerCase()] = v;+ },+ end(body) {+ this.body = body;+ },+ };+ const req = {+ method: 'GET',+ url: '/.well-known/x402-discovery?name=x402-discovery',+ query: { name: 'x402-discovery' },+ headers: {},+ };+ await mod.default(req, res);+ return JSON.parse(res.body);+}++describe('x402 discovery catalog parity', () => {+ it('lists every paid /api/x402/* endpoint (no silent drift)', async () => {+ const doc = await renderDiscovery();+ const cataloged = new Set(doc.resources.map((r) => r.path));+ const required = paidRoutesFromFiles().filter((r) => !EXCLUSIONS.has(r));++ const missing = required.filter((r) => !cataloged.has(r));+ expect(+ missing,+ `Paid x402 endpoints missing from /.well-known/x402-discovery: ${missing.join(+ ', ',+ )}. Add a matching resources[] entry in api/wk.js handleX402Discovery, ` ++ `or document an exemption in EXCLUSIONS with a reason.`,+ ).toEqual([]);+ });++ it('only exempts routes that still exist as paid endpoints', async () => {+ // Stops EXCLUSIONS from rotting: an exemption for a deleted/renamed route+ // would otherwise hide a real gap forever.+ const paid = new Set(paidRoutesFromFiles());+ const stale = [...EXCLUSIONS.keys()].filter((r) => !paid.has(r));+ expect(+ stale,+ `Stale EXCLUSIONS entries (route no longer paid): ${stale.join(', ')}`,+ ).toEqual([]);+ });++ it('every cataloged x402 resource carries a price and at least one accept', async () => {+ const doc = await renderDiscovery();+ const x402Resources = doc.resources.filter((r) => r.path?.startsWith('/api/x402/'));+ expect(x402Resources.length).toBeGreaterThan(0);+ for (const r of x402Resources) {+ expect(+ Array.isArray(r.accepts) && r.accepts.length > 0,+ `${r.path} has no accepts`,+ ).toBe(true);+ for (const a of r.accepts) {+ expect(+ typeof a.amount === 'string' && a.amount.length > 0,+ `${r.path} accept amount`,+ ).toBe(true);+ expect(Boolean(a.payTo), `${r.path} accept payTo`).toBe(true);+ }+ }+ });+});