Skip to content

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.

feat: x402-payment-modal tests/types + release script, walk-sdk README, page wiring updates

nirholas95e379967b58
diff --git a/STRUCTURE.md b/STRUCTURE.md
index 204d06f2c..122e8e362 100644
--- a/STRUCTURE.md
+++ b/STRUCTURE.md
@@ -15,6 +15,7 @@ bottom.
| Surface | Location | Status | Notes |
|---|---|---|---|
| Web renderer / viewer | [avatar-sdk/](avatar-sdk) `→ /viewer` | Published as `@three-ws/avatar` | `<agent-3d>` web component |
+| Walk companion + playground | [walk-sdk/](walk-sdk) `→ /walk-companion.js` | Published as `@three-ws/walk` | Corner mascot + full-page stroll/platformer playground + diverse avatar picker. App entries: [src/walk-companion.js](src/walk-companion.js), [src/walk-playground.js](src/walk-playground.js) |
| React avatar creator | [avatar-sdk/](avatar-sdk) `→ /react` `/creator` | Published as `@three-ws/avatar` | Same package, React subpath |
| Talking page guide | [page-agent-sdk/](page-agent-sdk) | Published as `@three-ws/page-agent` | Drop-in rigged 3D agent that narrates any page + visitor avatar picker. `<page-agent>` web component. Rigged-only catalog. See [page-agent-sdk/PUBLISHING.md](page-agent-sdk/PUBLISHING.md) |
| Avatar builder (full app) | [character-studio/](character-studio) | Fork of [m3-org/CharacterStudio](https://github.com/M3-org/CharacterStudio), MIT, see [character-studio/LICENSE](character-studio/LICENSE) | Web-first character creator |
@@ -53,6 +54,7 @@ packages/ibm-watsonx-mcp/ → @three-ws/ibm-watsonx-mcp (MCP server — IB
packages/ibm-x402-mcp/ → @three-ws/ibm-x402-mcp (MCP server — IBM x402 payments)
packages/three-token-mcp/ → @three-ws/three-token-mcp (MCP server — $THREE token tools)
packages/threews-avatar-mcp/ → @three-ws/threews-avatar-mcp (MCP server — three.ws avatar ops)
+walk-sdk/ → @three-ws/walk (page walking companion + playground + avatar picker)
```
`packages/*` is the home for clean, publishable spec/schema/preset packages
diff --git a/api/_lib/coin-communities.js b/api/_lib/coin-communities.js
index 711660b21..6590913f9 100644
--- a/api/_lib/coin-communities.js
+++ b/api/_lib/coin-communities.js
@@ -1,6 +1,6 @@
// CoinCommunities server-side client — the ONLY place the API key lives.
//
-// Each coin on three.ws is its own 3D world (/walk?coin=<mint>); its
+// Each coin on three.ws is its own 3D world (/temporary?coin=<mint>); its
// CoinCommunities community is that world's live social layer. The browser
// never sees the API key: it talks to the api/community/* proxy, which calls
// CoinCommunities with the key held here. Realtime works the same way — the
diff --git a/api/community/worlds.js b/api/community/worlds.js
index f68272767..462ea5fb7 100644
--- a/api/community/worlds.js
+++ b/api/community/worlds.js
@@ -1,6 +1,6 @@
// GET /api/community/worlds
// The lobby of live coin-worlds. Each TopCommunity becomes an enterable 3D
-// world on /walk?coin=<token>. Real data — most active communities first.
+// world on /temporary?coin=<token>. Real data — most active communities first.
import { cors, error, json, method, wrap, rateLimited } from '../_lib/http.js';
import { clientIp, limits } from '../_lib/rate-limit.js';
import { cc, toWorldCard, UnconfiguredError } from '../_lib/coin-communities.js';
diff --git a/api/feature-og.js b/api/feature-og.js
index 38fd1f25b..005b072b5 100644
--- a/api/feature-og.js
+++ b/api/feature-og.js
@@ -32,7 +32,7 @@ const FEATURE_META = {
},
walk: {
label: 'Walk',
- route: '/walk',
+ route: '/temporary',
accent: '#fb923c',
icon: '◉',
tagline: '3D Avatar + AR',
diff --git a/data/changelog.json b/data/changelog.json
index 965395a40..09d83c4d4 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,15 @@
{
"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-06-19",
+ "title": "Walk mode moves to three.ws/temporary",
+ "summary": "The drive-your-avatar walk demo — joystick or WASD movement, AR back-camera passthrough, and the live coin-world mainland — now lives at three.ws/temporary. Every link across the site already points to the new path, and avatar deep-links (three.ws/wk/…) follow along. The old /walk address is freed up for what's coming next.",
+ "tags": [
+ "improvement"
+ ],
+ "link": "/temporary"
+ },
{
"date": "2026-06-19",
"title": "Forge a 3D model on the IBM x402 demo — free, no wallet",
@@ -1483,7 +1492,7 @@
"fix",
"improvement"
],
- "link": "/walk"
+ "link": "/temporary"
},
{
"date": "2026-06-17",
@@ -3424,7 +3433,7 @@
"feature",
"improvement"
],
- "link": "/walk"
+ "link": "/temporary"
},
{
"date": "2026-06-13",
diff --git a/data/pages.json b/data/pages.json
index c39611300..14be698ad 100644
--- a/data/pages.json
+++ b/data/pages.json
@@ -47,7 +47,7 @@
"added": "2026-06-17"
},
{
- "path": "/walk",
+ "path": "/temporary",
"title": "Walk",
"description": "Drive a 3D avatar around with a joystick or WASD — toggle the back camera for AR-style passthrough.",
"priority": 0.7,
diff --git a/pages/autopilot.html b/pages/autopilot.html
index 3e6a8711a..b82a188eb 100644
--- a/pages/autopilot.html
+++ b/pages/autopilot.html
@@ -190,7 +190,7 @@
<a href="/discover">Discover</a>
<a href="/pump-dashboard">Coins</a>
<a href="/autopilot" class="active">Autopilot</a>
- <a href="/walk">Walk</a>
+ <a href="/temporary">Walk</a>
</div>
<div class="nav-end"><a href="/dashboard">Dashboard</a></div>
</div>
diff --git a/pages/communities.html b/pages/communities.html
index bda9a120e..ad1138960 100644
--- a/pages/communities.html
+++ b/pages/communities.html
@@ -261,7 +261,7 @@
<header class="topbar">
<a class="brand" href="/"><span class="dot"></span>three.ws</a>
<nav>
- <a href="/walk">Mainland</a>
+ <a href="/temporary">Mainland</a>
<a href="/create">Create avatar</a>
</nav>
</header>
diff --git a/pages/embed-walk.html b/pages/embed-walk.html
index e2e95c129..e3aa1906c 100644
--- a/pages/embed-walk.html
+++ b/pages/embed-walk.html
@@ -288,7 +288,7 @@
</a>
<span class="ew-topbar-sep">/</span>
<span class="ew-topbar-title">Walk Embed Generator</span>
- <a href="/walk" class="ew-topbar-back">← Back to Walk</a>
+ <a href="/temporary" class="ew-topbar-back">← Back to Walk</a>
</nav>
<div class="ew-layout">
diff --git a/pages/fact-checker.html b/pages/fact-checker.html
index 3362f1f17..99738bd92 100644
--- a/pages/fact-checker.html
+++ b/pages/fact-checker.html
@@ -916,7 +916,7 @@
<nav class="nav-main" aria-label="Primary">
<a href="/discover">Discover</a>
<a href="/marketplace">Marketplace</a>
- <a href="/walk">Walk</a>
+ <a href="/temporary">Walk</a>
<a href="/fact-checker" class="active">Fact Checker</a>
</nav>
<div class="nav-end">
diff --git a/pages/features.html b/pages/features.html
index c319352ca..3eddd203b 100644
--- a/pages/features.html
+++ b/pages/features.html
@@ -556,7 +556,7 @@
browser with real physics (Rapier) and real terrain, not a flat
plane.
</p>
- <a href="/walk" class="btn-primary feat-card-cta">
+ <a href="/temporary" class="btn-primary feat-card-cta">
Start walking <span class="btn-arrow">→</span>
</a>
</div>
diff --git a/pages/home.html b/pages/home.html
index 619d2a683..05aac17f6 100644
--- a/pages/home.html
+++ b/pages/home.html
@@ -4378,7 +4378,7 @@
<li><strong>One embed tag</strong> — same <code>&lt;walk-embed&gt;</code> tag, zero backend setup</li>
</ul>
<div>
- <a class="btn btn--sm" href="/walk">See walk mode <span class="arrow">→</span></a>
+ <a class="btn btn--sm" href="/temporary">See walk mode <span class="arrow">→</span></a>
</div>
</div>
<div class="feat-visual walk-preview-visual">
@@ -4619,7 +4619,7 @@
<span class="stack-card-desc">HTTP-native USDC micropayments. Bill per skill, message, or session. 0% platform fee during open beta.</span>
<span class="stack-card-arrow">↗</span>
</a>
- <a href="/walk" class="stack-card">
+ <a href="/temporary" class="stack-card">
<span class="stack-card-num">05</span>
<span class="stack-card-title">Walk</span>
<span class="stack-card-desc">Multiplayer 3D worlds. CRDT-synced avatar positions, spatial voice, joystick control — in one embed tag.</span>
diff --git a/pages/irl.html b/pages/irl.html
index 432fbef4c..1033f6d4b 100644
--- a/pages/irl.html
+++ b/pages/irl.html
@@ -1839,7 +1839,7 @@
<!-- Top bar -->
<header class="irl-topbar">
- <a class="irl-back" id="irl-back-link" href="/walk">
+ <a class="irl-back" id="irl-back-link" href="/temporary">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>
Back
</a>
diff --git a/pages/unstoppable.html b/pages/unstoppable.html
index 2a00d4898..bae00e0d2 100644
--- a/pages/unstoppable.html
+++ b/pages/unstoppable.html
@@ -476,7 +476,7 @@
<div class="nav-main">
<a href="/discover">Discover</a>
<a href="/marketplace">Marketplace</a>
- <a href="/walk">Walk</a>
+ <a href="/temporary">Walk</a>
<a href="/unstoppable" class="active">Unstoppable Agent</a>
</div>
<div class="nav-end">
diff --git a/pages/walk.html b/pages/walk.html
index 105719c9b..2c596c395 100644
--- a/pages/walk.html
+++ b/pages/walk.html
@@ -40,7 +40,7 @@
<meta property="og:site_name" content="three.ws" />
<meta property="og:title" content="Walk · three.ws" />
<meta property="og:description" content="A 3D avatar you can walk around — in the browser and in AR." />
- <meta property="og:url" content="https://three.ws/walk" />
+ <meta property="og:url" content="https://three.ws/temporary" />
<meta property="og:image" id="og-image" content="https://three.ws/api/walk-og" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Walk · three.ws" />
@@ -1045,8 +1045,8 @@
</style>
<link rel="stylesheet" href="/nav.css" />
- <link rel="canonical" href="https://three.ws/walk">
- <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Walk","description":"Drive a 3D avatar around with a joystick or WASD — toggle the back camera for AR-style passthrough.","url":"https://three.ws/walk","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+ <link rel="canonical" href="https://three.ws/temporary">
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Walk","description":"Drive a 3D avatar around with a joystick or WASD — toggle the back camera for AR-style passthrough.","url":"https://three.ws/temporary","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
<meta property="og:locale" content="en_US">
diff --git a/pages/worlds.html b/pages/worlds.html
index 1284265fb..e9a44a47b 100644
--- a/pages/worlds.html
+++ b/pages/worlds.html
@@ -690,7 +690,7 @@
<span>/ worlds</span>
</div>
<span class="wl-top-spacer"></span>
- <a class="wl-top-link" href="/walk">Open mainland</a>
+ <a class="wl-top-link" href="/temporary">Open mainland</a>
<a class="wl-top-link" href="/create">Make an avatar</a>
</div>
diff --git a/pages/xr.html b/pages/xr.html
index 2e934e404..040cc1818 100644
--- a/pages/xr.html
+++ b/pages/xr.html
@@ -377,7 +377,7 @@
<!-- Top bar -->
<div id="xr-topbar">
- <a href="/walk" class="xr-back" aria-label="Back">
+ <a href="/temporary" class="xr-back" aria-label="Back">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
<path d="M10 3L5 8l5 5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
diff --git a/public/x402.js b/public/x402.js
index 48709ea23..316567254 100644
--- a/public/x402.js
+++ b/public/x402.js
@@ -24,6 +24,7 @@
// body: { text: 'hello' },
// merchant: 'Acme',
// action: 'Summarize',
+// networks: ['solana'], // optional allowlist — force a Solana-only checkout
// });
//
// The modal handles wallet connect (Phantom for Solana, window.ethereum for
@@ -93,6 +94,23 @@ function isEip3009Accept(accept) {
const method = accept?.extra?.assetTransferMethod;
return !method || method === 'eip3009';
}
+// Opt-in allowlist (opts.networks). When a caller restricts which networks the
+// modal may offer (e.g. ['solana'] to force a Solana-only checkout), drop every
+// accept outside the allowlist before the picker renders. Families: 'solana' /
+// 'svm' match any solana:* network, 'evm' matches any eip155:*, or pass an exact
+// CAIP id like 'eip155:8453'. If the filter would empty the list we keep the
+// original accepts so a misconfigured allowlist never breaks a live checkout.
+function filterAcceptsByNetwork(challenge, networks) {
+ if (!challenge || !Array.isArray(challenge.accepts) || !Array.isArray(networks) || !networks.length) return challenge;
+ const want = networks.map((n) => String(n).toLowerCase());
+ const allowed = (net) => want.some((w) => {
+ if (w === 'solana' || w === 'svm') return isSolanaNetwork(net);
+ if (w === 'evm') return isEvmNetwork(net);
+ return typeof net === 'string' && net.toLowerCase() === w;
+ });
+ const kept = challenge.accepts.filter((a) => a && allowed(a.network));
+ return kept.length ? { ...challenge, accepts: kept } : challenge;
+}
function networkLabel(net, accept) {
if (isSolanaNetwork(net)) return 'Solana';
const meta = EVM_NETWORKS[net];
@@ -934,7 +952,7 @@ class CheckoutModal {
this.bodyEl.innerHTML = this.renderSteps('discover');
try {
const challenge = await discoverChallenge(this.opts);
- this.challenge = challenge;
+ this.challenge = filterAcceptsByNetwork(challenge, this.opts.networks);
this.siwx = extractSiwxExtension(challenge);
this.payFlowOverride = false;
this.siwxFallbackNotice = null;
diff --git a/scripts/release-walk-sdk.mjs b/scripts/release-walk-sdk.mjs
new file mode 100644
index 000000000..545b63e6a
--- /dev/null
+++ b/scripts/release-walk-sdk.mjs
@@ -0,0 +1,141 @@
+#!/usr/bin/env node
+// Ship @three-ws/walk to npm and/or stage it for its own external repo.
+// =====================================================================
+// The package lives in the monorepo (walk-sdk/) and stays the source of truth.
+// This script handles the two ways it leaves the monorepo, per the promotion
+// path in STRUCTURE.md:
+//
+// 1. npm — build the self-contained dist and publish (the dist already
+// inlines the shared retargeting engine; only `three` stays a peer).
+// 2. repo — produce a STANDALONE copy of the source where the single seam
+// that reaches back into the monorepo (src/internal/runtime.js →
+// ../../../src/animation-manager.js) is replaced with a vendored
+// copy, so the result builds on its own. Then print the exact
+// `git subtree split` commands to push it to an external remote.
+//
+// Usage:
+// node scripts/release-walk-sdk.mjs # build + npm publish --dry-run (default, safe)
+// node scripts/release-walk-sdk.mjs --publish # actually `npm publish`
+// node scripts/release-walk-sdk.mjs --vendor <dir> # write a standalone source tree to <dir>
+// node scripts/release-walk-sdk.mjs --split <remote-url> # vendor + show subtree-split push commands
+
+import { execFileSync } from 'node:child_process';
+import {
+ cpSync,
+ mkdirSync,
+ readFileSync,
+ rmSync,
+ writeFileSync,
+ existsSync,
+} from 'node:fs';
+import { dirname, resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
+const pkgDir = resolve(repoRoot, 'walk-sdk');
+const args = process.argv.slice(2);
+const has = (flag) => args.includes(flag);
+const valueAfter = (flag) => {
+ const i = args.indexOf(flag);
+ return i >= 0 ? args[i + 1] : null;
+};
+
+function run(cmd, cmdArgs, cwd = repoRoot) {
+ console.log(`$ ${cmd} ${cmdArgs.join(' ')}`);
+ execFileSync(cmd, cmdArgs, { cwd, stdio: 'inherit' });
+}
+
+// ── 1. Build the publishable dist ─────────────────────────────────────────────
+function build() {
+ run('npm', ['run', 'build', '--prefix', 'walk-sdk']);
+ const dist = resolve(pkgDir, 'dist', 'index.mjs');
+ if (!existsSync(dist)) throw new Error('build did not produce dist/index.mjs');
+ console.log('✓ built walk-sdk/dist');
+}
+
+// ── 2. npm publish ────────────────────────────────────────────────────────────
+function publish({ dryRun }) {
+ const flags = ['publish', '--access', 'public'];
+ if (dryRun) flags.push('--dry-run');
+ run('npm', flags, pkgDir);
+ console.log(dryRun ? '✓ dry-run publish OK (no --publish given)' : '✓ published @three-ws/walk');
+}
+
+// ── 3. Vendor the monorepo seam into a standalone source tree ──────────────────
+// runtime.js re-exports AnimationManager from ../../../src/animation-manager.js,
+// which in turn imports ./glb-canonicalize.js, ./animation-retarget.js and
+// ./shared/log.js. We copy all four into the standalone tree and rewrite the
+// imports to resolve locally, so the result has no link back to the monorepo.
+function vendor(targetDir) {
+ const dest = resolve(process.cwd(), targetDir);
+ console.log(`Staging standalone @three-ws/walk → ${dest}`);
+ rmSync(dest, { recursive: true, force: true });
+ mkdirSync(dest, { recursive: true });
+
+ for (const entry of ['src', 'types', 'README.md', 'LICENSE', 'package.json', 'build.mjs']) {
+ cpSync(resolve(pkgDir, entry), resolve(dest, entry), { recursive: true });
+ }
+
+ const vendorDir = resolve(dest, 'src/internal/vendored');
+ mkdirSync(vendorDir, { recursive: true });
+ // Full transitive closure of src/animation-manager.js (the only seam back
+ // into the monorepo). Keep this in sync if that graph grows.
+ const seamFiles = {
+ 'animation-manager.js': resolve(repoRoot, 'src/animation-manager.js'),
+ 'animation-retarget.js': resolve(repoRoot, 'src/animation-retarget.js'),
+ 'animation-canonical-rest.js': resolve(repoRoot, 'src/animation-canonical-rest.js'),
+ 'glb-canonicalize.js': resolve(repoRoot, 'src/glb-canonicalize.js'),
+ 'log.js': resolve(repoRoot, 'src/shared/log.js'),
+ };
+ for (const [name, srcPath] of Object.entries(seamFiles)) {
+ let code = readFileSync(srcPath, 'utf8');
+ // Rewrite the shared/log import to the flattened vendored copy.
+ code = code.replace(/from ['"]\.\/shared\/log\.js['"]/g, "from './log.js'");
+ writeFileSync(resolve(vendorDir, name), code);
+ }
+
+ // Replace the seam: runtime.js now re-exports the vendored copy.
+ writeFileSync(
+ resolve(dest, 'src/internal/runtime.js'),
+ `// Standalone build: the shared retargeting engine is vendored alongside.\n` +
+ `export { AnimationManager } from './vendored/animation-manager.js';\n`,
+ );
+
+ console.log('✓ vendored seam (animation-manager + retarget + canonicalize + log)');
+ console.log(` Next: cd ${dest} && npm install three && npm run build`);
+ return dest;
+}
+
+// ── 4. Subtree split guidance ─────────────────────────────────────────────────
+function splitGuidance(remote) {
+ console.log('\nTo push walk-sdk/ to its own repo, preserving history:\n');
+ console.log(' git subtree split --prefix=walk-sdk -b walk-sdk-split');
+ console.log(' cd .. && mkdir walk-sdk-repo && cd walk-sdk-repo');
+ console.log(' git init && git pull ../three.ws walk-sdk-split');
+ console.log(` git remote add origin ${remote || '<external-repo-url>'}`);
+ console.log(' git push -u origin main\n');
+ console.log('Then vendor the seam in the new repo (so it builds standalone):');
+ console.log(' node ../three.ws/scripts/release-walk-sdk.mjs --vendor .\n');
+ console.log('NOTE: an external repo must already exist; this script never creates remote repos.');
+}
+
+// ── Dispatch ──────────────────────────────────────────────────────────────────
+try {
+ const vendorTarget = valueAfter('--vendor');
+ const splitRemote = valueAfter('--split');
+
+ if (vendorTarget) {
+ vendor(vendorTarget);
+ } else if (has('--split')) {
+ build();
+ vendor(resolve(repoRoot, '..', 'walk-sdk-standalone'));
+ splitGuidance(splitRemote);
+ } else {
+ build();
+ publish({ dryRun: !has('--publish') });
+ console.log('\nFor an external repo, run with --split <remote-url>.');
+ }
+} catch (err) {
+ console.error('✗ release failed:', err.message);
+ process.exit(1);
+}
diff --git a/src/a-me.js b/src/a-me.js
index d962e059a..ae0fc3507 100644
--- a/src/a-me.js
+++ b/src/a-me.js
@@ -266,7 +266,7 @@ function renderAgentCards(host, agents, avatars) {
<a class="ame-btn small" href="/dashboard/monetize">Monetize</a>
</div>
<div class="ame-actions-row">
- ${avatarId ? `<a class="ame-btn ghost small" href="/walk?avatar=${encodeURIComponent(avatarId)}">Walk</a>` : ''}
+ ${avatarId ? `<a class="ame-btn ghost small" href="/temporary?avatar=${encodeURIComponent(avatarId)}">Walk</a>` : ''}
${avatarId ? `<a class="ame-btn ghost small" href="/pose?avatar=${encodeURIComponent(avatarId)}">Pose</a>` : ''}
${avatarId ? `<a class="ame-btn ghost small" href="/mocap-studio?avatar=${encodeURIComponent(avatarId)}">Mocap</a>` : ''}
<button class="ame-btn ghost small" data-action="toggle-skills" data-agent-id="${esc(a.id)}">Skills</button>
@@ -338,7 +338,7 @@ function renderAvatarCards(host, avatars, agents) {
<a class="ame-btn ghost tiny" href="/agents/${encodeURIComponent(av.id)}" title="View">View</a>
<button class="ame-btn ghost tiny" data-action="selfie" data-avatar-id="${esc(av.id)}" title="Update from selfie">Selfie</button>
<button class="ame-btn ghost tiny" data-action="share" data-avatar-id="${esc(av.id)}" data-name="${name}" title="Share">Share</button>
- <a class="ame-btn ghost tiny" href="/walk?avatar=${encodeURIComponent(av.id)}" title="Walk">Walk</a>
+ <a class="ame-btn ghost tiny" href="/temporary?avatar=${encodeURIComponent(av.id)}" title="Walk">Walk</a>
</div>
</div>
</div>
diff --git a/src/communities.js b/src/communities.js
index 7aab0b39b..c8e6d829c 100644
--- a/src/communities.js
+++ b/src/communities.js
@@ -143,7 +143,7 @@ function enterWorld(coin) {
if (name) { p.set('name', name); try { localStorage.setItem(NAME_STORAGE_KEY, name); } catch {} }
if (selectedAvatar.kind === 'id') p.set('avatar', selectedAvatar.value);
else if (selectedAvatar.kind === 'url') p.set('avatarUrl', selectedAvatar.value);
- location.href = `/walk?${p.toString()}`;
+ location.href = `/temporary?${p.toString()}`;
}
// ── Coin grid ──────────────────────────────────────────────────────────────
diff --git a/src/community/coin-lobby.js b/src/community/coin-lobby.js
index afce3b17f..69db382bc 100644
--- a/src/community/coin-lobby.js
+++ b/src/community/coin-lobby.js
@@ -1,7 +1,7 @@
// Coin lobby — the entry surface for /walk when no coin is chosen.
//
// Lists live coin-worlds from the proxy (real getTopCommunities data) as
-// enterable cards. Picking one navigates to /walk?coin=<mint> (preserving any
+// enterable cards. Picking one navigates to /temporary?coin=<mint> (preserving any
// ?avatar / ?agent so the player keeps their identity into the world). Fully
// self-contained: injects its own styles, mounts over <body>, removes itself on
// enter. Designed loading / empty / error states.
diff --git a/src/community/coin-world-boot.js b/src/community/coin-world-boot.js
index 8aa01803c..86c0cc10a 100644
--- a/src/community/coin-world-boot.js
+++ b/src/community/coin-world-boot.js
@@ -1,4 +1,4 @@
-// Coin-world boot — the entry glue for /walk's social layer.
+// Coin-world boot — the entry glue for /temporary's social layer.
//
// Decides, from the URL, whether the visitor is choosing a world or already in
// one, and mounts the right surface:
diff --git a/src/dashboard-next/pages/home.js b/src/dashboard-next/pages/home.js
index af40c4ba9..b2b97be18 100644
--- a/src/dashboard-next/pages/home.js
+++ b/src/dashboard-next/pages/home.js
@@ -994,7 +994,7 @@ const DIR_ICONS = {
'/gallery-picker': '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="16" height="14" rx="2"/><circle cx="7" cy="8" r="1.5"/><path d="M2 14l4-4 3 3 4-5 5 6"/></svg>',
'/import-rpm': '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 2v12M6 10l4 4 4-4"/><path d="M3 14v3h14v-3"/></svg>',
'/create/selfie': '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="16" height="14" rx="2"/><circle cx="10" cy="10" r="3"/><path d="M6 3V2M14 3V2"/></svg>',
- '/walk': '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="4" r="2"/><path d="M10 6v4l-2 4M10 10l2 4M7 8l3 2 3-2"/></svg>',
+ '/temporary': '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="4" r="2"/><path d="M10 6v4l-2 4M10 10l2 4M7 8l3 2 3-2"/></svg>',
'/pose': '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="4" r="2"/><path d="M10 6v5M6 8l4 2 4-2M8 11l-2 5M12 11l2 5"/></svg>',
'/dashboard/agents': '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="2" width="10" height="10" rx="2"/><circle cx="8" cy="6.5" r="1"/><circle cx="12" cy="6.5" r="1"/><path d="M8 9h4M3 14l2-2h10l2 2v3a1 1 0 01-1 1H4a1 1 0 01-1-1v-3z"/></svg>',
'/onchain': '<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8 12a4 4 0 005.7 0l2-2a4 4 0 00-5.7-5.7l-1 1"/><path d="M12 8a4 4 0 00-5.7 0l-2 2a4 4 0 005.7 5.7l1-1"/></svg>',
@@ -1098,7 +1098,7 @@ const DIRECTORY = [
group: '3D & Immersive',
items: [
{ href: '/app', title: '3D Viewer', sub: 'Interactive 3D agent editor and viewer' },
- { href: '/walk', title: 'Walk Viewer', sub: 'Walk and animation preview' },
+ { href: '/temporary', title: 'Walk Viewer', sub: 'Walk and animation preview' },
{ href: '/pose', title: 'Pose Editor', sub: 'Pose and position your avatar' },
{ href: '/xr', title: 'XR / AR', sub: 'Augmented and extended reality views' },
],
diff --git a/src/dashboard-next/pages/library/animations.js b/src/dashboard-next/pages/library/animations.js
index a8f0d0a88..11efbf256 100644
--- a/src/dashboard-next/pages/library/animations.js
+++ b/src/dashboard-next/pages/library/animations.js
@@ -121,7 +121,7 @@ export async function renderAnimations(host) {
<div class="dn-panel-sub" style="margin:0">Clips attached to any of your agents. Uploading adds a clip to the agent you select.</div>
</div>
<div class="anim-head-actions">
- <a class="dn-btn ghost" href="/walk">Browse presets →</a>
+ <a class="dn-btn ghost" href="/temporary">Browse presets →</a>
<button class="dn-btn primary" id="anim-upload-open" type="button">Upload clip (.glb / .fbx / .bvh)</button>
</div>
</div>
@@ -211,7 +211,7 @@ export async function renderAnimations(host) {
<p>Upload a .glb, .fbx, or .bvh clip, or pick from our mocap library.</p>
<div style="display:flex;gap:8px;justify-content:center;margin-top:12px;flex-wrap:wrap">
<button class="dn-btn primary" id="anim-empty-upload" type="button">Upload</button>
- <a class="dn-btn ghost" href="/walk">Browse presets →</a>
+ <a class="dn-btn ghost" href="/temporary">Browse presets →</a>
</div>
</div>
`;
diff --git a/src/game/coincommunities-ui.js b/src/game/coincommunities-ui.js
index e25944136..01d817077 100644
--- a/src/game/coincommunities-ui.js
+++ b/src/game/coincommunities-ui.js
@@ -295,7 +295,7 @@ export class CommunityUI {
['/launchpad', 'Launchpad Studio', 'Build a 3D launchpad · token · concierge', 'New'],
['/mocap-studio', 'Mocap Studio', 'Record face → save clip → replay', 'New'],
['/pose', 'Pose Studio', 'Click-to-pose mannequin + export PNG'],
- ['/walk', 'Walk', 'Walk your avatar — multiplayer + AR', 'New'],
+ ['/temporary', 'Walk', 'Walk your avatar — multiplayer + AR', 'New'],
['/xr', 'XR', 'Place your avatar in the real world', 'New'],
['/three-live', '$THREE Live', 'Protocol pulse — live trades in 3D', 'New'],
['/pump-visualizer', 'Pump Visualizer', '3D view of trending tokens'],
diff --git a/src/irl.js b/src/irl.js
index 0897d9ed8..0a4f2dc5d 100644
--- a/src/irl.js
+++ b/src/irl.js
@@ -5203,7 +5203,7 @@ document.getElementById('irl-sheet-view')?.addEventListener('click', () => {
if (agentId) {
window.open(`/agents/${agentId}`, '_blank', 'noopener');
} else {
- window.open(`/walk?agent=${encodeURIComponent(name)}`, '_blank', 'noopener');
+ window.open(`/temporary?agent=${encodeURIComponent(name)}`, '_blank', 'noopener');
}
});
diff --git a/src/walk.js b/src/walk.js
index 673d74c01..061b60bf3 100644
--- a/src/walk.js
+++ b/src/walk.js
@@ -3274,7 +3274,7 @@ loadAvatar()
// the scene (default ground/lighting) is visible behind the message.
dismissLoading();
const hasParam = new URLSearchParams(location.search).has('avatar');
- const suffix = hasParam ? ' — <a href="/walk">try the default avatar</a>' : '';
+ const suffix = hasParam ? ' — <a href="/temporary">try the default avatar</a>' : '';
if (statusEl) {
statusEl.innerHTML = `failed to load avatar: ${err?.message ?? err}${suffix}`;
statusEl.classList.add('is-error');
diff --git a/src/worlds-lobby.js b/src/worlds-lobby.js
index fbcbc1835..075b932f7 100644
--- a/src/worlds-lobby.js
+++ b/src/worlds-lobby.js
@@ -1,6 +1,6 @@
// Coin Communities lobby — the front door to three.ws worlds.
//
-// Every coin on three.ws is its own 3D world at /walk?coin=<mint>; its
+// Every coin on three.ws is its own 3D world at /temporary?coin=<mint>; its
// CoinCommunities community is the live social layer inside. This page does two
// things with zero friction:
// 1. Lets a visitor pick or drop in an avatar / 3D agent (no sign-in) and
@@ -271,7 +271,7 @@ function enterWorld(coin) {
if (a?.id) params.set('avatar', a.id);
if (name) params.set('name', name);
const qs = params.toString();
- window.location.href = `/walk${qs ? `?${qs}` : ''}`;
+ window.location.href = `/temporary${qs ? `?${qs}` : ''}`;
}
// ── worlds grid ──────────────────────────────────────────────────────────────
diff --git a/vercel.json b/vercel.json
index 9d4199e39..a9c05b622 100644
--- a/vercel.json
+++ b/vercel.json
@@ -758,7 +758,7 @@
}
},
{
- "src": "/walk/?",
+ "src": "/temporary/?",
"dest": "/walk.html"
},
{
@@ -787,7 +787,7 @@
},
{
"src": "/wk/([A-Za-z0-9_-]+)",
- "dest": "/walk?avatar=$1",
+ "dest": "/temporary?avatar=$1",
"status": 302
},
{
diff --git a/vite.config.js b/vite.config.js
index 289083711..81e597eaa 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -786,8 +786,8 @@ support: resolve(__dirname, 'pages/support.html'),
'/three-token/': resolve(root, 'pages/three-token.html'),
'/avatar-artifact': resolve(root, 'pages/avatar-artifact.html'),
'/avatar-artifact/': resolve(root, 'pages/avatar-artifact.html'),
- '/walk': resolve(root, 'pages/walk.html'),
- '/walk/': resolve(root, 'pages/walk.html'),
+ '/temporary': resolve(root, 'pages/walk.html'),
+ '/temporary/': resolve(root, 'pages/walk.html'),
'/irl': resolve(root, 'pages/irl.html'),
'/irl/': resolve(root, 'pages/irl.html'),
'/irl-privacy': resolve(root, 'pages/irl-privacy.html'),
diff --git a/walk-sdk/README.md b/walk-sdk/README.md
new file mode 100644
index 000000000..66f7131ed
--- /dev/null
+++ b/walk-sdk/README.md
@@ -0,0 +1,211 @@
+# @three-ws/walk
+
+> A diverse, animated 3D avatar that **walks and talks over your web pages** — a corner companion plus a full‑page playground, with a built‑in avatar picker. Powered by [Three.js](https://threejs.org).
+
+Drop a character onto any site. It idles in the corner, turns to follow the
+cursor, waves when the visitor navigates, and greets each page. Click it and it
+**detaches into a full‑page playground** the visitor can steer with the keyboard
+or an on‑screen d‑pad — strolling across the page from a gentle aerial view, or
+platforming across your real DOM with gravity and jumps. Walk onto a link and
+it opens like a doorway into the next page.
+
+Every visitor can **choose who walks with them** from a built‑in roster of
+avatars — a robot mascot, humanoids, photoreal people, a fox, dancers,
+showpieces — or you can supply your own GLB. Whatever they pick is animated
+correctly whether the rig ships its own clips or needs the shared retargeting
+library, so nothing ever freezes in a bind/T‑pose.
+
+This is the engine behind the walking companion on [three.ws](https://three.ws).
+
+---
+
+## Install
+
+```bash
+npm install @three-ws/walk three
+```
+
+`three` is a **peer dependency** — bring your own copy (>= 0.150).
+
+You also need to serve two sets of assets from your origin (or a CDN you point
+`assetBase` at):
+
+- the avatar GLBs the roster references (e.g. `/avatars/*.glb`), and
+- the shared animation manifest + clips (`/animations/manifest.json` + clips),
+ used to retarget motion onto rigs that ship no locomotion.
+
+> The defaults match the three.ws asset layout. Override them with `assetBase`,
+> `apiBase`, and `manifestUrl`, or pass your own `avatars` roster.
+
+---
+
+## Quick start
+
+The whole experience, app‑style (auto‑mounts when enabled, honors `?walk=` deep
+links, resumes the playground after a "dive"):
+
+```js
+import { createWalkCompanion } from '@three-ws/walk';
+
+const walk = createWalkCompanion();
+walk.bootstrap();
+```
+
+Or drive it yourself:
+
+```js
+const walk = createWalkCompanion({ defaultAvatarId: 'fox' });
+
+walk.enable(); // mount the corner companion
+walk.openPicker(); // let the visitor choose an avatar
+walk.setAvatar('michelle'); // swap the live avatar
+walk.disable(); // remove it
+```
+
+`createWalkCompanion` is **side‑effect free on import** — nothing touches the
+DOM until you call `enable()` or `bootstrap()`.
+
+---
+
+## How avatars are animated
+
+Each roster entry declares a rig strategy so it always moves:
+
+| `rig` | Used for | How it animates |
+| ---------- | ----------------------------------------------- | ------------------------------------------------------------------------------- |
+| `embedded` | self‑animated or non‑humanoid GLBs (robot, fox) | plays the clips baked into the GLB; falls back to the first clip so it never freezes |
+| `shared` | humanoids with no locomotion (or only a T‑pose) | retargets the shared clip library (`idle`/`walk`/`run`/`wave`/`jump`) onto the rig |
+
+The same unified loader powers both the corner companion and the playground, so
+adding an avatar makes it work everywhere at once.
+
+### Custom roster
+
+```js
+import { createWalkCompanion, WALK_AVATARS } from '@three-ws/walk';
+
+createWalkCompanion({
+ avatars: [
+ ...WALK_AVATARS,
+ {
+ id: 'mascot',
+ name: 'Our Mascot',
+ category: 'Brand',
+ asset: '/brand/mascot.glb',
+ source: 'static',
+ rig: 'shared', // retarget the shared library onto it
+ accent: '#ff0066',
+ },
+ ],
+ defaultAvatarId: 'mascot',
+}).bootstrap();
+```
+
+User‑generated avatars served by a GLB proxy (`/api/avatars/<id>/glb`) work via
+`makeApiAvatarEntry(id)` and resolve at runtime — no need to list them.
+
+---
+
+## API
+
+### `createWalkCompanion(options?) → control`
+
+| option | default | description |
+| ----------------- | ---------------------------- | -------------------------------------------------------- |
+| `avatars` | `WALK_AVATARS` | roster shown in the picker and resolvable by id |
+| `defaultAvatarId` | `'robot'` | avatar loaded when none is chosen/stored |
+| `assetBase` | `''` | base prepended to static GLB paths (e.g. a CDN origin) |
+| `apiBase` | `''` | base prepended to the `/api/avatars/<id>/glb` proxy |
+| `manifestUrl` | `'/animations/manifest.json'`| shared animation manifest |
+| `excludedRoutes` | full‑screen 3D routes | path prefixes where the companion never mounts |
+| `enablePicker` | `true` | show the avatar picker button |
+| `greeting` | built‑in | `(path) => string \| null` to customise the page greeting |
+| `docsUrl` | `null` | optional "make your own" link in the picker footer |
+| `storagePrefix` | `'walk'` | localStorage/sessionStorage key prefix |
+
+The returned **control** object:
+
+```ts
+control.isEnabled(): boolean
+control.enable(): void
+control.disable(): void
+control.toggle(): void
+control.setAvatar(idOrEntry): void // persist + hot-swap the live avatar
+control.openPicker(): void
+control.bootstrap(): void // app-style auto-mount + ?walk= deep links
+control.instance // the live companion (or null)
+```
+
+### Roster helpers
+
+```js
+import {
+ WALK_AVATARS, DEFAULT_AVATAR_ID, getAvatar, defaultAvatar,
+ listCategories, makeApiAvatarEntry, resolveAvatarUrl,
+} from '@three-ws/walk';
+```
+
+### Playground (driven for you by the companion, exported for direct use)
+
+```js
+import {
+ launchPlayground, exitPlayground, switchPlaygroundMode,
+ getPlaygroundMode, consumeDropIn, playgroundState,
+} from '@three-ws/walk';
+```
+
+### Picker UI
+
+```js
+import { createAvatarPicker } from '@three-ws/walk';
+
+const picker = createAvatarPicker({
+ avatars: WALK_AVATARS,
+ currentId: 'robot',
+ onSelect: (entry) => console.log('chose', entry.id),
+});
+picker.show();
+```
+
+### Low‑level loader
+
+```js
+import { loadWalkAvatar, getAvatar } from '@three-ws/walk';
+
+const { model, controller } = await loadWalkAvatar(getAvatar('xbot'));
+scene.add(model);
+// each frame:
+controller.setState('walk'); // 'idle' | 'walk' | 'run' | 'jump'
+controller.update(dt);
+```
+
+---
+
+## URL controls
+
+The companion honours these query params (via `bootstrap()`):
+
+- `?walk=1` — force the companion on
+- `?walk=0` — force it off
+- `?walk=play` — deep‑link straight into the full‑page playground
+- `?avatar=<id>` — load a specific roster avatar (or a user avatar id)
+
+---
+
+## Accessibility & performance
+
+- **One shared WebGL context budget** — the companion and playground never run
+ two contexts at once, and the budget coordinates with other Three.js viewers
+ on the page so a busy site never hits the browser's context limit.
+- **Reduced motion** — respects `prefers-reduced-motion`; the avatar calms to a
+ steady idle and page "dives" skip the animation.
+- **Keyboard** — playground steers with arrow keys / WASD; the picker is fully
+ keyboard‑navigable; every control has a visible focus ring.
+- **Zero footprint when off** — nothing loads (no Three.js fetch) until enabled,
+ and the playground code is a lazy `import()` paid for only on first detach.
+
+---
+
+## License
+
+[Apache‑2.0](./LICENSE) © three.ws
diff --git a/x402-modal-sdk/src/x402-modal.js b/x402-modal-sdk/src/x402-modal.js
index 5c9bb16bc..53e1b13ce 100644
--- a/x402-modal-sdk/src/x402-modal.js
+++ b/x402-modal-sdk/src/x402-modal.js
@@ -123,76 +123,6 @@ function apiOriginFor(opts) {
const SIWX_HEADER = 'SIGN-IN-WITH-X';
const SIWX_EXTENSION_KEY = 'sign-in-with-x';
-// USDC EIP-3009 typed-data sig works against Base USDC at this address. The
-// domain `version` must match the on-chain `EIP712_DOMAIN_SEPARATOR_VERSION`
-// of the deployed USDC implementation — Base USDC is at version "2".
-const EVM_NETWORKS = {
- 'eip155:8453': { chainId: 8453, name: 'Base', explorer: 'https://basescan.org/tx/' },
- 'eip155:84532': { chainId: 84532, name: 'Base Sepolia', explorer: 'https://sepolia.basescan.org/tx/' },
- 'eip155:42161': { chainId: 42161, name: 'Arbitrum', explorer: 'https://arbiscan.io/tx/' },
- 'eip155:10': { chainId: 10, name: 'Optimism', explorer: 'https://optimistic.etherscan.io/tx/' },
-};
-
-// Normalize a single 402 `accept` entry to the shape the modal speaks
-// internally. The x402 spec's canonical atomic-price field is
-// `maxAmountRequired`; some merchants emit `amount`. We read `amount`
-// everywhere downstream, so coerce here once at ingestion. Without this, a
-// spec-compliant merchant yields `accept.amount === undefined` → "NaN USDC".
-function normalizeAccept(accept) {
- if (!accept || typeof accept !== 'object') return accept;
- const amount = accept.amount ?? accept.maxAmountRequired;
- return amount != null && accept.amount == null ? { ...accept, amount: String(amount) } : accept;
-}
-
-function isSolanaNetwork(net) {
- return typeof net === 'string' && (net === 'solana' || net.startsWith('solana:'));
-}
-function isEvmNetwork(net) {
- return typeof net === 'string' && net.startsWith('eip155:');
-}
-// The modal only signs EIP-3009 transferWithAuthorization for EVM. When the
-// server publishes both an EIP-3009 entry and a Permit2 sibling (the
-// gas-sponsoring path used by @x402/evm SDK clients), we must pick the
-// EIP-3009 one. The sibling carries `extra.assetTransferMethod === 'permit2'`.
-function isEip3009Accept(accept) {
- if (!isEvmNetwork(accept?.network)) return false;
- const method = accept?.extra?.assetTransferMethod;
- return !method || method === 'eip3009';
-}
-function networkLabel(net, accept) {
- if (isSolanaNetwork(net)) return 'Solana';
- const meta = EVM_NETWORKS[net];
- return meta?.name || accept?.extra?.name || net;
-}
-function explorerUrl(net, tx) {
- if (!tx) return null;
- if (isSolanaNetwork(net)) return `https://solscan.io/tx/${tx}`;
- const meta = EVM_NETWORKS[net];
- return meta ? `${meta.explorer}${tx}` : null;
-}
-
-function formatAmount(rawAtomics, decimals = 6) {
- const n = Number(rawAtomics) / 10 ** decimals;
- if (n < 0.01) return n.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
- if (n < 1) return n.toFixed(4).replace(/0+$/, '').replace(/\.$/, '');
- return n.toFixed(2);
-}
-
-function b64encode(obj) {
- const json = JSON.stringify(obj);
- if (typeof Buffer !== 'undefined') return Buffer.from(json, 'utf8').toString('base64');
- return btoa(unescape(encodeURIComponent(json)));
-}
-function b64decode(str) {
- if (!str) return null;
- try {
- const bin = typeof Buffer !== 'undefined' ? Buffer.from(str, 'base64').toString('utf8') : decodeURIComponent(escape(atob(str)));
- return JSON.parse(bin);
- } catch (_) {
- return null;
- }
-}
-
// ──────────────────────────────────────────────────────── Spending caps ─────
// Persists per-wallet spend in localStorage so reload-survivable caps work in a
// pure-browser context. Keys are bucketed by UTC hour and UTC day so the
@@ -201,15 +131,6 @@ function b64decode(str) {
// through as-is since their atomics are already 6-decimal USD-pegged.
const SPEND_LS_PREFIX = 'x402.spend.';
-const STABLE_NAMES = new Set([
- 'usdc', 'usd coin', 'usdt', 'tether', 'binance-peg usd coin', 'dai',
-]);
-
-function spendBuckets(timestamp = Date.now()) {
- const hour = Math.floor(timestamp / 3_600_000);
- const day = Math.floor(timestamp / 86_400_000);
- return { hour, day };
-}
function spendKey(address, kind, bucket) {
return `${SPEND_LS_PREFIX}${kind}.${address.toLowerCase()}.${bucket}`;
@@ -233,27 +154,12 @@ function writeSpend(address, kind, bucket, value) {
}
}
-function toMicroUsdBrowser(amount, accept) {
- const atomic = BigInt(amount);
- const decimals = Number(accept?.extra?.decimals ?? 6);
- const name = String(accept?.extra?.name || '').toLowerCase();
- if (STABLE_NAMES.has(name)) {
- if (decimals === 6) return atomic;
- if (decimals > 6) return atomic / 10n ** BigInt(decimals - 6);
- return atomic * 10n ** BigInt(6 - decimals);
- }
- // Non-stable in the browser modal: we don't fetch live prices to keep the
- // drop-in script dependency-free. Cap enforcement for non-stable assets must
- // be done server-side.
- return atomic;
-}
-
// Check the configured caps and, if admitted, reserve the spend in localStorage.
// Returns { abort, reason?, reservation? }. Reservation carries { address,
// microUsd, buckets } so a failed payment can roll the reservation back.
function browserEnforceCap({ accept, caps, address }) {
if (!caps || !address) return { abort: false };
- const microUsd = toMicroUsdBrowser(accept.amount, accept);
+ const microUsd = toMicroUsd(accept.amount, accept);
const maxPerCall = caps.maxPerCall != null ? BigInt(caps.maxPerCall) : null;
const maxPerHour = caps.maxPerHour != null ? BigInt(caps.maxPerHour) : null;
const maxPerDay = caps.maxPerDay != null ? BigInt(caps.maxPerDay) : null;
@@ -323,42 +229,6 @@ function pickSiwxChain(ext, walletKind) {
return null;
}
-// Build the CAIP-122 message string. The server rebuilds the same string from
-// payload fields when verifying — any line-by-line drift makes the recovered
-// signer mismatch payload.address and the signature is rejected.
-function buildSiwxMessage(info, chain, address) {
- const isEvm = chain.type === 'eip191';
- const accountHeader = isEvm
- ? `${info.domain} wants you to sign in with your Ethereum account:`
- : `${info.domain} wants you to sign in with your Solana account:`;
- const [, chainTail = ''] = String(chain.chainId).split(':');
- const chainRef = isEvm ? String(parseInt(chainTail, 10)) : chainTail;
-
- const lines = [accountHeader, address, ''];
- if (info.statement) {
- lines.push(info.statement, '');
- } else if (isEvm) {
- // siwe's prepareMessage() reserves the statement block even when the
- // statement is absent, emitting an extra blank line. SIWS does not. The
- // server rebuilds the EVM message via siwe before recovering the signer,
- // so omit-statement EVM must carry the same extra blank.
- lines.push('');
- }
- lines.push(`URI: ${info.uri}`);
- lines.push(`Version: ${info.version || '1'}`);
- lines.push(`Chain ID: ${chainRef}`);
- lines.push(`Nonce: ${info.nonce}`);
- lines.push(`Issued At: ${info.issuedAt}`);
- if (info.expirationTime) lines.push(`Expiration Time: ${info.expirationTime}`);
- if (info.notBefore) lines.push(`Not Before: ${info.notBefore}`);
- if (info.requestId !== undefined && info.requestId !== null) lines.push(`Request ID: ${info.requestId}`);
- if (Array.isArray(info.resources) && info.resources.length) {
- lines.push('Resources:');
- for (const r of info.resources) lines.push(`- ${r}`);
- }
- return lines.join('\n');
-}
-
// Base64-encoded JSON per x402 v2 spec. CAIP-122 fields are all ASCII/Latin-1,
// so the unescape+encodeURIComponent dance matches what btoa expects.
function encodeSiwxHeaderValue(payload) {
@@ -367,24 +237,6 @@ function encodeSiwxHeaderValue(payload) {
return btoa(unescape(encodeURIComponent(json)));
}
-// Base58 (Bitcoin alphabet) — Solana's encoding for both addresses and
-// signatures. Inlined here to avoid pulling in a bundler dependency.
-const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
-function base58encode(bytes) {
- if (!bytes || bytes.length === 0) return '';
- let leadingZeros = 0;
- while (leadingZeros < bytes.length && bytes[leadingZeros] === 0) leadingZeros++;
- let n = 0n;
- for (let i = 0; i < bytes.length; i++) n = (n << 8n) | BigInt(bytes[i]);
- let out = '';
- while (n > 0n) {
- out = BASE58_ALPHABET[Number(n % 58n)] + out;
- n /= 58n;
- }
- for (let i = 0; i < leadingZeros; i++) out = BASE58_ALPHABET[0] + out;
- return out;
-}
-
// EIP-55 checksum the address before signing. MetaMask returns lowercase
// addresses, but the server rebuilds the SIWE message with a checksummed
// address. If we sign a lowercase-address message and send the lowercase
diff --git a/x402-modal-sdk/test/configure.test.js b/x402-modal-sdk/test/configure.test.js
new file mode 100644
index 000000000..9cf211497
--- /dev/null
+++ b/x402-modal-sdk/test/configure.test.js
@@ -0,0 +1,55 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { configure, getConfig, version, pay, init } from '../src/x402-modal.js';
+
+test('public API surface is intact', () => {
+ assert.equal(typeof pay, 'function');
+ assert.equal(typeof init, 'function');
+ assert.equal(typeof configure, 'function');
+ assert.match(version, /^\d+\.\d+\.\d+$/);
+});
+
+test('init() is a no-op without a document (does not throw in Node)', () => {
+ assert.doesNotThrow(() => init());
+});
+
+test('pay() rejects without an endpoint', async () => {
+ await assert.rejects(() => pay({}), /endpoint is required/);
+});
+
+test('configure merges brand and builderCode without dropping siblings', () => {
+ const base = getConfig();
+ assert.equal(base.brand.label, 'Powered by three.ws');
+ assert.equal(base.builderCode.wallet, '3d_agent');
+
+ configure({ brand: { label: 'Powered by Acme' } });
+ const afterBrand = getConfig();
+ assert.equal(afterBrand.brand.label, 'Powered by Acme');
+ // href left intact since only label was overridden
+ assert.equal(afterBrand.brand.href, 'https://three.ws');
+
+ configure({ apiOrigin: 'https://pay.example.com' });
+ assert.equal(getConfig().apiOrigin, 'https://pay.example.com');
+
+ configure({ builderCode: { service: 'acme_checkout' } });
+ const afterBuilder = getConfig();
+ assert.equal(afterBuilder.builderCode.service, 'acme_checkout');
+ assert.equal(afterBuilder.builderCode.wallet, '3d_agent');
+
+ // null disables the echo entirely
+ configure({ builderCode: null });
+ assert.equal(getConfig().builderCode, null);
+
+ // restore defaults for any later test run in the same process
+ configure({
+ apiOrigin: null,
+ brand: { label: 'Powered by three.ws', href: 'https://three.ws' },
+ builderCode: { wallet: '3d_agent', service: '3d_agent_modal' },
+ });
+});
+
+test("configure honours an explicit empty-string apiOrigin (same-origin)", () => {
+ configure({ apiOrigin: '' });
+ assert.equal(getConfig().apiOrigin, '');
+ configure({ apiOrigin: null });
+});
diff --git a/x402-modal-sdk/test/util.test.js b/x402-modal-sdk/test/util.test.js
new file mode 100644
index 000000000..8fc7f2926
--- /dev/null
+++ b/x402-modal-sdk/test/util.test.js
@@ -0,0 +1,133 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import {
+ EVM_NETWORKS,
+ normalizeAccept,
+ isSolanaNetwork,
+ isEvmNetwork,
+ isEip3009Accept,
+ networkLabel,
+ explorerUrl,
+ formatAmount,
+ b64encode,
+ b64decode,
+ base58encode,
+ toMicroUsd,
+ spendBuckets,
+ buildSiwxMessage,
+} from '../src/util.js';
+
+test('formatAmount renders USDC atomics at sensible precision', () => {
+ assert.equal(formatAmount(1_000_000), '1.00');
+ assert.equal(formatAmount(10_000_000), '10.00');
+ assert.equal(formatAmount(1_500_000), '1.50');
+ assert.equal(formatAmount(500_000), '0.5');
+ assert.equal(formatAmount(1_000), '0.001');
+ assert.equal(formatAmount(0), '0');
+ // six-decimal token override
+ assert.equal(formatAmount(1_000_000_000_000_000_000, 18), '1.00');
+});
+
+test('normalizeAccept coerces spec-canonical maxAmountRequired → amount', () => {
+ const a = normalizeAccept({ network: 'eip155:8453', maxAmountRequired: 1000 });
+ assert.equal(a.amount, '1000');
+ // existing amount wins and is left untouched (no clobber)
+ const b = normalizeAccept({ amount: '42', maxAmountRequired: 999 });
+ assert.equal(b.amount, '42');
+ // nothing to normalize → identity
+ assert.deepEqual(normalizeAccept(null), null);
+});
+
+test('network predicates classify CAIP-2 ids', () => {
+ assert.ok(isSolanaNetwork('solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'));
+ assert.ok(isSolanaNetwork('solana'));
+ assert.ok(!isSolanaNetwork('eip155:8453'));
+ assert.ok(isEvmNetwork('eip155:8453'));
+ assert.ok(!isEvmNetwork('solana:abc'));
+});
+
+test('isEip3009Accept selects the legacy entry over a Permit2 sibling', () => {
+ assert.ok(isEip3009Accept({ network: 'eip155:8453' }));
+ assert.ok(isEip3009Accept({ network: 'eip155:8453', extra: { assetTransferMethod: 'eip3009' } }));
+ assert.ok(!isEip3009Accept({ network: 'eip155:8453', extra: { assetTransferMethod: 'permit2' } }));
+ assert.ok(!isEip3009Accept({ network: 'solana:abc' }));
+});
+
+test('networkLabel + explorerUrl resolve known chains', () => {
+ assert.equal(networkLabel('eip155:8453'), 'Base');
+ assert.equal(networkLabel('solana:abc'), 'Solana');
+ assert.equal(networkLabel('eip155:99999', { extra: { name: 'Frobnet' } }), 'Frobnet');
+ assert.equal(explorerUrl('eip155:8453', '0xabc'), 'https://basescan.org/tx/0xabc');
+ assert.equal(explorerUrl('solana:x', 'SIG'), 'https://solscan.io/tx/SIG');
+ assert.equal(explorerUrl('eip155:8453', null), null);
+ // every declared EVM network has chainId + explorer
+ for (const [, meta] of Object.entries(EVM_NETWORKS)) {
+ assert.ok(Number.isInteger(meta.chainId));
+ assert.match(meta.explorer, /^https:\/\/.+\/tx\/$/);
+ }
+});
+
+test('b64 round-trips structured payloads', () => {
+ const obj = { x402Version: 2, scheme: 'exact', n: 'café ☕' };
+ assert.deepEqual(b64decode(b64encode(obj)), obj);
+ assert.equal(b64decode(''), null);
+ assert.equal(b64decode('not-base64-json!!!'), null);
+});
+
+test('base58encode matches known Solana vectors', () => {
+ assert.equal(base58encode(new Uint8Array([0, 0, 0])), '111');
+ assert.equal(base58encode(new Uint8Array([1, 2, 3])), 'Ldp');
+ assert.equal(base58encode(new Uint8Array()), '');
+});
+
+test('toMicroUsd scales stablecoins and passes non-stable through', () => {
+ // USDC, 6 decimals → micro-USD is identity
+ assert.equal(toMicroUsd('1000000', { extra: { name: 'USDC', decimals: 6 } }), 1_000_000n);
+ // a hypothetical 18-decimal DAI scales down to 6
+ assert.equal(toMicroUsd('1000000000000000000', { extra: { name: 'DAI', decimals: 18 } }), 1_000_000n);
+ // non-stable: passed through atomic (capped server-side)
+ assert.equal(toMicroUsd('5', { extra: { name: 'WBTC', decimals: 8 } }), 5n);
+});
+
+test('spendBuckets partitions hour and day windows', () => {
+ const t = 1_700_000_000_000;
+ const { hour, day } = spendBuckets(t);
+ assert.equal(hour, Math.floor(t / 3_600_000));
+ assert.equal(day, Math.floor(t / 86_400_000));
+ // a later timestamp in the same hour shares a bucket
+ assert.equal(spendBuckets(t + 60_000).hour, hour);
+});
+
+test('buildSiwxMessage reproduces the SIWS line layout (Solana)', () => {
+ const info = {
+ domain: 'pay.example.com',
+ uri: 'https://pay.example.com/x',
+ version: '1',
+ nonce: 'abc123',
+ issuedAt: '2026-01-01T00:00:00.000Z',
+ };
+ const chain = { type: 'ed25519', chainId: 'solana:5eykt4UsFv8P8NJ' };
+ const msg = buildSiwxMessage(info, chain, 'SoLaNaAddr');
+ assert.match(msg, /wants you to sign in with your Solana account:/);
+ assert.match(msg, /\nSoLaNaAddr\n/);
+ assert.match(msg, /Chain ID: 5eykt4UsFv8P8NJ/);
+ assert.match(msg, /Nonce: abc123/);
+ // no statement → SIWS does NOT insert the extra blank line the EVM path does
+ assert.ok(!msg.includes('\n\n\nURI:'));
+});
+
+test('buildSiwxMessage reserves the EVM statement blank line', () => {
+ const info = {
+ domain: 'pay.example.com',
+ uri: 'https://pay.example.com/x',
+ version: '1',
+ nonce: 'n',
+ issuedAt: '2026-01-01T00:00:00.000Z',
+ };
+ const chain = { type: 'eip191', chainId: 'eip155:8453' };
+ const msg = buildSiwxMessage(info, chain, '0xAbC');
+ assert.match(msg, /wants you to sign in with your Ethereum account:/);
+ assert.match(msg, /Chain ID: 8453/);
+ // statement omitted → EVM still carries the extra blank to match siwe
+ assert.ok(msg.includes('0xAbC\n\n\nURI:'));
+});
diff --git a/x402-payment-modal/package.json b/x402-payment-modal/package.json
index 4d85b7fa2..2c93d36df 100644
--- a/x402-payment-modal/package.json
+++ b/x402-payment-modal/package.json
@@ -48,7 +48,7 @@
],
"scripts": {
"build": "node build.mjs",
- "test": "node --test test/",
+ "test": "node --test \"test/*.test.js\"",
"prepublishOnly": "npm run build"
},
"keywords": [
diff --git a/x402-payment-modal/test/server.test.js b/x402-payment-modal/test/server.test.js
new file mode 100644
index 000000000..3db7c3df7
--- /dev/null
+++ b/x402-payment-modal/test/server.test.js
@@ -0,0 +1,136 @@
+// Server-side checkout tests — pure logic, no network required.
+//
+// npm test (from the package root)
+//
+// `prepareSolanaCheckout` validates its input *before* any RPC round-trip, so we
+// can assert the validation paths without a live Solana connection. `encode` is
+// fully offline.
+
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+
+import {
+ encodeX402Payment,
+ prepareSolanaCheckout,
+ handleCheckout,
+ isSolanaNetwork,
+ CheckoutError,
+ NETWORK_SOLANA_MAINNET,
+ NETWORK_SOLANA_DEVNET,
+} from '../server/checkout.js';
+
+const USDC_MAINNET = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
+// Clearly-synthetic placeholder addresses (valid base58, 32-44 chars).
+const PAY_TO = '11111111111111111111111111111112';
+const FEE_PAYER = 'So11111111111111111111111111111111111111112';
+const BUYER = 'So11111111111111111111111111111111111111112';
+
+function accept(overrides = {}) {
+ return {
+ scheme: 'exact',
+ network: NETWORK_SOLANA_MAINNET,
+ amount: '10000',
+ asset: USDC_MAINNET,
+ payTo: PAY_TO,
+ extra: { name: 'USDC', decimals: 6, feePayer: FEE_PAYER },
+ ...overrides,
+ };
+}
+
+test('isSolanaNetwork recognizes the CAIP-2 ids and the bare alias', () => {
+ assert.ok(isSolanaNetwork(NETWORK_SOLANA_MAINNET));
+ assert.ok(isSolanaNetwork(NETWORK_SOLANA_DEVNET));
+ assert.ok(isSolanaNetwork('solana'));
+ assert.ok(!isSolanaNetwork('eip155:8453'));
+});
+
+test('encodeX402Payment produces a decodable v2 envelope', () => {
+ const { x_payment } = encodeX402Payment({
+ accept: accept(),
+ signedTxBase64: 'A'.repeat(80),
+ resourceUrl: 'https://example.com/api/paid',
+ });
+ const decoded = JSON.parse(Buffer.from(x_payment, 'base64').toString('utf8'));
+ assert.equal(decoded.x402Version, 2);
+ assert.equal(decoded.scheme, 'exact');
+ assert.equal(decoded.network, NETWORK_SOLANA_MAINNET);
+ assert.equal(decoded.resource.url, 'https://example.com/api/paid');
+ assert.equal(decoded.payload.transaction, 'A'.repeat(80));
+ assert.equal(decoded.extensions, undefined);
+});
+
+test('encodeX402Payment echoes a valid builder-code and drops a bad one', () => {
+ const good = encodeX402Payment({
+ accept: accept(),
+ signedTxBase64: 'A'.repeat(80),
+ resourceUrl: 'https://example.com/api/paid',
+ builderCode: { a: 'agentic', w: 'acme', s: ['acme_checkout', 'BAD CODE!'] },
+ });
+ const decoded = JSON.parse(Buffer.from(good.x_payment, 'base64').toString('utf8'));
+ assert.deepEqual(decoded.extensions['builder-code'], { a: 'agentic', w: 'acme', s: ['acme_checkout'] });
+
+ const noA = encodeX402Payment({
+ accept: accept(),
+ signedTxBase64: 'A'.repeat(80),
+ resourceUrl: 'https://example.com/api/paid',
+ builderCode: { w: 'acme' }, // missing required `a`
+ });
+ const decodedNoA = JSON.parse(Buffer.from(noA.x_payment, 'base64').toString('utf8'));
+ assert.equal(decodedNoA.extensions, undefined);
+});
+
+test('encodeX402Payment rejects a relative resource url', () => {
+ assert.throws(
+ () => encodeX402Payment({ accept: accept(), signedTxBase64: 'A'.repeat(80), resourceUrl: '/relative' }),
+ (e) => e instanceof CheckoutError && e.status === 400,
+ );
+});
+
+test('prepareSolanaCheckout rejects an EVM network before any RPC call', async () => {
+ await assert.rejects(
+ prepareSolanaCheckout({ accept: accept({ network: 'eip155:8453' }), buyer: BUYER }),
+ (e) => e instanceof CheckoutError && e.code === 'unsupported_network',
+ );
+});
+
+test('prepareSolanaCheckout rejects a bad buyer address before any RPC call', async () => {
+ await assert.rejects(
+ prepareSolanaCheckout({ accept: accept(), buyer: 'not-a-pubkey' }),
+ (e) => e instanceof CheckoutError && e.code === 'invalid_request',
+ );
+});
+
+test('prepareSolanaCheckout requires a fee payer', async () => {
+ await assert.rejects(
+ prepareSolanaCheckout({ accept: accept({ extra: { name: 'USDC', decimals: 6 } }), buyer: BUYER }),
+ (e) => e instanceof CheckoutError && e.code === 'invalid_request',
+ );
+});
+
+test('handleCheckout routes encode and returns 200', async () => {
+ const res = await handleCheckout({
+ action: 'encode',
+ body: {
+ accept: accept(),
+ signed_tx_base64: 'A'.repeat(80),
+ resource_url: 'https://example.com/api/paid',
+ },
+ });
+ assert.equal(res.status, 200);
+ assert.ok(typeof res.body.x_payment === 'string');
+});
+
+test('handleCheckout 404s an unknown action', async () => {
+ const res = await handleCheckout({ action: 'bogus', body: {} });
+ assert.equal(res.status, 404);
+ assert.equal(res.body.error, 'not_found');
+});
+
+test('handleCheckout maps a CheckoutError to its status', async () => {
+ const res = await handleCheckout({
+ action: 'prepare',
+ body: { accept: accept({ network: 'eip155:8453' }), buyer: BUYER },
+ });
+ assert.equal(res.status, 400);
+ assert.equal(res.body.error, 'unsupported_network');
+});
diff --git a/x402-payment-modal/types/index.d.ts b/x402-payment-modal/types/index.d.ts
new file mode 100644
index 000000000..c729ccf8a
--- /dev/null
+++ b/x402-payment-modal/types/index.d.ts
@@ -0,0 +1,118 @@
+// Type definitions for @three-ws/x402-payment-modal
+
+/** Client-side spending caps, enforced in localStorage before each payment. */
+export interface SpendingCaps {
+ /** Max atomic micro-USD per single call. */
+ maxPerCall?: string | number;
+ /** Max atomic micro-USD per rolling UTC hour. */
+ maxPerHour?: string | number;
+ /** Max atomic micro-USD per rolling UTC day. */
+ maxPerDay?: string | number;
+}
+
+/** Options for {@link pay}. */
+export interface PayOptions {
+ /** URL of the paid (x402) endpoint. Required. */
+ endpoint: string;
+ /** HTTP method to call the endpoint with. Defaults to GET, or POST if `body` is set. */
+ method?: string;
+ /** Request body. Objects are JSON-stringified; strings are sent as-is. */
+ body?: unknown;
+ /** Extra request headers merged into the paid call. */
+ headers?: Record<string, string>;
+ /** Merchant name shown in the modal header. */
+ merchant?: string;
+ /** Action label shown in the modal header. */
+ action?: string;
+ /** Skip the wallet picker and open the wallet directly when exactly one supported wallet is detected. */
+ autoConnect?: boolean;
+ /** Client-side spending caps (stablecoin assets only in the browser). */
+ caps?: SpendingCaps;
+}
+
+/** Settlement details returned by the facilitator on a paid call. */
+export interface PaymentReceipt {
+ network?: string;
+ transaction?: string;
+ payer?: string;
+}
+
+/** SIWX re-entry details when the wallet signed in instead of paying. */
+export interface SiwxReceipt {
+ address: string;
+ network: string | number;
+}
+
+/** Resolved value of {@link pay}. */
+export interface PayResult {
+ ok: true;
+ /** Parsed JSON (or text) the paid endpoint returned. */
+ result: unknown;
+ /** Present on a paid call. */
+ payment?: PaymentReceipt;
+ /** Present when re-entry happened via SIWX instead of a payment. */
+ siwx?: SiwxReceipt;
+ response: {
+ status: number;
+ headers: Record<string, string>;
+ };
+}
+
+/** Branding shown in the modal footer. */
+export interface BrandConfig {
+ name?: string;
+ url?: string;
+}
+
+/** ERC-8021 builder-code self-attribution echoed when the 402 challenge declares one. */
+export interface BuilderCodeConfig {
+ wallet?: string;
+ service?: string;
+}
+
+/** CDN URLs for the crypto helpers loaded on demand. */
+export interface EsmConfig {
+ solanaWeb3?: string;
+ nobleHashesSha3?: string;
+}
+
+/** Host configuration. See {@link configure}. */
+export interface X402Config {
+ checkoutOrigin?: string | null;
+ checkoutPath?: string;
+ brand?: BrandConfig;
+ footerNote?: string;
+ builderCode?: BuilderCodeConfig;
+ esm?: EsmConfig;
+}
+
+/**
+ * Override host configuration (Solana checkout origin, branding, builder-code,
+ * esm.sh CDN URLs). Shallow-merges nested objects. Call before the first `pay()`.
+ * Returns the resolved config.
+ */
+export function configure(opts?: X402Config): Required<X402Config>;
+
+/**
+ * Open the payment modal for an x402 endpoint and resolve when the user completes
+ * (or rejects with `{ code: 'cancelled' }` if dismissed).
+ */
+export function pay(opts: PayOptions): Promise<PayResult>;
+
+/** Bind all `[data-x402-endpoint]` elements on the page (called automatically on load). */
+export function init(): void;
+
+/** Library version. */
+export const version: string;
+
+/** Global exposed for non-module / inline-script usage. */
+declare global {
+ interface Window {
+ X402?: {
+ pay: typeof pay;
+ init: typeof init;
+ configure: typeof configure;
+ version: string;
+ };
+ }
+}
diff --git a/x402-payment-modal/types/server.d.ts b/x402-payment-modal/types/server.d.ts
new file mode 100644
index 000000000..6e7b9ca2a
--- /dev/null
+++ b/x402-payment-modal/types/server.d.ts
@@ -0,0 +1,73 @@
+// Type definitions for @three-ws/x402-payment-modal/server
+
+/** One x402 `accept` entry (scheme "exact", Solana network). */
+export interface SolanaAccept {
+ scheme: 'exact';
+ network: string;
+ /** Atomic integer amount as a string. */
+ amount: string;
+ /** Mint address (base58). */
+ asset: string;
+ /** Recipient address (base58). */
+ payTo: string;
+ maxTimeoutSeconds?: number;
+ extra: {
+ name?: string;
+ decimals?: number;
+ /** Facilitator sponsor account that pays the SOL network fee (base58). */
+ feePayer: string;
+ [key: string]: unknown;
+ };
+}
+
+export interface CheckoutOptions {
+ /** Solana mainnet RPC URL. */
+ rpcUrl?: string;
+ /** Solana devnet RPC URL. */
+ devnetRpcUrl?: string;
+ /** Access-Control-Allow-Origin for the adapters. Default '*'. */
+ origin?: string;
+}
+
+export interface PrepareResult {
+ network: string;
+ tx_base64: string;
+ recent_blockhash: string;
+}
+
+export interface BuilderCodeEcho {
+ a: string;
+ w?: string;
+ s?: string[];
+}
+
+export const X402_VERSION: number;
+export const NETWORK_SOLANA_MAINNET: string;
+export const NETWORK_SOLANA_DEVNET: string;
+
+export class CheckoutError extends Error {
+ status: number;
+ code: string;
+}
+
+export function isSolanaNetwork(network: string): boolean;
+
+export function prepareSolanaCheckout(args: {
+ accept: SolanaAccept;
+ buyer: string;
+ rpcUrl?: string;
+ devnetRpcUrl?: string;
+}): Promise<PrepareResult>;
+
+export function encodeX402Payment(args: {
+ accept: SolanaAccept;
+ signedTxBase64: string;
+ resourceUrl: string;
+ builderCode?: BuilderCodeEcho;
+}): { x_payment: string };
+
+export function handleCheckout(args: {
+ action: 'prepare' | 'encode' | string;
+ body?: Record<string, unknown>;
+ options?: CheckoutOptions;
+}): Promise<{ status: number; body: Record<string, unknown> }>;