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(erc8004): chain dropdown on /agent/:id deploy chip; mainnet default
nirholasfb0c6d704192
diff --git a/src/erc8004/chain-meta.js b/src/erc8004/chain-meta.jsindex 778ee78d6..750008e2a 100644--- a/src/erc8004/chain-meta.js+++ b/src/erc8004/chain-meta.js@@ -196,7 +196,7 @@ export const CHAIN_META = {},};-export const DEFAULT_CHAIN_ID = 97; // BSC Testnet+export const DEFAULT_CHAIN_ID = 8453; // Base mainnet/** @returns {number[]} All chain IDs where both CHAIN_META and REGISTRY_DEPLOYMENTS exist. */export function supportedChainIds() {@@ -205,6 +205,19 @@ export function supportedChainIds() {.filter((id) => REGISTRY_DEPLOYMENTS[id]);}+/**+ * Same set as supportedChainIds() but split into mainnets and testnets.+ * @returns {{ mainnets: number[], testnets: number[] }}+ */+export function supportedChainIdsGrouped() {+ const mainnets = [];+ const testnets = [];+ for (const id of supportedChainIds()) {+ (CHAIN_META[id]?.testnet ? testnets : mainnets).push(id);+ }+ return { mainnets, testnets };+}+/** @param {number} chainId */export function chainIdHex(chainId) {return '0x' + chainId.toString(16);diff --git a/src/erc8004/deploy-button.css b/src/erc8004/deploy-button.cssindex 2940bf3c9..f010f5d7a 100644--- a/src/erc8004/deploy-button.css+++ b/src/erc8004/deploy-button.css@@ -6,6 +6,59 @@font-family: inherit;}+/* ── Chain select + deploy row ───────────────────────────────────────────── */++.deploy-chain-row {+ display: inline-flex;+ align-items: center;+ gap: 0.5em;+ flex-wrap: wrap;+}++.deploy-chain-select {+ padding: 0.4em 0.65em;+ border: 1.5px solid #6c63ff;+ border-radius: 6px;+ background: transparent;+ color: #a89fff;+ font-family: inherit;+ font-size: 0.82rem;+ font-weight: 500;+ cursor: pointer;+ transition:+ background 0.15s,+ border-color 0.15s,+ color 0.15s;+ max-width: 12em;+}++.deploy-chain-select:hover:not(:disabled) {+ background: #6c63ff15;+ color: #fff;+ border-color: #a89fff;+}++.deploy-chain-select:focus-visible {+ outline: 2px solid #a89fff;+ outline-offset: 2px;+}++.deploy-chain-select:disabled {+ opacity: 0.6;+ cursor: progress;+}++.deploy-chain-select optgroup {+ color: #888;+ font-style: italic;+}++.deploy-chain-select option {+ background: #14141c;+ color: #e6e6e6;+ font-style: normal;+}+/* ── Deploy button ───────────────────────────────────────────────────────── */.deploy-btn {@@ -153,6 +206,22 @@/* ── Light-mode overrides ────────────────────────────────────────────────── */@media (prefers-color-scheme: light) {+ .deploy-chain-select {+ border-color: #4f46e5;+ color: #4f46e5;+ }++ .deploy-chain-select:hover:not(:disabled) {+ background: #4f46e511;+ color: #312e81;+ border-color: #4f46e5;+ }++ .deploy-chain-select option {+ background: #fff;+ color: #1e1b4b;+ }+.deploy-btn {border-color: #4f46e5;color: #4f46e5;diff --git a/src/erc8004/deploy-button.js b/src/erc8004/deploy-button.jsindex 1c80ce19e..76c4be6a1 100644--- a/src/erc8004/deploy-button.js+++ b/src/erc8004/deploy-button.js@@ -8,11 +8,15 @@import { connectWallet, getIdentityRegistry } from './agent-registry.js';import { REGISTRY_DEPLOYMENTS } from './abi.js';-import { CHAIN_META, switchChain, txExplorerUrl } from './chain-meta.js';+import {+ CHAIN_META,+ DEFAULT_CHAIN_ID,+ supportedChainIdsGrouped,+ switchChain,+ txExplorerUrl,+} from './chain-meta.js';import { BrowserProvider } from 'ethers';-const BASE_SEPOLIA = 84532;-// Faucet links per testnet chainIdconst FAUCETS = {84532: 'https://www.coinbase.com/faucets/base-ethereum-goerli-faucet',@@ -29,9 +33,9 @@ export class DeployButton {* @param {object} opts* @param {object} opts.agent Agent object (must have .id and optionally .chainId, .txHash, .manifestUrl, .name)* @param {HTMLElement} opts.container Where to mount- * @param {number} [opts.preferredChainId] Defaults to Base Sepolia (84532)+ * @param {number} [opts.preferredChainId] Defaults to DEFAULT_CHAIN_ID*/- constructor({ agent, container, preferredChainId = BASE_SEPOLIA }) {+ constructor({ agent, container, preferredChainId = DEFAULT_CHAIN_ID }) {this._agent = agent;this._container = container;this._chainId = preferredChainId;@@ -66,11 +70,47 @@ export class DeployButton {}_renderDeployButton() {+ const { mainnets, testnets } = supportedChainIdsGrouped();+ const optionsFor = (ids) =>+ ids+ .map(+ (id) =>+ `<option value="${id}"${id === this._chainId ? ' selected' : ''}>${_esc(+ CHAIN_META[id]?.name || `Chain ${id}`,+ )}</option>`,+ )+ .join('');+this._root.innerHTML = `- <button class="deploy-btn" title="Deploy this agent as an ERC-8004 token on-chain">- ⬢ Deploy on-chain- </button>+ <div class="deploy-chain-row">+ <select class="deploy-chain-select" title="Choose chain to deploy to" aria-label="Target chain">+ <optgroup label="Mainnets">${optionsFor(mainnets)}</optgroup>+ <optgroup label="Testnets">${optionsFor(testnets)}</optgroup>+ </select>+ <button class="deploy-btn" title="Deploy this agent as an ERC-8004 token on-chain">+ ⬢ Deploy on-chain+ </button>+ </div>`;++ const select = this._root.querySelector('.deploy-chain-select');+ select.addEventListener('change', async (ev) => {+ const newChainId = Number(ev.target.value);+ this._chainId = newChainId;+ if (typeof window !== 'undefined' && window.ethereum) {+ select.disabled = true;+ try {+ await switchChain(newChainId);+ } catch (err) {+ if (!/rejected|denied/i.test(err?.message || '')) {+ console.warn('[deploy-button] switchChain failed:', err?.message);+ }+ } finally {+ select.disabled = false;+ }+ }+ });+this._root.querySelector('.deploy-btn').addEventListener('click', () => this._startDeploy());diff --git a/src/erc8004/register-ui.js b/src/erc8004/register-ui.jsindex 7d7b0bd37..8a6d3cdfa 100644--- a/src/erc8004/register-ui.js+++ b/src/erc8004/register-ui.js@@ -420,27 +420,27 @@ export class RegisterUI {_populateChainSelect() {const sel = this.el.querySelector('.erc8004-chain-select');const ids = supportedChainIds();- // Testnets first (default-friendly), then mainnets- const testnets = ids.filter((id) => CHAIN_META[id].testnet);+ // Mainnets first (production-default), then testnetsconst mainnets = ids.filter((id) => !CHAIN_META[id].testnet);- const groupT = document.createElement('optgroup');- groupT.label = 'Testnets';+ const testnets = ids.filter((id) => CHAIN_META[id].testnet);const groupM = document.createElement('optgroup');groupM.label = 'Mainnets';- for (const id of testnets) {+ const groupT = document.createElement('optgroup');+ groupT.label = 'Testnets';+ for (const id of mainnets) {const opt = document.createElement('option');opt.value = String(id);opt.textContent = CHAIN_META[id].name;- groupT.appendChild(opt);+ groupM.appendChild(opt);}- for (const id of mainnets) {+ for (const id of testnets) {const opt = document.createElement('option');opt.value = String(id);opt.textContent = CHAIN_META[id].name;- groupM.appendChild(opt);+ groupT.appendChild(opt);}- sel.appendChild(groupT);sel.appendChild(groupM);+ sel.appendChild(groupT);sel.value = String(this.selectedChainId);}