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 spec refinements and skill-call payment plumbing
nirholas0fd0b51eefd6
diff --git a/api/_lib/x402-paid-endpoint.js b/api/_lib/x402-paid-endpoint.jsindex 583b4146e..b1fbe7811 100644--- a/api/_lib/x402-paid-endpoint.js+++ b/api/_lib/x402-paid-endpoint.js@@ -219,7 +219,10 @@ export function paidEndpoint(spec) {route,method = 'GET',priceAtomics = env.X402_MAX_AMOUNT_REQUIRED,- networks = ['base', 'solana'],+ // Solana-first platform default: the live 402 challenge lists Solana+ // before Base so first-accept clients/modals settle on Solana unless a+ // route explicitly overrides the network order.+ networks = ['solana', 'base'],description,mimeType = 'application/json',bazaar,diff --git a/api/_lib/x402-spec.js b/api/_lib/x402-spec.jsindex 253800ea1..c147e25b1 100644--- a/api/_lib/x402-spec.js+++ b/api/_lib/x402-spec.js@@ -159,18 +159,9 @@ export function paymentRequirements(resourceUrl, { amount } = {}) {...(resourceUrl ? { resource: resourceUrl } : {}),};const out = [];- if (env.X402_PAY_TO_BASE) {- pushEvmAccepts(out, {- ...common,- network: NETWORK_BASE_MAINNET,- payTo: env.X402_PAY_TO_BASE,- asset: env.X402_ASSET_ADDRESS_BASE,- // `name` MUST match the on-chain EIP-712 domain. Base USDC's domain- // name is "USD Coin" (not "USDC"); using "USDC" here makes the- // facilitator recompute the wrong domain hash → invalid signature.- extra: { name: 'USD Coin', version: '2', decimals: 6 },- });- }+ // Solana-first platform default: the Solana accept leads so first-accept+ // clients and the payment modal settle on Solana unless the caller picks+ // another network explicitly. Base/BSC follow as alternatives.if (env.X402_PAY_TO_SOLANA) {out.push({...common,@@ -198,6 +189,18 @@ export function paymentRequirements(resourceUrl, { amount } = {}) {});}}+ if (env.X402_PAY_TO_BASE) {+ pushEvmAccepts(out, {+ ...common,+ network: NETWORK_BASE_MAINNET,+ payTo: env.X402_PAY_TO_BASE,+ asset: env.X402_ASSET_ADDRESS_BASE,+ // `name` MUST match the on-chain EIP-712 domain. Base USDC's domain+ // name is "USD Coin" (not "USDC"); using "USDC" here makes the+ // facilitator recompute the wrong domain hash → invalid signature.+ extra: { name: 'USD Coin', version: '2', decimals: 6 },+ });+ }if (env.X402_PAY_TO_BSC) {// BSC uses the contract-mediated "direct" scheme — see x402-bsc-direct.js// for the wire flow. Clients call ThreeWSPayments.pay(ref) themselves anddiff --git a/api/_mcpagent/tools.js b/api/_mcpagent/tools.jsindex da0a955b2..02816e4e9 100644--- a/api/_mcpagent/tools.js+++ b/api/_mcpagent/tools.js@@ -457,7 +457,7 @@ export const toolDefs = [type: 'object',description: 'Optional JSON Schema for the request body.',},- network: { type: 'string', enum: ['base', 'solana'], default: 'base' },+ network: { type: 'string', enum: ['solana', 'base'], default: 'solana' },},required: ['agent_id', 'name', 'description', 'price_usdc', 'target_url'],additionalProperties: false,diff --git a/api/wk.js b/api/wk.jsindex 1455675e7..af5ddefd2 100644--- a/api/wk.js+++ b/api/wk.js@@ -294,34 +294,36 @@ function extensionsForAccepts(accepts, bazaar) {function acceptsForPrice(amountAtomics, resourceUrl) {const out = [];const price = RAW_AMOUNT_TO_USDC(amountAtomics);- if (env.X402_PAY_TO_BASE) {- pushAcceptWithPermit2Sibling(out, {+ // Solana-first platform default — the Solana accept leads so first-accept+ // clients and marketplaces treat it as the primary rail; Base follows.+ if (env.X402_PAY_TO_SOLANA) {+ out.push({scheme: 'exact',- network: NETWORK_BASE_MAINNET,- network_label: 'base-mainnet',+ network: NETWORK_SOLANA_MAINNET,+ network_label: 'solana-mainnet',amount: String(amountAtomics),price,- payTo: env.X402_PAY_TO_BASE,- asset: env.X402_ASSET_ADDRESS_BASE,+ payTo: env.X402_PAY_TO_SOLANA,+ asset: env.X402_ASSET_MINT_SOLANA,asset_symbol: 'USDC',maxTimeoutSeconds: 60,resource: resourceUrl,- extra: { name: 'USD Coin', version: '2', decimals: 6 },+ extra: { name: 'USDC', decimals: 6, feePayer: env.X402_FEE_PAYER_SOLANA },});}- if (env.X402_PAY_TO_SOLANA) {- out.push({+ if (env.X402_PAY_TO_BASE) {+ pushAcceptWithPermit2Sibling(out, {scheme: 'exact',- network: NETWORK_SOLANA_MAINNET,- network_label: 'solana-mainnet',+ network: NETWORK_BASE_MAINNET,+ network_label: 'base-mainnet',amount: String(amountAtomics),price,- payTo: env.X402_PAY_TO_SOLANA,- asset: env.X402_ASSET_MINT_SOLANA,+ payTo: env.X402_PAY_TO_BASE,+ asset: env.X402_ASSET_ADDRESS_BASE,asset_symbol: 'USDC',maxTimeoutSeconds: 60,resource: resourceUrl,- extra: { name: 'USDC', decimals: 6, feePayer: env.X402_FEE_PAYER_SOLANA },+ extra: { name: 'USD Coin', version: '2', decimals: 6 },});}return out;@@ -489,6 +491,22 @@ async function handleX402Discovery(req, res) {// resource it gates without walking back to the parent resource[] entry.function buildMcpAccepts(resourceUrl) {const out = [];+ // Solana-first platform default — Solana leads, Base follows.+ if (env.X402_PAY_TO_SOLANA) {+ out.push({+ scheme: 'exact',+ network: NETWORK_SOLANA_MAINNET,+ network_label: 'solana-mainnet',+ amount: env.X402_MAX_AMOUNT_REQUIRED,+ price,+ payTo: env.X402_PAY_TO_SOLANA,+ asset: env.X402_ASSET_MINT_SOLANA,+ asset_symbol: 'USDC',+ maxTimeoutSeconds: 60,+ resource: resourceUrl,+ extra: { name: 'USDC', decimals: 6, feePayer: env.X402_FEE_PAYER_SOLANA },+ });+ }if (env.X402_PAY_TO_BASE) {pushAcceptWithPermit2Sibling(out, {scheme: 'exact',@@ -504,6 +522,20 @@ async function handleX402Discovery(req, res) {extra: { name: 'USDC', version: '2', decimals: 6 },});}+ return out;+ }++ // model-check / mint-to-mesh / revenue-vision are CDP-Bazaar-cataloged.+ // CDP supports Base mainnet + Arbitrum One; advertise both here so+ // agentic.market shows the same network options buyers will see in the+ // live 402 challenge. Each EVM entry gets a Permit2 sibling so+ // EIP-2612-aware clients can pick the gasless Permit2-via-EIP-2612 path.+ const ARB_USDC = env.X402_ASSET_ADDRESS_ARBITRUM;+ function buildBazaarAccepts(resourceUrl) {+ const out = [];+ // Solana-first platform default — Solana leads the catalog entry. The+ // Base + Arbitrum accepts still follow so CDP keeps processing an EVM+ // verify+settle for agentic.market cataloging.if (env.X402_PAY_TO_SOLANA) {out.push({scheme: 'exact',@@ -519,17 +551,6 @@ async function handleX402Discovery(req, res) {extra: { name: 'USDC', decimals: 6, feePayer: env.X402_FEE_PAYER_SOLANA },});}- return out;- }-- // model-check / mint-to-mesh / revenue-vision are CDP-Bazaar-cataloged.- // CDP supports Base mainnet + Arbitrum One; advertise both here so- // agentic.market shows the same network options buyers will see in the- // live 402 challenge. Each EVM entry gets a Permit2 sibling so- // EIP-2612-aware clients can pick the gasless Permit2-via-EIP-2612 path.- const ARB_USDC = env.X402_ASSET_ADDRESS_ARBITRUM;- function buildBazaarAccepts(resourceUrl) {- const out = [];if (env.X402_PAY_TO_BASE) {pushAcceptWithPermit2Sibling(out, {scheme: 'exact',@@ -560,21 +581,6 @@ async function handleX402Discovery(req, res) {extra: { name: 'USDC', version: '2', decimals: 6 },});}- if (env.X402_PAY_TO_SOLANA) {- out.push({- scheme: 'exact',- network: NETWORK_SOLANA_MAINNET,- network_label: 'solana-mainnet',- amount: env.X402_MAX_AMOUNT_REQUIRED,- price,- payTo: env.X402_PAY_TO_SOLANA,- asset: env.X402_ASSET_MINT_SOLANA,- asset_symbol: 'USDC',- maxTimeoutSeconds: 60,- resource: resourceUrl,- extra: { name: 'USDC', decimals: 6, feePayer: env.X402_FEE_PAYER_SOLANA },- });- }return out;}diff --git a/api/x402/skill-call.js b/api/x402/skill-call.jsindex 6ef6a512d..363d108ad 100644--- a/api/x402/skill-call.js+++ b/api/x402/skill-call.js@@ -159,10 +159,12 @@ export default async function handler(req, res) {const payTo = {};if (skill.author_payto_base) payTo.base = skill.author_payto_base;if (skill.author_payto_solana) payTo.solana = skill.author_payto_solana;+ // Solana-first platform default: advertise Solana ahead of Base so+ // first-accept clients settle on Solana when the author supports both.const networks = [];- if (payTo.base) networks.push('base');if (payTo.solana) networks.push('solana');- if (!networks.length) networks.push('base', 'solana'); // platform fallback+ if (payTo.base) networks.push('base');+ if (!networks.length) networks.push('solana', 'base'); // platform fallbackconst priceAtomics = priceFor(`skill-call-${slug}`, usdToAtomics(skill.price_per_call_usd));diff --git a/public/x402.js b/public/x402.jsindex f01c13b7f..63fdb4be0 100644--- a/public/x402.js+++ b/public/x402.js@@ -1291,13 +1291,15 @@ class CheckoutModal {this.siwx = extractSiwxExtension(challenge);this.payFlowOverride = false;this.siwxFallbackNotice = null;- // Prefer Solana when Phantom is present, else first EIP-3009 EVM- // entry (skipping Permit2 siblings the modal can't sign for), else- // first accept.+ // Solana-first platform default: select the Solana accept by default+ // whenever one is offered, regardless of which wallet is detected —+ // renderConnect() still shows both wallet buttons (Solana listed+ // first), so EVM users simply click the EVM option. Falls back to the+ // first EIP-3009 EVM entry (skipping Permit2 siblings the modal can't+ // sign for), then the first accept.const solana = challenge.accepts.find((a) => isSolanaNetwork(a.network));const evm = challenge.accepts.find(isEip3009Accept);- const phantomDetected = typeof window !== 'undefined' && (window.solana?.isPhantom || window.phantom?.solana);- this.accept = (phantomDetected && solana) || evm || challenge.accepts[0];+ this.accept = solana || evm || challenge.accepts[0];this.setPrice(this.accept);this.renderConnect();} catch (err) {diff --git a/src/editor/launchpad-studio.js b/src/editor/launchpad-studio.jsindex e6bc5be54..9cef48dcc 100644--- a/src/editor/launchpad-studio.js+++ b/src/editor/launchpad-studio.js@@ -36,7 +36,7 @@ const TEMPLATES = [label: 'Paid Concierge',tagline: '3D avatar that answers questions for x402 USDC',hint: 'A hosted agent page that charges a per-question fee via x402. Replies stream from the configured agent skill.',- monetize: { kind: 'x402-call', defaultPrice: 0.01, currency: 'USDC', chain: 'base' },+ monetize: { kind: 'x402-call', defaultPrice: 0.01, currency: 'USDC', chain: 'solana' },defaultCta: 'Ask the concierge',defaultTagline: 'Get an answer from the team in 5 seconds — paid in USDC.',},@@ -45,7 +45,7 @@ const TEMPLATES = [label: 'Gated 3D Showroom',tagline: 'Pay-to-enter glTF gallery with avatar greeter',hint: 'Visitors pay a small USDC fee to unlock a private 3D scene. Use for product reveals, premium models, or NFT preview rooms.',- monetize: { kind: 'x402-unlock', defaultPrice: 0.05, currency: 'USDC', chain: 'base' },+ monetize: { kind: 'x402-unlock', defaultPrice: 0.05, currency: 'USDC', chain: 'solana' },defaultCta: 'Unlock the room',defaultTagline: 'Step inside a private 3D space — one-time USDC pass.',},@@ -975,7 +975,7 @@ export function mountLaunchpadStudio(root, options = {}) {return;}if (action === 'add-skill') {- state.agentSkills.push({ name: '', price: 0.001, currency: 'USDC', chain: 'base', description: '' });+ state.agentSkills.push({ name: '', price: 0.001, currency: 'USDC', chain: 'solana', description: '' });render();return;}diff --git a/x402-modal-sdk/src/x402-modal.js b/x402-modal-sdk/src/x402-modal.jsindex 60acb0d63..b6bcc7613 100644--- a/x402-modal-sdk/src/x402-modal.js+++ b/x402-modal-sdk/src/x402-modal.js@@ -840,12 +840,15 @@ export class CheckoutModal {this.siwx = extractSiwxExtension(challenge);this.payFlowOverride = false;this.siwxFallbackNotice = null;- // Prefer Solana when Phantom is present, else first EIP-3009 EVM entry- // (skipping Permit2 siblings the modal can't sign for), else first accept.+ // Solana-first platform default: select the Solana accept by default+ // whenever one is offered, regardless of which wallet is detected —+ // renderConnect() still shows both wallet buttons (Solana listed+ // first), so EVM users simply click the EVM option. Falls back to the+ // first EIP-3009 EVM entry (skipping Permit2 siblings the modal can't+ // sign for), then the first accept.const solana = challenge.accepts.find((a) => isSolanaNetwork(a.network));const evm = challenge.accepts.find(isEip3009Accept);- const phantomDetected = typeof window !== 'undefined' && (window.solana?.isPhantom || window.phantom?.solana);- this.accept = (phantomDetected && solana) || evm || challenge.accepts[0];+ this.accept = solana || evm || challenge.accepts[0];this.setPrice(this.accept);this.renderConnect();} catch (err) {