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
feat(x402): route Base mainnet through Coinbase CDP facilitator
nirholas691b7b1edd01
diff --git a/.gitignore b/.gitignoreindex ffad161c6..aa7513395 100644--- a/.gitignore+++ b/.gitignore@@ -47,6 +47,8 @@ experiments/*/build# Reference repo clones (read-only)forks/*/.env.production+.env.preview+.env.development# Solana keypair files — NEVER commit*-vanity.jsondiff --git a/api/_lib/env.js b/api/_lib/env.jsindex 229c9706f..c06a6a5a2 100644--- a/api/_lib/env.js+++ b/api/_lib/env.js@@ -145,7 +145,7 @@ export const env = {get X402_PAY_TO_SOLANA() {return opt('X402_PAY_TO_SOLANA',- opt('X402_PAY_TO', 'BUrwd1nK6tFeeJMyzRHDo6AuVbnSfUULfvwq21X93nSN'),+ opt('X402_PAY_TO', 'wwwPqsM4N7T9J69tB82nLyzxqsH159j4orftLTQfUGV'),);},get X402_PAY_TO_BASE() {@@ -190,6 +190,21 @@ export const env = {get X402_FACILITATOR_TOKEN_BASE() {return opt('X402_FACILITATOR_TOKEN_BASE', opt('X402_FACILITATOR_TOKEN'));},+ // Coinbase Developer Platform x402 facilitator. When both keys are set,+ // Base-mainnet payments route through CDP (required for CDP Bazaar /+ // agentic.market listing — only endpoints whose first verify+settle is+ // processed by CDP get cataloged). Solana keeps routing to PayAI.+ get CDP_API_KEY_ID() {+ return opt('CDP_API_KEY_ID');+ },+ get CDP_API_KEY_SECRET() {+ return opt('CDP_API_KEY_SECRET');+ },+ get X402_CDP_FACILITATOR_URL() {+ return trimSlash(+ opt('X402_CDP_FACILITATOR_URL', 'https://api.cdp.coinbase.com/platform/v2/x402'),+ );+ },// Solana fee payer advertised in the 402 challenge's `extra.feePayer`.// Clients build the SPL transfer with this account paying SOL fees; the// facilitator co-signs on /settle. Must match whatever facilitator.payai.networkdiff --git a/api/_lib/x402-spec.js b/api/_lib/x402-spec.jsindex 53b181b6d..49df2f139 100644--- a/api/_lib/x402-spec.js+++ b/api/_lib/x402-spec.js@@ -31,6 +31,8 @@// 5. Server POSTs facilitator /settle (same body) → { success, transaction, network, payer }// Server attaches a base64 settlement object as `X-PAYMENT-RESPONSE` on the success reply.+import { createAuthHeader as createCdpAuthHeader } from '@coinbase/x402';+import { env } from './env.js';export const X402_VERSION = 2;@@ -97,11 +99,34 @@ function facilitatorFor(network) {network === 'solana')return { url: env.X402_FACILITATOR_URL_SOLANA, token: env.X402_FACILITATOR_TOKEN_SOLANA };- if (network === NETWORK_BASE_MAINNET || network === NETWORK_BASE_SEPOLIA || network === 'base')+ if (network === NETWORK_BASE_MAINNET || network === NETWORK_BASE_SEPOLIA || network === 'base') {+ // Route Base mainnet through Coinbase's CDP facilitator when credentials+ // are configured — CDP Bazaar/agentic.market only catalogs endpoints+ // whose first verify+settle is processed by CDP. Fall back to PayAI+ // (or whatever X402_FACILITATOR_URL_BASE points at) otherwise.+ if (env.CDP_API_KEY_ID && env.CDP_API_KEY_SECRET) {+ return { url: env.X402_CDP_FACILITATOR_URL, cdp: true };+ }return { url: env.X402_FACILITATOR_URL_BASE, token: env.X402_FACILITATOR_TOKEN_BASE };+ }throw new X402Error('unsupported_network', `unsupported network: ${network}`, 400);}+async function authHeaderFor(config, method, fullUrl) {+ if (config.cdp) {+ const u = new URL(fullUrl);+ return createCdpAuthHeader(+ env.CDP_API_KEY_ID,+ env.CDP_API_KEY_SECRET,+ method,+ u.host,+ u.pathname,+ );+ }+ if (config.token) return `Bearer ${config.token}`;+ return null;+}+function decodePaymentHeader(header) {if (!header) throw new X402Error('payment_required', 'X-PAYMENT header required', 402);let json;@@ -135,11 +160,12 @@ function hostOf(url) {}async function callFacilitator(network, path, body) {- const { url: base, token } = facilitatorFor(network);- const url = `${base}${path}`;- const host = hostOf(base);+ const config = facilitatorFor(network);+ const url = `${config.url}${path}`;+ const host = hostOf(config.url);const headers = { 'content-type': 'application/json', accept: 'application/json' };- if (token) headers.authorization = `Bearer ${token}`;+ const auth = await authHeaderFor(config, 'POST', url);+ if (auth) headers.authorization = auth;let res;try {res = await fetch(url, {@@ -206,7 +232,8 @@ export async function probeFacilitators() {try {const probeUrl = `${t.url}/supported`;const headers = { accept: 'application/json' };- if (t.token) headers.authorization = `Bearer ${t.token}`;+ const auth = await authHeaderFor(t, 'GET', probeUrl);+ if (auth) headers.authorization = auth;const res = await fetch(probeUrl, {headers,signal: AbortSignal.timeout(10_000),