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: eth vanity agent API, skill-prices overhaul, pump launch, marketplace + UI polish

nirholasdcc1903034e6
diff --git a/api/_lib/schema.sql b/api/_lib/schema.sql
index 3cd1535cb..9a6c53893 100644
--- a/api/_lib/schema.sql
+++ b/api/_lib/schema.sql
@@ -993,97 +993,71 @@ create index if not exists pumpfun_graduations_mint on pumpfun_graduations(mint)
create index if not exists pumpfun_graduations_creator on pumpfun_graduations(creator) where creator is not null;
-- ── agent_skill_prices ───────────────────────────────────────────────────────
--- Stores pricing information for premium agent skills.
+-- Per-skill price set by the agent owner. Authoritative source of truth for
+-- "is this skill paid, and how much?". See migration 2026-04-30-agent-monetization.sql.
CREATE TABLE IF NOT EXISTS agent_skill_prices (
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
- agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,
- skill_name TEXT NOT NULL,
- amount BIGINT NOT NULL,
- currency_mint VARCHAR(44) NOT NULL,
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- UNIQUE (agent_id, skill_name)
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
+ agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,
+ skill TEXT NOT NULL,
+ currency_mint TEXT NOT NULL,
+ chain TEXT NOT NULL DEFAULT 'solana',
+ amount BIGINT NOT NULL,
+ is_active BOOLEAN NOT NULL DEFAULT true,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+ UNIQUE (agent_id, skill)
);
-CREATE INDEX IF NOT EXISTS idx_agent_skill_prices_on_agent_id ON agent_skill_prices(agent_id);
+CREATE INDEX IF NOT EXISTS agent_skill_prices_agent_id ON agent_skill_prices(agent_id);
+-- ── skill_purchases ─────────────────────────────────────────────────────────
+-- Per-buyer skill ownership ledger. Pending row is created when buyer initiates
+-- the Solana Pay flow; status flips to 'confirmed' once on-chain transfer is
+-- verified by /api/marketplace/purchase/:reference/confirm or by the
+-- /api/webhooks/solana-pay endpoint. See migration 2026-05-10-skill-purchases.sql.
CREATE TABLE IF NOT EXISTS skill_purchases (
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
- user_id uuid NOT NULL REFERENCES users (id),
- agent_id uuid NOT NULL REFERENCES agent_identities (id),
- skill_name varchar(255) NOT NULL,
- transaction_signature varchar(255) UNIQUE NOT NULL,
- amount bigint NOT NULL,
- currency_mint varchar(255) NOT NULL,
- created_at timestamptz NOT NULL DEFAULT now()
-);
-
-CREATE INDEX IF NOT EXISTS idx_skill_purchases_user_id ON skill_purchases (user_id);
-CREATE INDEX IF NOT EXISTS idx_skill_purchases_agent_id ON skill_purchases (agent_id);
-
-CREATE TABLE IF NOT EXISTS agent_payment_intents (
- id TEXT PRIMARY KEY,
- payer_user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
- agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
+ user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
+ agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,
+ skill TEXT NOT NULL,
+ status TEXT NOT NULL DEFAULT 'pending'
+ CHECK (status IN ('pending', 'confirmed', 'failed')),
+ reference TEXT NOT NULL UNIQUE,
+ tx_signature TEXT UNIQUE,
+ amount BIGINT NOT NULL,
currency_mint TEXT NOT NULL,
- amount BIGINT NOT NULL,
- status TEXT NOT NULL DEFAULT 'pending',
- expires_at TIMESTAMPTZ NOT NULL,
- payload JSONB NOT NULL,
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
+ chain TEXT NOT NULL DEFAULT 'solana',
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+ confirmed_at TIMESTAMPTZ
);
- skill_id TEXT NOT NULL,
- creator_id UUID NOT NULL REFERENCES users(id),
- amount BIGINT NOT NULL CHECK (amount > 0),
- currency_mint TEXT NOT NULL,
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- deleted_at TIMESTAMPTZ
-);
+CREATE UNIQUE INDEX IF NOT EXISTS skill_purchases_one_confirmed_per_user
+ ON skill_purchases (user_id, agent_id, skill)
+ WHERE status = 'confirmed';
-CREATE UNIQUE INDEX IF NOT EXISTS idx_agent_skill_prices_one_price_per_skill
-ON agent_skill_prices (agent_id, skill_id)
-WHERE deleted_at IS NULL;
-
-CREATE INDEX IF NOT EXISTS idx_agent_skill_prices_creator_id ON agent_skill_prices(creator_id);
-
--- ── user_skill_purchases ─────────────────────────────────────────────────────
--- Tracks which users have purchased which skills.
-CREATE TYPE purchase_status AS ENUM ('pending', 'confirmed', 'failed');
-
-CREATE TABLE IF NOT EXISTS user_skill_purchases (
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
- user_id UUID NOT NULL REFERENCES users(id),
- agent_id UUID NOT NULL REFERENCES agent_identities(id),
- skill_id TEXT NOT NULL,
- price_id UUID NOT NULL REFERENCES agent_skill_prices(id),
- transaction_id TEXT, -- e.g., Solana transaction signature
- status purchase_status NOT NULL DEFAULT 'pending',
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
-);
+CREATE INDEX IF NOT EXISTS skill_purchases_user_agent ON skill_purchases (user_id, agent_id);
+CREATE INDEX IF NOT EXISTS skill_purchases_agent ON skill_purchases (agent_id);
+CREATE INDEX IF NOT EXISTS skill_purchases_status_created ON skill_purchases (status, created_at DESC);
-CREATE UNIQUE INDEX IF NOT EXISTS idx_user_skill_purchases_one_per_user
-ON user_skill_purchases (user_id, agent_id, skill_id);
-
-CREATE INDEX IF NOT EXISTS idx_user_skill_purchases_tx_id ON user_skill_purchases(transaction_id);
-
--- ── agent_skill_prices — monetization for agent skills ──────────────────────
-CREATE TABLE IF NOT EXISTS agent_skill_prices (
- agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,
- skill_id TEXT NOT NULL,
- amount BIGINT NOT NULL CHECK (amount > 0),
- currency_mint TEXT NOT NULL,
- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
- PRIMARY KEY (agent_id, skill_id)
+-- ── agent_payment_intents ────────────────────────────────────────────────────
+-- Generic payment intent (subscriptions, one-shot, x402 invocations). Skill
+-- purchases get a synthetic intent with id 'sp_<skill_purchase_id>' on confirm
+-- so agent_revenue_events.intent_id FK can point at it.
+CREATE TABLE IF NOT EXISTS agent_payment_intents (
+ id TEXT PRIMARY KEY,
+ payer_user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
+ agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,
+ currency_mint TEXT NOT NULL,
+ amount TEXT NOT NULL,
+ memo TEXT,
+ start_time TIMESTAMPTZ,
+ end_time TIMESTAMPTZ,
+ status TEXT NOT NULL DEFAULT 'pending',
+ cluster TEXT,
+ tx_signature TEXT,
+ paid_at TIMESTAMPTZ,
+ payload JSONB NOT NULL DEFAULT '{}'::jsonb,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+ expires_at TIMESTAMPTZ NOT NULL
);
-
-CREATE INDEX IF NOT EXISTS idx_agent_skill_prices_agent_id ON agent_skill_prices(agent_id);
-
-CREATE TRIGGER set_timestamp
-BEFORE UPDATE ON agent_skill_prices
-FOR EACH ROW
-EXECUTE PROCEDURE set_updated_at();
diff --git a/api/_lib/x402-spec.js b/api/_lib/x402-spec.js
index 55ae0ca98..39c3ca36f 100644
--- a/api/_lib/x402-spec.js
+++ b/api/_lib/x402-spec.js
@@ -69,7 +69,10 @@ export function paymentRequirements() {
network: NETWORK_BASE_MAINNET,
payTo: env.X402_PAY_TO_BASE,
asset: env.X402_ASSET_ADDRESS_BASE,
- extra: { name: 'USDC', version: '2', decimals: 6 },
+ // `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_SOLANA) {
diff --git a/api/agents/[id].js b/api/agents/[id].js
index 267a033b4..881941a80 100644
--- a/api/agents/[id].js
+++ b/api/agents/[id].js
@@ -42,6 +42,11 @@ export default wrap(async function handler(req, res) {
return mod.default(req, res, id, action);
}
+ if (sub === 'eth-vanity') {
+ const mod = await import('./eth-vanity.js');
+ return mod.default(req, res, id, action);
+ }
+
if (sub === 'sns') {
const mod = await import('./sns.js');
return mod.default(req, res, id, action);
diff --git a/api/agents/[id]/skill-prices.js b/api/agents/[id]/skill-prices.js
index ef563d470..651c578f1 100644
--- a/api/agents/[id]/skill-prices.js
+++ b/api/agents/[id]/skill-prices.js
@@ -1,71 +1,112 @@
+/**
+ * /api/agents/:id/skill-prices
+ * Per-skill price CRUD on the agent's skill catalog.
+ * POST { skill, amount, currency_mint, chain? } — set/update one price
+ * PUT { skill, amount } — update amount only
+ * DELETE { skill } — deactivate the price
+ *
+ * Bulk equivalent (replace-all): PUT /api/agents/:id/skills-pricing
+ */
+
import { sql } from '../../_lib/db.js';
-import { getSessionUser } from '../../_lib/auth.js';
-import { error, json, wrap } from '../../_lib/http.js';
+import { authenticateBearer, extractBearer, getSessionUser } from '../../_lib/auth.js';
+import { cors, error, json, method, readJson, wrap } from '../../_lib/http.js';
+import { clientIp, limits } from '../../_lib/rate-limit.js';
import { z } from 'zod';
-const priceSchema = z.object({
- skill_id: z.string().min(1),
- amount: z.number().int().positive(),
- currency_mint: z.string().min(32), // Solana mint address length
+const upsertSchema = z.object({
+ skill: z.string().trim().min(1).max(100),
+ amount: z.number().int().min(1),
+ currency_mint: z.string().trim().min(1).max(100),
+ chain: z.string().trim().min(1).max(20).default('solana'),
});
-const updatePriceSchema = z.object({
- skill_id: z.string().min(1),
- amount: z.number().int().positive(),
+const updateSchema = z.object({
+ skill: z.string().trim().min(1).max(100),
+ amount: z.number().int().min(1),
});
-const deletePriceSchema = z.object({
- skill_id: z.string().min(1),
+const deleteSchema = z.object({
+ skill: z.string().trim().min(1).max(100),
});
+async function resolveAuth(req) {
+ const session = await getSessionUser(req);
+ if (session) return { userId: session.id };
+ const bearer = await authenticateBearer(extractBearer(req));
+ if (bearer) return { userId: bearer.userId };
+ return null;
+}
+
export default wrap(async (req, res) => {
- const user = await getSessionUser(req);
- if (!user) return error(res, 401, 'unauthorized');
+ if (cors(req, res, { methods: 'POST,PUT,DELETE,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST', 'PUT', 'DELETE'])) return;
+
+ const auth = await resolveAuth(req);
+ if (!auth) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
- const agentId = req.query.id;
- const [agent] = await sql`
- SELECT user_id FROM agent_identities WHERE id = ${agentId} AND deleted_at IS NULL
- `;
+ const url = new URL(req.url, 'http://x');
+ const parts = url.pathname.split('/').filter(Boolean);
+ const agentId = url.searchParams.get('id') || parts[2];
+ if (!agentId) return error(res, 400, 'validation_error', 'agent id required');
- if (!agent || agent.user_id !== user.id) {
- return error(res, 403, 'forbidden', 'You do not own this agent.');
- }
+ const [agent] = await sql`
+ SELECT id, user_id FROM agent_identities
+ WHERE id = ${agentId} AND deleted_at IS NULL
+ `;
+ if (!agent) return error(res, 404, 'not_found', 'agent not found');
+ if (agent.user_id !== auth.userId) return error(res, 403, 'forbidden', 'not your agent');
- if (req.method === 'POST') {
- const body = priceSchema.parse(await readJson(req));
- await sql`
- INSERT INTO agent_skill_prices (agent_id, skill_id, creator_id, amount, currency_mint)
- VALUES (${agentId}, ${body.skill_id}, ${user.id}, ${body.amount}, ${body.currency_mint})
- ON CONFLICT (agent_id, skill_id) WHERE deleted_at IS NULL
- DO UPDATE SET
- amount = EXCLUDED.amount,
- currency_mint = EXCLUDED.currency_mint,
- creator_id = EXCLUDED.creator_id,
- updated_at = NOW(),
- deleted_at = NULL
- `;
- return json(res, { success: true });
- }
+ const body = await readJson(req).catch(() => null);
+ if (!body) return error(res, 400, 'validation_error', 'request body required');
- if (req.method === 'PUT') {
- const body = updatePriceSchema.parse(await readJson(req));
- await sql`
- UPDATE agent_skill_prices
- SET amount = ${body.amount}, updated_at = NOW()
- WHERE agent_id = ${agentId} AND skill_id = ${body.skill_id} AND deleted_at IS NULL
- `;
- return json(res, { success: true });
- }
+ if (req.method === 'POST') {
+ const parsed = upsertSchema.safeParse(body);
+ if (!parsed.success) {
+ return error(res, 400, 'validation_error', parsed.error.issues[0]?.message || 'invalid');
+ }
+ const { skill, amount, currency_mint, chain } = parsed.data;
+ await sql`
+ INSERT INTO agent_skill_prices (agent_id, skill, amount, currency_mint, chain, is_active)
+ VALUES (${agentId}, ${skill}, ${amount}, ${currency_mint}, ${chain}, true)
+ ON CONFLICT (agent_id, skill) DO UPDATE SET
+ amount = EXCLUDED.amount,
+ currency_mint = EXCLUDED.currency_mint,
+ chain = EXCLUDED.chain,
+ is_active = true,
+ updated_at = now()
+ `;
+ return json(res, 200, { data: { ok: true } });
+ }
- if (req.method === 'DELETE') {
- const body = deletePriceSchema.parse(await readJson(req));
- await sql`
- UPDATE agent_skill_prices
- SET deleted_at = NOW()
- WHERE agent_id = ${agentId} AND skill_id = ${body.skill_id}
- `;
- return json(res, { success: true });
- }
+ if (req.method === 'PUT') {
+ const parsed = updateSchema.safeParse(body);
+ if (!parsed.success) {
+ return error(res, 400, 'validation_error', parsed.error.issues[0]?.message || 'invalid');
+ }
+ const { skill, amount } = parsed.data;
+ const r = await sql`
+ UPDATE agent_skill_prices
+ SET amount = ${amount}, updated_at = now()
+ WHERE agent_id = ${agentId} AND skill = ${skill}
+ RETURNING agent_id
+ `;
+ if (r.length === 0) return error(res, 404, 'not_found', 'no existing price for this skill');
+ return json(res, 200, { data: { ok: true } });
+ }
- return error(res, 405, 'method_not_allowed');
+ // DELETE — soft-deactivate
+ const parsed = deleteSchema.safeParse(body);
+ if (!parsed.success) {
+ return error(res, 400, 'validation_error', parsed.error.issues[0]?.message || 'invalid');
+ }
+ await sql`
+ UPDATE agent_skill_prices
+ SET is_active = false, updated_at = now()
+ WHERE agent_id = ${agentId} AND skill = ${parsed.data.skill}
+ `;
+ return json(res, 200, { data: { ok: true } });
});
diff --git a/api/agents/eth-vanity.js b/api/agents/eth-vanity.js
new file mode 100644
index 000000000..5f752e122
--- /dev/null
+++ b/api/agents/eth-vanity.js
@@ -0,0 +1,176 @@
+// /api/agents/:id/eth-vanity — assign / read / delete a CREATE2 vanity record.
+//
+// Stores the salt + factory + initCode(Hash) the owner ground in the
+// browser at /eth-vanity. Unlike the Solana custodial wallet, this record
+// holds NO secret material — the predicted address is just a deterministic
+// function of (deployer, salt, initCodeHash). The owner deploys the
+// contract themselves with their own EVM signer.
+//
+// Persisted under agent_identities.meta.eth_vanity:
+// {
+// deployer: "0x…20 bytes…",
+// init_code_hash: "0x…32 bytes…",
+// init_code: "0x…" | null, // optional raw bytecode for deploy convenience
+// salt: "0x…32 bytes…",
+// predicted_address: "0x…20 bytes…",
+// prefix: "beef" | null,
+// suffix: "cafe" | null,
+// deployer_label: "CreateX" | null,
+// created_at: ISO,
+// deployed: {
+// chain_id: 8453,
+// tx_hash: "0x…",
+// at: ISO
+// } | null
+// }
+
+import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';
+import { sql } from '../_lib/db.js';
+import { cors, json, method, error, readJson } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { keccak_256 } from '@noble/hashes/sha3';
+
+const HEX_RE = /^0x[0-9a-f]+$/i;
+const ADDR_RE = /^0x[0-9a-f]{40}$/i;
+const HASH_RE = /^0x[0-9a-f]{64}$/i;
+const TX_RE = /^0x[0-9a-f]{64}$/i;
+
+async function resolveAuth(req) {
+ const session = await getSessionUser(req);
+ if (session) return { userId: session.id };
+ const bearer = await authenticateBearer(extractBearer(req));
+ if (bearer) return { userId: bearer.userId };
+ return null;
+}
+
+function _hexToBytes(hex) {
+ const h = hex.startsWith('0x') ? hex.slice(2) : hex;
+ const out = new Uint8Array(h.length / 2);
+ for (let i = 0; i < out.length; i++) out[i] = parseInt(h.substring(i * 2, i * 2 + 2), 16);
+ return out;
+}
+function _bytesToHex(b) {
+ let s = ''; for (let i = 0; i < b.length; i++) s += b[i].toString(16).padStart(2, '0');
+ return s;
+}
+
+/**
+ * Re-derive the CREATE2 address server-side and verify it matches the
+ * client-supplied prediction. Anyone can claim "this salt produces that
+ * address"; we don't take their word for it.
+ */
+function _verifyCreate2(deployer, salt, initCodeHash, predicted) {
+ const buf = new Uint8Array(85);
+ buf[0] = 0xff;
+ buf.set(_hexToBytes(deployer), 1);
+ buf.set(_hexToBytes(salt), 21);
+ buf.set(_hexToBytes(initCodeHash), 53);
+ const digest = keccak_256(buf);
+ const derived = '0x' + _bytesToHex(digest.subarray(12));
+ return derived.toLowerCase() === predicted.toLowerCase();
+}
+
+export default async function handler(req, res, id, action) {
+ if (cors(req, res, { methods: 'GET,POST,DELETE,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['GET', 'POST', 'DELETE'])) return;
+
+ const auth = await resolveAuth(req);
+ if (!auth) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const rl = req.method === 'GET'
+ ? await limits.walletRead(auth.userId)
+ : await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const [row] = await sql`SELECT id, user_id, meta FROM agent_identities WHERE id = ${id} AND deleted_at IS NULL`;
+ if (!row) return error(res, 404, 'not_found', 'agent not found');
+ if (row.user_id !== auth.userId) return error(res, 403, 'forbidden', 'not your agent');
+
+ let meta = { ...(row.meta || {}) };
+
+ if (req.method === 'DELETE') {
+ delete meta.eth_vanity;
+ await sql`UPDATE agent_identities SET meta = ${JSON.stringify(meta)}::jsonb WHERE id = ${id}`;
+ return json(res, 200, { data: { ok: true } });
+ }
+
+ if (req.method === 'POST') {
+ const body = await readJson(req).catch(() => ({}));
+
+ // "Mark as deployed" sub-action — record an on-chain deployment of the
+ // existing saved record. Owner deploys with their own signer; this is
+ // just metadata we use to hide the Deploy button afterwards.
+ if (action === 'deployed' || body.mark_deployed) {
+ if (!meta.eth_vanity) return error(res, 404, 'not_found', 'no vanity record to mark deployed');
+ const chainId = Number(body.chain_id);
+ const txHash = String(body.tx_hash || '');
+ if (!Number.isInteger(chainId) || chainId <= 0) return error(res, 400, 'validation_error', 'chain_id must be a positive integer');
+ if (!TX_RE.test(txHash)) return error(res, 400, 'validation_error', 'tx_hash must be 0x + 64 hex');
+ meta.eth_vanity = {
+ ...meta.eth_vanity,
+ deployed: { chain_id: chainId, tx_hash: txHash.toLowerCase(), at: new Date().toISOString() },
+ };
+ await sql`UPDATE agent_identities SET meta = ${JSON.stringify(meta)}::jsonb WHERE id = ${id}`;
+ return json(res, 200, { data: meta.eth_vanity });
+ }
+
+ // Save / replace.
+ const deployer = String(body.deployer || '').toLowerCase();
+ const salt = String(body.salt || '').toLowerCase();
+ const ich = String(body.init_code_hash || body.initCodeHash || '').toLowerCase();
+ const pred = String(body.predicted_address || body.address || '').toLowerCase();
+ const initCode = body.init_code || body.initCode || null;
+ const prefix = body.prefix ? String(body.prefix).toLowerCase().replace(/^0x/, '') : null;
+ const suffix = body.suffix ? String(body.suffix).toLowerCase().replace(/^0x/, '') : null;
+ const label = body.deployer_label ? String(body.deployer_label).slice(0, 64) : null;
+
+ if (!ADDR_RE.test(deployer)) return error(res, 400, 'validation_error', 'deployer must be 0x + 40 hex');
+ if (!HASH_RE.test(salt)) return error(res, 400, 'validation_error', 'salt must be 0x + 64 hex');
+ if (!HASH_RE.test(ich)) return error(res, 400, 'validation_error', 'init_code_hash must be 0x + 64 hex');
+ if (!ADDR_RE.test(pred)) return error(res, 400, 'validation_error', 'predicted_address must be 0x + 40 hex');
+ if (initCode != null && (typeof initCode !== 'string' || !HEX_RE.test(initCode))) {
+ return error(res, 400, 'validation_error', 'init_code must be a 0x-prefixed hex string');
+ }
+ if (prefix && !/^[0-9a-f]+$/.test(prefix)) return error(res, 400, 'validation_error', 'prefix must be hex');
+ if (suffix && !/^[0-9a-f]+$/.test(suffix)) return error(res, 400, 'validation_error', 'suffix must be hex');
+
+ // Re-derive server-side — refuse the request if the supplied address
+ // doesn't actually match (deployer, salt, initCodeHash).
+ if (!_verifyCreate2(deployer, salt, ich, pred)) {
+ return error(res, 400, 'validation_error', 'predicted_address does not match keccak256(0xff‖deployer‖salt‖init_code_hash)');
+ }
+
+ // If raw init_code was supplied, verify its hash matches.
+ if (initCode) {
+ const computed = '0x' + _bytesToHex(keccak_256(_hexToBytes(initCode)));
+ if (computed.toLowerCase() !== ich) {
+ return error(res, 400, 'validation_error', 'init_code does not hash to init_code_hash');
+ }
+ }
+
+ // If the agent already has a vanity record, require explicit DELETE first
+ // (matches the Solana wallet semantics).
+ if (meta.eth_vanity) {
+ return error(res, 409, 'conflict', 'agent already has an eth vanity record — DELETE /api/agents/:id/eth-vanity first to replace');
+ }
+
+ meta.eth_vanity = {
+ deployer,
+ init_code_hash: ich,
+ init_code: initCode || null,
+ salt,
+ predicted_address: pred,
+ prefix,
+ suffix,
+ deployer_label: label,
+ created_at: new Date().toISOString(),
+ deployed: null,
+ };
+ await sql`UPDATE agent_identities SET meta = ${JSON.stringify(meta)}::jsonb WHERE id = ${id}`;
+ return json(res, 201, { data: meta.eth_vanity });
+ }
+
+ // GET
+ if (!meta.eth_vanity) return error(res, 404, 'not_found', 'agent has no eth vanity record');
+ return json(res, 200, { data: meta.eth_vanity });
+}
diff --git a/api/marketplace/purchase.js b/api/marketplace/purchase.js
index 4ccaedb6f..a61a0a420 100644
--- a/api/marketplace/purchase.js
+++ b/api/marketplace/purchase.js
@@ -260,15 +260,39 @@ async function handleConfirm(req, res, reference) {
return error(res, 409, 'transfer_mismatch', `on-chain transfer did not match expected: ${e.message}`);
}
- // Atomic confirm. The status='pending' guard keeps concurrent confirms idempotent.
- // Revenue aggregation is derived from skill_purchases at query time; we don't
- // write to agent_revenue_events here because its intent_id FK constrains it
- // to the agent_payment_intents flow (subscriptions / x402), not skill purchases.
- await sql`
+ // Atomic confirm + revenue ledger. The status='pending' guard keeps concurrent
+ // confirms idempotent: the second one updates 0 rows and skips the ledger writes.
+ // agent_revenue_events.intent_id has a FK to agent_payment_intents, so we
+ // synthesize a payment-intent row keyed off the skill_purchase id.
+ const intentId = `sp_${pur.id}`;
+ const updated = await sql`
UPDATE skill_purchases
SET status = 'confirmed', tx_signature = ${txSignature}, confirmed_at = now()
WHERE id = ${pur.id} AND status = 'pending'
+ RETURNING id
`;
+ if (updated.length > 0) {
+ await sql`
+ INSERT INTO agent_payment_intents
+ (id, payer_user_id, agent_id, currency_mint, amount, status, expires_at,
+ cluster, tx_signature, paid_at, payload)
+ VALUES
+ (${intentId}, ${pur.user_id}, ${pur.agent_id}, ${pur.currency_mint},
+ ${String(pur.amount)}, 'confirmed', now() + interval '30 days',
+ 'mainnet', ${txSignature}, now(),
+ ${JSON.stringify({ kind: 'skill_purchase', skill: pur.skill, reference })}::jsonb)
+ ON CONFLICT (id) DO NOTHING
+ `;
+ await sql`
+ INSERT INTO agent_revenue_events
+ (agent_id, intent_id, skill, gross_amount, fee_amount, net_amount,
+ currency_mint, chain, payer_address)
+ VALUES
+ (${pur.agent_id}, ${intentId}, ${pur.skill},
+ ${pur.amount}, 0, ${pur.amount},
+ ${pur.currency_mint}, ${pur.chain}, ${payout.address})
+ `;
+ }
return json(res, 200, { data: { status: 'confirmed', tx_signature: txSignature } });
}
diff --git a/api/pump/[action].js b/api/pump/[action].js
index 449412fe9..1ed3050ff 100644
--- a/api/pump/[action].js
+++ b/api/pump/[action].js
@@ -32,6 +32,8 @@ import { Keypair, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';
import { sql } from '../_lib/db.js';
import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';
import { cors, json, method, readJson, wrap, error } from '../_lib/http.js';
+import { putObject, publicUrl as r2PublicUrl } from '../_lib/r2.js';
+import { env } from '../_lib/env.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
import { parse } from '../_lib/validate.js';
import { randomToken } from '../_lib/crypto.js';
@@ -79,6 +81,7 @@ const wrapped = wrap(async (req, res) => {
case 'buy-confirm': return handleBuyConfirm(req, res);
case 'sell-prep': return handleSellPrep(req, res);
case 'sell-confirm': return handleSellConfirm(req, res);
+ case 'build-metadata': return handleBuildMetadata(req, res);
case 'launch-prep': return handleLaunchPrep(req, res);
case 'launch-confirm': return handleLaunchConfirm(req, res);
case 'accept-payment-prep': return handleAcceptPaymentPrep(req, res);
@@ -472,6 +475,84 @@ async function handleSellConfirm(req, res) {
});
}
+// ── build-metadata ─────────────────────────────────────────────────────────
+// Builds a pump.fun-compatible metadata JSON and uploads it (+ optional token
+// image) to R2. Returns a stable public URL the wizard can use as the URI.
+
+const buildMetadataSchema = z.object({
+ name: z.string().trim().min(1).max(32),
+ symbol: z.string().trim().min(1).max(10),
+ description: z.string().trim().max(500).default(''),
+ avatar_id: z.string().uuid().optional(),
+ agent_id: z.string().uuid().optional(),
+ // Base64 data URL: "data:image/png;base64,..." — max ~4 MB image.
+ image_data_url: z.string().max(6_000_000).optional(),
+});
+
+async function handleBuildMetadata(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const body = parse(buildMetadataSchema, await readJson(req));
+ const uid = user.id;
+ const ts = Date.now().toString(36);
+ const prefix = `pump/meta/${uid}/${ts}`;
+
+ // ── Resolve image URL ───────────────────────────────────────────────────
+ let imageUrl = null;
+
+ if (body.image_data_url) {
+ const commaIdx = body.image_data_url.indexOf(',');
+ if (commaIdx === -1) return error(res, 400, 'validation_error', 'invalid image_data_url');
+ const meta = body.image_data_url.slice(0, commaIdx);
+ const payload = body.image_data_url.slice(commaIdx + 1);
+ const buf = meta.includes('base64')
+ ? Buffer.from(payload, 'base64')
+ : Buffer.from(decodeURIComponent(payload));
+ if (buf.byteLength > 4 * 1024 * 1024) {
+ return error(res, 413, 'payload_too_large', 'image must be under 4 MB');
+ }
+ const contentType = meta.match(/data:([^;,]+)/)?.[1] || 'image/png';
+ const ext = contentType.includes('jpeg') || contentType.includes('jpg') ? 'jpg' : 'png';
+ const imgKey = `${prefix}/image.${ext}`;
+ await putObject({ key: imgKey, body: buf, contentType });
+ imageUrl = r2PublicUrl(imgKey);
+ } else if (body.avatar_id) {
+ const [av] = await sql`
+ select thumbnail_key from avatars
+ where id=${body.avatar_id} and owner_id=${uid} and deleted_at is null limit 1
+ `;
+ if (av?.thumbnail_key) imageUrl = r2PublicUrl(av.thumbnail_key);
+ }
+
+ // ── Build metadata JSON ─────────────────────────────────────────────────
+ const agentHomeUrl = body.agent_id
+ ? `${env.APP_ORIGIN}/agent/${body.agent_id}`
+ : env.APP_ORIGIN;
+
+ const metadata = {
+ name: body.name,
+ symbol: body.symbol,
+ description: body.description,
+ ...(imageUrl ? { image: imageUrl } : {}),
+ showName: true,
+ createdOn: 'https://pump.fun',
+ website: agentHomeUrl,
+ };
+
+ const jsonBuf = Buffer.from(JSON.stringify(metadata, null, 2));
+ const jsonKey = `${prefix}/metadata.json`;
+ await putObject({ key: jsonKey, body: jsonBuf, contentType: 'application/json' });
+
+ return json(res, 200, { metadata_url: r2PublicUrl(jsonKey), image_url: imageUrl });
+}
+
// ── launch-prep ────────────────────────────────────────────────────────────
const launchPrepSchema = z
@@ -679,6 +760,7 @@ async function handleLaunchPrep(req, res) {
return json(res, 201, {
prep_id: prepId,
+ agent_id: resolvedAgentId,
mint: mint.toBase58(),
// Mint keypair must co-sign the tx. When server-generated, we hand
// the secret to the frontend; when client-supplied (vanity), the
diff --git a/marketplace.html b/marketplace.html
index 09f0418cb..de8b9dfbe 100644
--- a/marketplace.html
+++ b/marketplace.html
@@ -22,6 +22,119 @@
rel="stylesheet"
/>
<style>
+ .market-wip-banner {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ padding: 10px 24px;
+ background: linear-gradient(90deg, rgba(253, 224, 71, 0.08), rgba(253, 224, 71, 0.02));
+ border-bottom: 1px solid rgba(253, 224, 71, 0.2);
+ color: #fde68a;
+ font-size: 13px;
+ line-height: 1.4;
+ }
+ .market-wip-banner .market-wip-icon {
+ flex: 0 0 auto;
+ width: 22px;
+ height: 22px;
+ border-radius: 50%;
+ background: rgba(253, 224, 71, 0.12);
+ color: #fde047;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ font-weight: 700;
+ font-size: 13px;
+ }
+ .market-wip-banner strong {
+ color: #fef3c7;
+ }
+ .market-wip-banner .market-wip-text {
+ flex: 1;
+ min-width: 0;
+ }
+
+ .market-card-avatar {
+ display: flex;
+ flex-direction: column;
+ background: var(--mk-panel, #111);
+ border: 1px solid var(--mk-border, #1f1f1f);
+ border-radius: var(--mk-radius, 14px);
+ overflow: hidden;
+ cursor: pointer;
+ transition: border-color 0.15s ease, transform 0.15s ease;
+ }
+ .market-card-avatar:hover {
+ border-color: var(--mk-border-2, #2a2a2a);
+ transform: translateY(-1px);
+ }
+ .market-card-avatar .thumb {
+ aspect-ratio: 1 / 1;
+ background: #0d0d0d center/cover no-repeat;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 40px;
+ color: rgba(255, 255, 255, 0.25);
+ border-bottom: 1px solid var(--mk-border, #1f1f1f);
+ }
+ .market-card-avatar .body {
+ padding: 12px 14px;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ min-width: 0;
+ }
+ .market-card-avatar .title {
+ font-size: 14px;
+ font-weight: 600;
+ color: var(--mk-text, #f4f4f5);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .market-card-avatar .desc {
+ font-size: 12px;
+ color: var(--mk-text-2, #a1a1aa);
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ min-height: 30px;
+ }
+ .market-card-avatar .footer {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ font-size: 11px;
+ color: var(--mk-text-3, #71717a);
+ margin-top: 2px;
+ }
+ .market-card-avatar .avatar-pill {
+ background: rgba(125, 211, 252, 0.1);
+ color: #7dd3fc;
+ padding: 2px 8px;
+ border-radius: 999px;
+ font-size: 10px;
+ font-weight: 600;
+ letter-spacing: 0.02em;
+ }
+ .market-grid-section-title {
+ grid-column: 1 / -1;
+ font-size: 13px;
+ font-weight: 600;
+ color: var(--mk-text-2, #a1a1aa);
+ margin: 18px 0 4px;
+ display: flex;
+ align-items: baseline;
+ gap: 8px;
+ }
+ .market-grid-section-title .count {
+ font-size: 11px;
+ color: var(--mk-text-3, #71717a);
+ font-weight: 500;
+ }
+
.price-badge {
display: inline-block;
margin-left: 8px;
@@ -147,6 +260,14 @@
</aside>
<main class="market-main" id="market-main">
+ <div class="market-wip-banner" role="status">
+ <span class="market-wip-icon" aria-hidden="true">!</span>
+ <div class="market-wip-text">
+ <strong>Work in progress.</strong>
+ This marketplace is still being built — features, paid skills, and listings may be incomplete or change.
+ </div>
+ </div>
+
<!-- Discovery view -->
<section class="market-discovery" id="market-discovery">
<header class="market-topbar">
diff --git a/public/dashboard/index.html b/public/dashboard/index.html
index 72299ebe8..de9fd53ca 100644
--- a/public/dashboard/index.html
+++ b/public/dashboard/index.html
@@ -1145,6 +1145,7 @@
<a href="#account" data-tab="account">Account</a>
<a href="/dashboard/wallets">Wallets</a>
<a href="/vanity-wallet">Vanity wallet ✦</a>
+ <a href="/eth-vanity">ETH vanity (CREATE2) ✦</a>
<a href="/dashboard/agent-pumpfun">Agent · Pump.fun</a>
<a href="/strategy-lab">Strategy lab</a>
<a href="/reputation">Reputation</a>
diff --git a/public/eth-vanity.html b/public/eth-vanity.html
index 6659f5ea1..c3473becd 100644
--- a/public/eth-vanity.html
+++ b/public/eth-vanity.html
@@ -401,9 +401,11 @@
Same factory + same initCode + this salt → same address, on every EVM chain that has this factory deployed.
</div>
</div>
+ <div id="assign-host"></div>
`;
$('result').hidden = false;
$('result').innerHTML = html;
+ renderAssignBlock(result, p, s);
$('copy-salt').addEventListener('click', () => copy(result.salt, 'copy-salt', 'Copy salt'));
$('copy-addr').addEventListener('click', () => copy(result.address, 'copy-addr', 'Copy address'));
@@ -437,6 +439,135 @@
setTimeout(() => { $(btnId).textContent = restoreLabel; }, 1400);
} catch {}
}
+
+ // ── Assign to agent ───────────────────────────────────────────────
+ async function renderAssignBlock(result, p, s) {
+ const host = document.getElementById('assign-host');
+ if (!host) return;
+
+ let agents = [];
+ try {
+ const r = await fetch('/api/agents', { credentials: 'include' });
+ if (r.status === 401) {
+ host.innerHTML = `
+ <div class="card" style="margin-top:1rem">
+ <h2>Assign to an agent</h2>
+ <p class="desc" style="margin:0">
+ <a href="/login.html?next=${encodeURIComponent(location.pathname)}" style="color:#a78bfa">Sign in</a>
+ to assign this CREATE2 vanity to one of your agents — they'll display it on their profile and you can deploy it from the agent home page.
+ </p>
+ </div>`;
+ return;
+ }
+ if (!r.ok) throw new Error(`agents fetch ${r.status}`);
+ const data = await r.json();
+ agents = data.agents || [];
+ } catch (e) {
+ host.innerHTML = `<div class="card" style="margin-top:1rem"><h2>Assign to an agent</h2><p class="desc" style="color:#f87171;margin:0">Could not load your agents: ${esc(e.message)}</p></div>`;
+ return;
+ }
+ if (!agents.length) {
+ host.innerHTML = `
+ <div class="card" style="margin-top:1rem">
+ <h2>Assign to an agent</h2>
+ <p class="desc" style="margin:0">No agents yet. <a href="/create.html" style="color:#a78bfa">Create one</a> and come back to assign this address.</p>
+ </div>`;
+ return;
+ }
+
+ const initCode = ($('initcode-raw').value || '').trim();
+ const hasInitCode = /^0x[0-9a-f]+$/i.test(initCode) && initCode.length % 2 === 0;
+ const deployerLabel = (document.querySelector('.preset[data-deployer]')?.dataset?.name && $('deployer').value.toLowerCase() ===
+ document.querySelector('.preset.active')?.dataset?.deployer?.toLowerCase()) ? null : null;
+ // Find the matching preset label by deployer address
+ let presetLabel = null;
+ document.querySelectorAll('.preset[data-deployer]').forEach((b) => {
+ if (b.dataset.deployer.toLowerCase() === $('deployer').value.toLowerCase()) presetLabel = b.dataset.name;
+ });
+
+ host.innerHTML = `
+ <div class="card" style="margin-top:1rem">
+ <h2>Assign to an agent</h2>
+ <p class="desc" style="margin:0 0 .5rem">
+ Save this CREATE2 record (deployer + salt + init code hash + predicted address) to one of your agents.
+ No private keys are stored — the predicted address is just a deterministic function of the inputs.
+ ${hasInitCode ? 'Raw init code will be saved alongside, enabling one-click deploy from the agent home page (Arachnid only).' : 'No raw init code provided — you\'ll be able to deploy from your own tooling.'}
+ </p>
+ <select id="assign-agent" style="margin-top:.4rem">
+ <option value="">— select an agent —</option>
+ ${agents.map((a) => `<option value="${esc(a.id)}">${esc(a.name)}${a.meta?.eth_vanity ? ' (already has CREATE2 vanity)' : ''}</option>`).join('')}
+ </select>
+ <div class="actions">
+ <button id="assign-btn" class="btn primary" type="button" disabled>Assign to agent</button>
+ </div>
+ <div id="assign-status" style="margin-top:.5rem;font-size:.8rem"></div>
+ </div>
+ `;
+
+ const sel = document.getElementById('assign-agent');
+ const btn = document.getElementById('assign-btn');
+ const status = document.getElementById('assign-status');
+ sel.addEventListener('change', () => { btn.disabled = !sel.value; });
+
+ btn.addEventListener('click', async () => {
+ btn.disabled = true;
+ status.textContent = 'assigning…';
+ status.style.color = '#888';
+ const payload = {
+ deployer: result.deployer,
+ salt: result.salt,
+ init_code_hash: result.initCodeHash,
+ init_code: hasInitCode ? initCode.toLowerCase() : null,
+ predicted_address: result.address,
+ prefix: p || null,
+ suffix: s || null,
+ deployer_label: presetLabel,
+ };
+ try {
+ let r = await fetch(`/api/agents/${encodeURIComponent(sel.value)}/eth-vanity`, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify(payload),
+ });
+ // On 409, ask before replacing.
+ if (r.status === 409) {
+ if (!confirm('This agent already has a CREATE2 vanity record. Replace it?')) {
+ btn.disabled = false; status.textContent = ''; return;
+ }
+ const del = await fetch(`/api/agents/${encodeURIComponent(sel.value)}/eth-vanity`, { method: 'DELETE', credentials: 'include' });
+ if (!del.ok) {
+ const dd = await del.json().catch(() => ({}));
+ status.innerHTML = `<span style="color:#f87171">Could not remove existing record: ${esc(dd.error_description || del.status)}</span>`;
+ btn.disabled = false; return;
+ }
+ r = await fetch(`/api/agents/${encodeURIComponent(sel.value)}/eth-vanity`, {
+ method: 'POST', credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify(payload),
+ });
+ }
+ const data = await r.json().catch(() => ({}));
+ if (!r.ok) {
+ status.innerHTML = `<span style="color:#f87171">Failed: ${esc(data.error_description || r.status)}</span>`;
+ btn.disabled = false;
+ return;
+ }
+ const agentName = sel.options[sel.selectedIndex].text.replace(/\s*\(already.*\)$/, '');
+ host.innerHTML = `
+ <div class="card" style="margin-top:1rem;background:rgba(74,222,128,0.06);border-color:rgba(74,222,128,0.2)">
+ <h2 style="color:#4ade80">✓ Assigned to ${esc(agentName)}</h2>
+ <p class="desc" style="margin:0">
+ <a href="/agent/${esc(sel.value)}" style="color:#a78bfa">Open agent →</a> &nbsp;
+ The CREATE2 record is saved. Deploy it from the agent home page when you're ready.
+ </p>
+ </div>`;
+ } catch (e) {
+ status.innerHTML = `<span style="color:#f87171">Network error: ${esc(e.message)}</span>`;
+ btn.disabled = false;
+ }
+ });
+ }
</script>
</body>
</html>
diff --git a/public/nav.html b/public/nav.html
index 7d3060e2f..83fdf2b20 100644
--- a/public/nav.html
+++ b/public/nav.html
@@ -55,6 +55,12 @@
><span class="nav-mi-sub">Grind a Solana address</span></a
>
</li>
+ <li role="none">
+ <a href="/eth-vanity" role="menuitem"
+ ><span class="nav-mi-title">ETH vanity (CREATE2)</span
+ ><span class="nav-mi-sub">Grind a smart-contract address</span></a
+ >
+ </li>
<li role="none">
<a href="/strategy-lab" role="menuitem"
><span class="nav-mi-title">Strategy Lab</span
diff --git a/public/reputation/index.html b/public/reputation/index.html
index 0b4adb1f9..64722521b 100644
--- a/public/reputation/index.html
+++ b/public/reputation/index.html
@@ -552,6 +552,7 @@
<ul class="nav-menu" role="menu" aria-label="Solana">
<li role="none"><a href="/pumpfun" role="menuitem"><span class="nav-mi-title">Pump.fun stream</span><span class="nav-mi-sub">Mint agent tokens</span></a></li>
<li role="none"><a href="/vanity-wallet" role="menuitem"><span class="nav-mi-title">Vanity wallet</span><span class="nav-mi-sub">Grind a Solana address</span></a></li>
+ <li role="none"><a href="/eth-vanity" role="menuitem"><span class="nav-mi-title">ETH vanity (CREATE2)</span><span class="nav-mi-sub">Grind a smart-contract address</span></a></li>
<li role="none"><a href="/strategy-lab" role="menuitem"><span class="nav-mi-title">Strategy Lab</span><span class="nav-mi-sub">DCA + subscriptions</span></a></li>
<li role="none"><a href="/pump-live.html" role="menuitem"><span class="nav-mi-title">Live launches</span><span class="nav-mi-sub">Real-time mint feed</span></a></li>
<li role="none"><a href="/pump-dashboard.html" role="menuitem"><span class="nav-mi-title">Pump Dashboard</span><span class="nav-mi-sub">Watches · scanner · quotes</span></a></li>
diff --git a/public/studio/launch-panel.js b/public/studio/launch-panel.js
index 5a5f275ed..f8a1df867 100644
--- a/public/studio/launch-panel.js
+++ b/public/studio/launch-panel.js
@@ -183,8 +183,6 @@ export function mountLaunchPanel(container, { onSubmit } = {}) {
return;
}
- // The studio page listens for this event and opens the launch modal.
- console.log('[launch-panel] submit', fields);
if (typeof window !== 'undefined') {
window.dispatchEvent(
new CustomEvent('pump-launch-open', {
diff --git a/public/studio/studio.js b/public/studio/studio.js
index 668112c5c..f93ae2aed 100644
--- a/public/studio/studio.js
+++ b/public/studio/studio.js
@@ -173,7 +173,7 @@ if (preModel) state.preselectedModel = preModel;
// Pass the linked agent_id when known (from /api/avatars lateral join);
// otherwise pass avatar_id and the backend will resolve-or-create.
const identity = { name: detail.formData?.name || avatar.name, ...avatar };
- openPumpLaunchWizard(identity, avatar.agent_id || null, avatar.id);
+ openPumpLaunchWizard(identity, avatar.agent_id || null, avatar.id, detail.formData);
});
await loadAvatars();
diff --git a/scripts/refresh-tweet-metrics.mjs b/scripts/refresh-tweet-metrics.mjs
new file mode 100644
index 000000000..f0a8d381f
--- /dev/null
+++ b/scripts/refresh-tweet-metrics.mjs
@@ -0,0 +1,101 @@
+#!/usr/bin/env node
+// Refresh live X (Twitter) metrics for every tweet referenced in the launch-week case study.
+// Reads tweet IDs from threews-launch-week-case-study.html, batches calls to X API v2,
+// writes results to tweet-metrics.json which the HTML page reads at load time.
+//
+// Usage: node scripts/refresh-tweet-metrics.mjs
+// Requires: X_API_BEARER in .env
+
+import fs from 'node:fs/promises';
+import path from 'node:path';
+
+const ROOT = path.resolve(import.meta.dirname, '..');
+const HTML_PATH = path.join(ROOT, 'threews-launch-week-case-study.html');
+const OUT_PATH = path.join(ROOT, 'tweet-metrics.json');
+const ENV_PATH = path.join(ROOT, '.env');
+
+async function loadEnv() {
+ const raw = await fs.readFile(ENV_PATH, 'utf8');
+ for (const line of raw.split('\n')) {
+ const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
+ if (m && !process.env[m[1]]) process.env[m[1]] = m[2];
+ }
+}
+
+function extractTweetIds(html) {
+ const ids = new Set();
+ const re = /(?:twitter\.com|x\.com)\/[^/]+\/status\/(\d+)/g;
+ let m;
+ while ((m = re.exec(html)) !== null) ids.add(m[1]);
+ return [...ids];
+}
+
+async function fetchBatch(ids, bearer) {
+ const url = new URL('https://api.x.com/2/tweets');
+ url.searchParams.set('ids', ids.join(','));
+ url.searchParams.set('tweet.fields', 'public_metrics,created_at,author_id,note_tweet');
+ url.searchParams.set('expansions', 'author_id');
+ url.searchParams.set('user.fields', 'username,name,profile_image_url');
+
+ const res = await fetch(url, { headers: { Authorization: `Bearer ${bearer}` } });
+ if (!res.ok) {
+ const body = await res.text();
+ throw new Error(`X API ${res.status}: ${body.slice(0, 400)}`);
+ }
+ return res.json();
+}
+
+async function main() {
+ await loadEnv();
+ const bearer = process.env.X_API_BEARER;
+ if (!bearer) throw new Error('X_API_BEARER missing in .env');
+
+ const html = await fs.readFile(HTML_PATH, 'utf8');
+ const ids = extractTweetIds(html);
+ console.log(`Found ${ids.length} unique tweet IDs in case study HTML.`);
+
+ const metrics = {};
+ const authors = {};
+
+ // X v2 allows up to 100 IDs per call.
+ for (let i = 0; i < ids.length; i += 100) {
+ const batch = ids.slice(i, i + 100);
+ console.log(`Fetching batch ${i / 100 + 1} (${batch.length} tweets)...`);
+ const data = await fetchBatch(batch, bearer);
+ for (const u of data.includes?.users ?? []) authors[u.id] = u;
+ for (const t of data.data ?? []) {
+ const author = authors[t.author_id];
+ metrics[t.id] = {
+ id: t.id,
+ created_at: t.created_at,
+ author: author ? { username: author.username, name: author.name } : null,
+ metrics: t.public_metrics,
+ };
+ }
+ for (const err of data.errors ?? []) {
+ console.warn(` skipped ${err.resource_id ?? err.value}: ${err.title} — ${err.detail ?? ''}`);
+ }
+ }
+
+ const out = {
+ refreshed_at: new Date().toISOString(),
+ count: Object.keys(metrics).length,
+ tweets: metrics,
+ };
+ await fs.writeFile(OUT_PATH, JSON.stringify(out, null, 2));
+ console.log(`Wrote ${Object.keys(metrics).length} tweet metrics to ${path.relative(ROOT, OUT_PATH)}`);
+
+ const top = Object.values(metrics)
+ .sort((a, b) => (b.metrics?.impression_count ?? 0) - (a.metrics?.impression_count ?? 0))
+ .slice(0, 5);
+ console.log('\nTop 5 by impressions:');
+ for (const t of top) {
+ const m = t.metrics || {};
+ console.log(` ${m.impression_count ?? '-'} views · ${m.like_count ?? '-'} likes · ${m.retweet_count ?? '-'} RTs · @${t.author?.username ?? '?'} · ${t.id}`);
+ }
+}
+
+main().catch((e) => {
+ console.error('FAILED:', e.message);
+ process.exit(1);
+});
diff --git a/src/agent-edit.js b/src/agent-edit.js
index ad3f95869..7042872bd 100644
--- a/src/agent-edit.js
+++ b/src/agent-edit.js
@@ -100,42 +100,124 @@ function escapeHtml(s) {
// --- Event Listeners ---
$('persona-save').addEventListener('click', async () => {
- // This would save persona changes, not implemented in this task
+ const status = $('persona-status');
+ const name = $('f-name').value.trim();
+ const description = $('f-desc').value.trim();
+ if (!name) {
+ status.textContent = 'Name is required.';
+ status.className = 'form-status err';
+ return;
+ }
+ status.textContent = 'Saving…';
+ status.className = 'form-status';
+ try {
+ const r = await fetch(`${API_BASE}/agents/${agentId}`, {
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({ name, description }),
+ });
+ if (!r.ok) {
+ const j = await r.json().catch(() => ({}));
+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);
+ }
+ const j = await r.json();
+ if (j.agent) {
+ agentData.name = j.agent.name;
+ agentData.description = j.agent.description;
+ $('agent-title').textContent = `Edit Agent: ${agentData.name}`;
+ }
+ status.textContent = 'Saved.';
+ status.className = 'form-status ok';
+ } catch (err) {
+ status.textContent = `Error: ${err.message}`;
+ status.className = 'form-status err';
+ }
});
$('publish-save').addEventListener('click', async () => {
- // This would save publish changes, not implemented in this task
+ const status = $('publish-status');
+ const category = $('f-category').value.trim();
+ const tags = $('f-tags').value.split(',').map((t) => t.trim()).filter(Boolean).slice(0, 12);
+ const system_prompt = $('f-prompt').value.trim();
+ const greeting = $('f-greeting').value.trim();
+ const changelog = $('f-changelog').value.trim() || null;
+
+ if (!category) {
+ status.textContent = 'Pick a category.';
+ status.className = 'form-status err';
+ return;
+ }
+ if (!system_prompt) {
+ status.textContent = 'Agent profile (system prompt) is required.';
+ status.className = 'form-status err';
+ return;
+ }
+
+ status.textContent = 'Publishing…';
+ status.className = 'form-status';
+ try {
+ const r = await fetch(`${API_BASE}/marketplace/agents/${agentId}/publish`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({ category, tags, system_prompt, greeting, changelog }),
+ });
+ const j = await r.json().catch(() => ({}));
+ if (!r.ok) {
+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);
+ }
+ const ver = j.data?.version;
+ status.textContent = ver ? `Published v${ver}.` : 'Published.';
+ status.className = 'form-status ok';
+ const view = $('publish-view');
+ if (view) {
+ view.href = `/marketplace.html#${agentId}`;
+ view.hidden = false;
+ }
+ } catch (err) {
+ status.textContent = `Error: ${err.message}`;
+ status.className = 'form-status err';
+ }
});
+// Solana mainnet USDC.
+const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
+
$('monetization-save').addEventListener('click', async () => {
const prices = [];
- document.querySelectorAll('#skill-prices-list .skill-item').forEach(item => {
- const name = item.dataset.skillName;
+ document.querySelectorAll('#skill-prices-list .skill-item').forEach((item) => {
+ const skill = item.dataset.skillName;
const toggle = item.querySelector('.price-toggle');
const input = item.querySelector('.price-input');
-
+
if (toggle.checked && input.value) {
- const amountInLamports = parseFloat(input.value) * 1e6;
prices.push({
- skill_name: name,
- amount: amountInLamports,
- currency_mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyB7u6a'
+ skill,
+ amount: Math.round(parseFloat(input.value) * 1e6),
+ currency_mint: USDC_MINT,
+ chain: 'solana',
});
}
});
+ const status = $('monetization-status');
try {
const r = await fetch(`${API_BASE}/agents/${agentId}/skills-pricing`, {
- method: 'POST',
+ method: 'PUT',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ prices })
+ credentials: 'include',
+ body: JSON.stringify({ prices }),
});
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
- $('monetization-status').textContent = 'Prices saved!';
- $('monetization-status').className = 'form-status ok';
+ if (!r.ok) {
+ const j = await r.json().catch(() => ({}));
+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);
+ }
+ status.textContent = 'Prices saved.';
+ status.className = 'form-status ok';
} catch (err) {
- $('monetization-status').textContent = `Error: ${err.message}`;
- $('monetization-status').className = 'form-status err';
+ status.textContent = `Error: ${err.message}`;
+ status.className = 'form-status err';
}
});
diff --git a/src/agent-eth-vanity-card.js b/src/agent-eth-vanity-card.js
new file mode 100644
index 000000000..1ddd98242
--- /dev/null
+++ b/src/agent-eth-vanity-card.js
@@ -0,0 +1,445 @@
+/**
+ * Agent ETH-CREATE2 vanity card — sibling of agent-vanity-grinder.js.
+ *
+ * Surfaces the CREATE2 vanity record stored under
+ * /api/agents/:id/eth-vanity. Lifecycle states:
+ *
+ * none → form to pick deployer + raw initCode + prefix/suffix,
+ * grind locally (Web Workers), POST to save
+ * saved → show predicted address + Deploy button (Arachnid only)
+ * + Replace and Remove
+ * deployed → show address + chain id + tx link, no Deploy button
+ *
+ * Deploy uses the connected EVM signer via ethers BrowserProvider and
+ * targets the **Arachnid deterministic-deployment-proxy** at
+ * 0x4e59b44847b379578588920cA78FbF26c0B4956C. That proxy's interface is
+ * a raw fallback: send tx with `data = salt(32) ‖ initCode` and the
+ * contract is created at the predicted address.
+ *
+ * Other factory presets (Safe / CreateX / Coinbase Smart Wallet) save
+ * fine but show "Use your factory tooling to deploy" — those need
+ * factory-specific ABIs we don't bundle here.
+ */
+
+import { keccak_256 } from '@noble/hashes/sha3';
+import { grindCreate2Vanity } from './eth/vanity/grinder.js';
+import {
+ validatePattern, validateAddress, validateInitCodeHash, MAX_PATTERN_LENGTH,
+} from './eth/vanity/validation.js';
+
+const ARACHNID_PROXY = '0x4e59b44847b379578588920ca78fbf26c0b4956c';
+
+const PRESETS = [
+ { addr: ARACHNID_PROXY, label: 'Arachnid proxy', deployable: true },
+ { addr: '0xba5ed099633d3b313e4d5f7bdc1305d3c28ba5ed', label: 'CreateX', deployable: false },
+ { addr: '0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67', label: 'Safe v1.4.1', deployable: false },
+ { addr: '0x0ba5ed0c6aa8c49038f819e587e2633c4a9f428a', label: 'Coinbase SW', deployable: false },
+];
+
+const STYLE = `
+.agent-eth-vanity-details { margin: .85rem 0; }
+.agent-eth-vanity-summary { font: 11px/1.4 system-ui, sans-serif; color: rgba(230,230,234,0.4); cursor: pointer; list-style: none; padding: .2rem 0; user-select: none; }
+.agent-eth-vanity-summary::-webkit-details-marker { display: none; }
+.agent-eth-vanity-summary::before { content: '▸ '; font-size: .65rem; }
+.agent-eth-vanity-details[open] .agent-eth-vanity-summary::before { content: '▾ '; }
+.agent-eth-vanity { border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: .85rem 1rem; margin: .4rem 0 0; font: 13px/1.4 system-ui, sans-serif; background: rgba(255,255,255,0.03); color: #e6e6ea; }
+.agent-eth-vanity h3 { margin: 0 0 .2rem; font-size: .85rem; font-weight: 600; color: #f2f2f5; display:flex; align-items:center; gap:.4rem; }
+.agent-eth-vanity h3 .badge { font-size: .65rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; background: linear-gradient(90deg, rgba(167,139,250,0.2), rgba(99,102,241,0.2)); color: #c4b5fd; border: 1px solid rgba(167,139,250,0.25); letter-spacing: .03em; }
+.agent-eth-vanity .sub { color: rgba(230,230,234,0.6); font-size: .78rem; margin: 0 0 .55rem; }
+.agent-eth-vanity .row { display: flex; gap: .5rem; align-items: center; margin-top: .35rem; flex-wrap: wrap; }
+.agent-eth-vanity .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
+@media (max-width: 480px) { .agent-eth-vanity .grid2 { grid-template-columns: 1fr; } }
+.agent-eth-vanity input, .agent-eth-vanity textarea, .agent-eth-vanity select { font: inherit; font-family: ui-monospace, monospace; padding: .35rem .55rem; border-radius: 5px; border: 1px solid rgba(255,255,255,0.12); background: #1a1a1a; color: #e6e6ea; width: 100%; }
+.agent-eth-vanity input:focus, .agent-eth-vanity textarea:focus { outline: none; border-color: rgba(255,255,255,0.3); }
+.agent-eth-vanity input.invalid, .agent-eth-vanity textarea.invalid { border-color: #ff8a80; }
+.agent-eth-vanity textarea { resize: vertical; min-height: 3em; }
+.agent-eth-vanity label { display: block; font-size: .7rem; color: rgba(230,230,234,0.55); margin: .55rem 0 .15rem; }
+.agent-eth-vanity button { font: inherit; padding: .35rem .75rem; border-radius: 5px; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.04); color: #e6e6ea; cursor: pointer; font-size: .8rem; }
+.agent-eth-vanity button:hover:not(:disabled) { background: rgba(255,255,255,0.08); }
+.agent-eth-vanity button.primary { background: linear-gradient(90deg,#a78bfa,#6366f1); color: #fff; border-color: transparent; font-weight: 600; }
+.agent-eth-vanity button.primary:hover:not(:disabled) { filter: brightness(1.1); }
+.agent-eth-vanity button.danger { color: #ff8a80; }
+.agent-eth-vanity button:disabled { opacity: .45; cursor: not-allowed; }
+.agent-eth-vanity .preset-row { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .3rem; }
+.agent-eth-vanity .preset { padding: .2rem .55rem; border-radius: 999px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); font-size: .7rem; cursor: pointer; }
+.agent-eth-vanity .preset.active { background: linear-gradient(90deg, rgba(167,139,250,0.18), rgba(99,102,241,0.18)); border-color: rgba(167,139,250,0.35); color: #c4b5fd; }
+.agent-eth-vanity .progress { font-size: .72rem; color: rgba(230,230,234,0.7); margin-top: .55rem; font-family: ui-monospace, monospace; }
+.agent-eth-vanity .err { color: #ff8a80; font-size: .72rem; margin-top: .4rem; }
+.agent-eth-vanity .ok { color: #4ade80; font-size: .72rem; margin-top: .4rem; }
+.agent-eth-vanity .addr { font-family: ui-monospace, monospace; font-size: .75rem; color: rgba(230,230,234,0.85); margin-top: .35rem; word-break: break-all; padding: .35rem .5rem; background: #0e0e10; border-radius: 5px; border: 1px solid rgba(255,255,255,0.06); }
+.agent-eth-vanity .addr .pfx, .agent-eth-vanity .addr .sfx { background: linear-gradient(90deg,#a78bfa,#6366f1); color: #fff; padding: 0 2px; border-radius: 2px; font-weight: 700; }
+.agent-eth-vanity .meta-line { font-size: .68rem; color: rgba(230,230,234,0.5); margin-top: .4rem; font-family: ui-monospace, monospace; }
+.agent-eth-vanity a { color: #a78bfa; text-decoration: none; }
+.agent-eth-vanity a:hover { text-decoration: underline; }
+`;
+
+let _styleInjected = false;
+function _injectStyle() {
+ if (_styleInjected || typeof document === 'undefined') return;
+ const tag = document.createElement('style');
+ tag.id = 'agent-eth-vanity-style';
+ tag.textContent = STYLE;
+ document.head.appendChild(tag);
+ _styleInjected = true;
+}
+
+function _esc(s) {
+ return String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;' })[c]);
+}
+function _hexToBytes(hex) {
+ const h = hex.startsWith('0x') ? hex.slice(2) : hex;
+ const out = new Uint8Array(h.length / 2);
+ for (let i = 0; i < out.length; i++) out[i] = parseInt(h.substring(i*2, i*2+2), 16);
+ return out;
+}
+function _bytesToHex(b) { let s=''; for (let i=0;i<b.length;i++) s += b[i].toString(16).padStart(2,'0'); return s; }
+function _isHex(s) { return typeof s === 'string' && /^0x[0-9a-f]*$/i.test(s) && s.length % 2 === 0; }
+
+const EXPLORERS = {
+ 1: 'https://etherscan.io',
+ 8453: 'https://basescan.org',
+ 10: 'https://optimistic.etherscan.io',
+ 42161: 'https://arbiscan.io',
+ 137: 'https://polygonscan.com',
+ 11155111: 'https://sepolia.etherscan.io',
+ 84532: 'https://sepolia.basescan.org',
+};
+
+/**
+ * @param {object} opts
+ * @param {HTMLElement} opts.panel
+ * @param {{ id: string, name?: string, isOwner?: boolean }} opts.identity
+ * @param {() => void} [opts.onAssigned]
+ */
+export function mountAgentEthVanityCard({ panel, identity, onAssigned }) {
+ if (!panel || !identity?.id) return null;
+ if (identity.isOwner === false) return null;
+ _injectStyle();
+
+ const wrapper = document.createElement('details');
+ wrapper.className = 'agent-eth-vanity-details';
+ wrapper.hidden = true;
+ const summary = document.createElement('summary');
+ summary.className = 'agent-eth-vanity-summary';
+ summary.textContent = 'Vanity address (ETH · CREATE2)';
+ wrapper.appendChild(summary);
+ panel.appendChild(wrapper);
+
+ const root = document.createElement('section');
+ root.className = 'agent-eth-vanity';
+ wrapper.appendChild(root);
+
+ const state = {
+ loaded: false,
+ record: null, // null when no record exists
+ mode: 'view', // view | form
+ busy: false,
+ progress: null,
+ err: null,
+ ok: null,
+ form: {
+ deployer: ARACHNID_PROXY,
+ deployerLabel: 'Arachnid proxy',
+ rawInitCode: '',
+ prefix: '',
+ suffix: '',
+ },
+ };
+ let abort = null;
+
+ async function load() {
+ try {
+ const r = await fetch(`/api/agents/${encodeURIComponent(identity.id)}/eth-vanity`, { credentials: 'include' });
+ if (r.status === 403) { wrapper.remove(); return; }
+ wrapper.hidden = false;
+ if (r.status === 404) {
+ state.record = null;
+ } else if (r.ok) {
+ const data = await r.json();
+ state.record = data.data || data;
+ } else {
+ state.err = `load failed (${r.status})`;
+ }
+ } catch (e) {
+ state.err = e.message || 'load failed';
+ } finally {
+ state.loaded = true;
+ render();
+ }
+ }
+
+ function render() {
+ if (!state.loaded) {
+ root.innerHTML = `<div class="sub">Loading…</div>`;
+ return;
+ }
+
+ if (state.mode === 'form' || (!state.record && state.busy)) return renderForm();
+ if (state.record) return renderSaved();
+ return renderEmpty();
+ }
+
+ function renderEmpty() {
+ root.innerHTML = `
+ <h3>Vanity address <span class="badge">CREATE2</span></h3>
+ <p class="sub">
+ Predict and assign a smart-contract address whose hex digits start (or end) with characters you choose.
+ No keys involved — you grind a salt and deploy from a factory with your own EVM signer.
+ </p>
+ <div class="row">
+ <button class="primary" data-act="new">Set up CREATE2 vanity</button>
+ <a href="/eth-vanity" target="_blank" rel="noopener" style="font-size:.72rem">open full grinder ↗</a>
+ </div>
+ ${state.err ? `<div class="err">${_esc(state.err)}</div>` : ''}
+ `;
+ root.querySelector('[data-act="new"]').addEventListener('click', () => { state.mode = 'form'; state.err = null; render(); });
+ }
+
+ function renderForm() {
+ const canDeploy = PRESETS.find((p) => p.addr === state.form.deployer.toLowerCase())?.deployable;
+ const presets = PRESETS.map((p) =>
+ `<button class="preset ${state.form.deployer.toLowerCase() === p.addr ? 'active' : ''}" data-preset="${p.addr}" data-label="${_esc(p.label)}" type="button">${_esc(p.label)}</button>`
+ ).join('');
+
+ root.innerHTML = `
+ <h3>Set up CREATE2 vanity <span class="badge">CREATE2</span></h3>
+ <p class="sub">Pick the factory you'll deploy through, paste its init code, choose a pattern, and grind.</p>
+
+ <label>Deployer / factory</label>
+ <input data-field="deployer" type="text" value="${_esc(state.form.deployer)}" spellcheck="false" />
+ <div class="preset-row">${presets}</div>
+ ${canDeploy
+ ? `<div class="meta-line">✓ Arachnid proxy supports one-click deploy from this card.</div>`
+ : `<div class="meta-line">Note: this factory requires its own deploy ABI — saving works, but you'll deploy from your own tooling.</div>`}
+
+ <label>Init code (raw deploy bytecode + ABI-encoded args)</label>
+ <textarea data-field="initcode" rows="3" placeholder="0x…" spellcheck="false">${_esc(state.form.rawInitCode)}</textarea>
+
+ <div class="grid2">
+ <div>
+ <label>Prefix (hex, after 0x)</label>
+ <input data-field="prefix" type="text" maxlength="${MAX_PATTERN_LENGTH}" value="${_esc(state.form.prefix)}" placeholder="beef" />
+ </div>
+ <div>
+ <label>Suffix (hex)</label>
+ <input data-field="suffix" type="text" maxlength="${MAX_PATTERN_LENGTH}" value="${_esc(state.form.suffix)}" placeholder="cafe" />
+ </div>
+ </div>
+
+ <div class="row">
+ <button class="primary" data-act="grind" ${state.busy ? 'disabled' : ''}>${state.busy ? 'Grinding…' : 'Grind & assign'}</button>
+ ${state.busy ? '<button data-act="cancel">cancel</button>' : '<button data-act="back">back</button>'}
+ </div>
+ ${state.progress ? `<div class="progress">${state.progress.attempts.toLocaleString()} tries · ${Math.round(state.progress.rate).toLocaleString()}/s · eta ${_esc(state.progress.eta)}</div>` : ''}
+ ${state.err ? `<div class="err">${_esc(state.err)}</div>` : ''}
+ `;
+
+ root.querySelector('[data-field="deployer"]').addEventListener('input', (e) => {
+ state.form.deployer = e.target.value.trim();
+ const p = PRESETS.find((x) => x.addr === state.form.deployer.toLowerCase());
+ state.form.deployerLabel = p ? p.label : null;
+ });
+ root.querySelector('[data-field="initcode"]').addEventListener('input', (e) => { state.form.rawInitCode = e.target.value.trim(); });
+ root.querySelector('[data-field="prefix"]').addEventListener('input', (e) => { state.form.prefix = e.target.value.trim().replace(/^0x/i, '').toLowerCase(); });
+ root.querySelector('[data-field="suffix"]').addEventListener('input', (e) => { state.form.suffix = e.target.value.trim().toLowerCase(); });
+ root.querySelectorAll('[data-preset]').forEach((b) => {
+ b.addEventListener('click', () => {
+ state.form.deployer = b.dataset.preset;
+ state.form.deployerLabel = b.dataset.label;
+ render();
+ });
+ });
+ root.querySelector('[data-act="back"]')?.addEventListener('click', () => { state.mode = 'view'; state.err = null; render(); });
+ root.querySelector('[data-act="cancel"]')?.addEventListener('click', () => abort?.abort());
+ root.querySelector('[data-act="grind"]')?.addEventListener('click', onGrindAndAssign);
+ }
+
+ function renderSaved() {
+ const r = state.record;
+ const addr = r.predicted_address;
+ const noPrefix = addr.slice(2);
+ const pLen = (r.prefix || '').length;
+ const sLen = (r.suffix || '').length;
+ const mid = noPrefix.slice(pLen, noPrefix.length - sLen);
+ const isArachnid = r.deployer.toLowerCase() === ARACHNID_PROXY;
+ const canDeploy = isArachnid && !!r.init_code && !r.deployed;
+ const explorer = r.deployed ? EXPLORERS[r.deployed.chain_id] : null;
+
+ root.innerHTML = `
+ <h3>Vanity address <span class="badge">CREATE2</span></h3>
+ <p class="sub">
+ Deterministic contract address — same on every chain that has the factory at <code style="font-family:ui-monospace,monospace">${_esc(r.deployer.slice(0,8))}…${_esc(r.deployer.slice(-4))}</code>${r.deployer_label ? ` (${_esc(r.deployer_label)})` : ''}.
+ </p>
+ <div class="addr">
+ 0x${r.prefix ? `<span class="pfx">${_esc(r.prefix)}</span>` : ''}${_esc(mid)}${r.suffix ? `<span class="sfx">${_esc(r.suffix)}</span>` : ''}
+ </div>
+ ${r.deployed ? `
+ <div class="ok">
+ ✓ Deployed on chain ${r.deployed.chain_id}
+ ${explorer ? `· <a href="${explorer}/tx/${_esc(r.deployed.tx_hash)}" target="_blank" rel="noopener">view tx</a>` : `· tx ${_esc(r.deployed.tx_hash.slice(0,12))}…`}
+ </div>
+ ` : ''}
+ <div class="meta-line">
+ salt ${_esc(r.salt.slice(0, 14))}…${_esc(r.salt.slice(-4))}${r.init_code ? ' · init code stored' : ' · init code hash only'}
+ </div>
+ <div class="row">
+ ${canDeploy ? `<button class="primary" data-act="deploy" ${state.busy ? 'disabled' : ''}>${state.busy ? 'Deploying…' : 'Deploy via Arachnid'}</button>` : ''}
+ <button data-act="copy">Copy address</button>
+ <button data-act="json">Download JSON</button>
+ <button data-act="replace">Replace</button>
+ <button class="danger" data-act="remove">Remove</button>
+ </div>
+ ${state.ok ? `<div class="ok">${_esc(state.ok)}</div>` : ''}
+ ${state.err ? `<div class="err">${_esc(state.err)}</div>` : ''}
+ `;
+ root.querySelector('[data-act="copy"]').addEventListener('click', async () => {
+ try { await navigator.clipboard.writeText(r.predicted_address); state.ok = 'address copied'; render(); setTimeout(() => { state.ok = null; render(); }, 1500); } catch {}
+ });
+ root.querySelector('[data-act="json"]').addEventListener('click', () => {
+ const blob = new Blob([JSON.stringify(r, null, 2)], { type: 'application/json' });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url; a.download = `agent-${identity.id}-vanity.json`;
+ document.body.appendChild(a); a.click(); a.remove();
+ URL.revokeObjectURL(url);
+ });
+ root.querySelector('[data-act="replace"]').addEventListener('click', async () => {
+ if (!confirm('Replace the saved CREATE2 vanity record? The address above will no longer be associated with this agent.')) return;
+ try {
+ await fetch(`/api/agents/${encodeURIComponent(identity.id)}/eth-vanity`, { method: 'DELETE', credentials: 'include' });
+ state.record = null; state.mode = 'form'; state.err = null; render();
+ } catch (e) { state.err = e.message; render(); }
+ });
+ root.querySelector('[data-act="remove"]').addEventListener('click', async () => {
+ if (!confirm('Remove the saved CREATE2 vanity record?')) return;
+ try {
+ await fetch(`/api/agents/${encodeURIComponent(identity.id)}/eth-vanity`, { method: 'DELETE', credentials: 'include' });
+ state.record = null; state.err = null; render();
+ } catch (e) { state.err = e.message; render(); }
+ });
+ root.querySelector('[data-act="deploy"]')?.addEventListener('click', onDeploy);
+ }
+
+ async function onGrindAndAssign() {
+ state.err = null;
+ const f = state.form;
+ const dv = validateAddress(f.deployer);
+ if (!dv.valid) { state.err = `deployer: ${dv.error}`; render(); return; }
+ if (!_isHex(f.rawInitCode)) { state.err = 'init code must be 0x-prefixed even-length hex'; render(); return; }
+ if (!f.prefix && !f.suffix) { state.err = 'pick a prefix or suffix'; render(); return; }
+ if (f.prefix) {
+ const v = validatePattern(f.prefix);
+ if (!v.valid) { state.err = `prefix: ${v.errors.join('; ')}`; render(); return; }
+ }
+ if (f.suffix) {
+ const v = validatePattern(f.suffix);
+ if (!v.valid) { state.err = `suffix: ${v.errors.join('; ')}`; render(); return; }
+ }
+
+ const initCode = f.rawInitCode.toLowerCase();
+ const initCodeHash = '0x' + _bytesToHex(keccak_256(_hexToBytes(initCode)));
+ const ich = validateInitCodeHash(initCodeHash);
+ if (!ich.valid) { state.err = `init code: ${ich.error}`; render(); return; }
+
+ state.busy = true; state.progress = null; render();
+ abort = new AbortController();
+ try {
+ const result = await grindCreate2Vanity({
+ deployer: dv.normalized,
+ initCodeHash: ich.normalized,
+ prefix: f.prefix || undefined,
+ suffix: f.suffix || undefined,
+ signal: abort.signal,
+ onProgress: (p) => { state.progress = p; render(); },
+ });
+
+ // Save to server.
+ const res = await fetch(`/api/agents/${encodeURIComponent(identity.id)}/eth-vanity`, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ deployer: result.deployer,
+ salt: result.salt,
+ init_code_hash: result.initCodeHash,
+ init_code: initCode,
+ predicted_address: result.address,
+ prefix: f.prefix || null,
+ suffix: f.suffix || null,
+ deployer_label: f.deployerLabel || null,
+ }),
+ });
+ const data = await res.json().catch(() => ({}));
+ if (!res.ok) {
+ if (res.status === 409) {
+ // Already has a record; delete and retry once.
+ await fetch(`/api/agents/${encodeURIComponent(identity.id)}/eth-vanity`, { method: 'DELETE', credentials: 'include' });
+ return onGrindAndAssign();
+ }
+ throw new Error(data.error_description || `save failed (${res.status})`);
+ }
+ state.record = data.data || data;
+ state.mode = 'view';
+ state.progress = null;
+ onAssigned?.(state.record);
+ } catch (e) {
+ state.err = e.name === 'AbortError' ? 'cancelled' : (e.message || 'failed');
+ state.progress = null;
+ } finally {
+ state.busy = false; abort = null; render();
+ }
+ }
+
+ async function onDeploy() {
+ const r = state.record;
+ if (!r || !r.init_code) { state.err = 'no init code stored — cannot deploy from this card'; render(); return; }
+ if (r.deployer.toLowerCase() !== ARACHNID_PROXY) { state.err = 'one-click deploy only supported for the Arachnid proxy'; render(); return; }
+
+ state.busy = true; state.err = null; state.ok = null; render();
+ try {
+ const { BrowserProvider } = await import('ethers');
+ if (!window.ethereum) throw new Error('no EVM wallet detected — install MetaMask or another EIP-1193 wallet');
+ const provider = new BrowserProvider(window.ethereum);
+ await provider.send('eth_requestAccounts', []);
+ const signer = await provider.getSigner();
+ const network = await provider.getNetwork();
+ const chainId = Number(network.chainId);
+
+ // Arachnid proxy: send tx with data = salt(32) ‖ initCode → CREATE2.
+ const data = r.salt + r.init_code.slice(2);
+
+ const tx = await signer.sendTransaction({ to: r.deployer, data });
+ state.ok = `submitted ${tx.hash.slice(0, 10)}… waiting for inclusion`;
+ render();
+ const receipt = await tx.wait();
+ if (receipt?.status !== 1) throw new Error('deploy reverted');
+
+ // Persist deployment metadata.
+ const mark = await fetch(`/api/agents/${encodeURIComponent(identity.id)}/eth-vanity/deployed`, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ chain_id: chainId, tx_hash: tx.hash }),
+ });
+ if (mark.ok) {
+ const md = await mark.json().catch(() => ({}));
+ state.record = md.data || { ...r, deployed: { chain_id: chainId, tx_hash: tx.hash, at: new Date().toISOString() } };
+ } else {
+ state.record = { ...r, deployed: { chain_id: chainId, tx_hash: tx.hash, at: new Date().toISOString() } };
+ }
+ state.ok = `deployed on chain ${chainId}`;
+ } catch (e) {
+ state.err = e.shortMessage || e.message || 'deploy failed';
+ } finally {
+ state.busy = false; render();
+ }
+ }
+
+ render();
+ load();
+
+ return {
+ destroy: () => { abort?.abort(); wrapper.remove(); },
+ refresh: () => load(),
+ };
+}
diff --git a/src/agent-home.js b/src/agent-home.js
index 319c2783d..432818f5b 100644
--- a/src/agent-home.js
+++ b/src/agent-home.js
@@ -13,6 +13,7 @@ import { MEMORY_TYPES } from './agent-memory.js';
import { mountPumpFunCard } from './agent-home-pumpfun.js';
import { mountAgentSolanaWalletCard } from './agent-solana-wallet.js';
import { mountAgentVanityGrinderCard } from './agent-vanity-grinder.js';
+import { mountAgentEthVanityCard } from './agent-eth-vanity-card.js';
import { mountClaimsPanel } from './agent-home-claims.js';
const ACTION_ICONS = {
@@ -230,6 +231,14 @@ export class AgentHome {
} catch {
/* card is optional */
}
+ try {
+ mountAgentEthVanityCard({
+ panel,
+ identity: this.identity,
+ });
+ } catch {
+ /* card is optional */
+ }
}
mountPumpIfReady();
diff --git a/src/marketplace.js b/src/marketplace.js
index 6ea7f90cb..1ba1dfc7a 100644
--- a/src/marketplace.js
+++ b/src/marketplace.js
@@ -49,6 +49,8 @@ const state = {
cursor: null,
items: [],
loading: false,
+ publicAvatars: [],
+ publicAvatarsLoaded: false,
};
const $ = (id) => document.getElementById(id);
@@ -169,21 +171,84 @@ async function loadList(reset = false) {
} finally {
state.loading = false;
}
+
+ if (reset) loadPublicAvatars();
+}
+
+async function loadPublicAvatars() {
+ try {
+ const url = new URL(`${API}/explore`, location.origin);
+ url.searchParams.set('source', 'avatar');
+ url.searchParams.set('limit', '60');
+ if (state.q) url.searchParams.set('q', state.q);
+ const r = await fetch(url);
+ if (!r.ok) return;
+ const j = await r.json();
+ const avatars = (j?.items || []).filter((it) => it.kind === 'avatar' && it.glbUrl);
+ state.publicAvatars = avatars;
+ state.publicAvatarsLoaded = true;
+ renderGrid();
+ } catch (err) {
+ console.error('[marketplace] public avatars', err);
+ }
}
function renderGrid() {
- if (!state.items.length) {
- els.grid.innerHTML = '<div class="market-empty">No agents yet. Be the first to publish!</div>';
+ const showAvatars = !state.category;
+ const avatars = showAvatars ? state.publicAvatars : [];
+
+ if (!state.items.length && !avatars.length) {
+ const msg = state.publicAvatarsLoaded
+ ? 'No agents yet. Be the first to publish!'
+ : 'Loading…';
+ els.grid.innerHTML = `<div class="market-empty">${msg}</div>`;
els.loadMore.hidden = true;
return;
}
- els.grid.innerHTML = state.items.map(renderCard).join('');
+
+ let html = '';
+ if (state.items.length) {
+ html += state.items.map(renderCard).join('');
+ }
+ if (avatars.length) {
+ html += `<div class="market-grid-section-title">Community Avatars <span class="count">${avatars.length} public</span></div>`;
+ html += avatars.map(renderAvatarCard).join('');
+ }
+ els.grid.innerHTML = html;
+
els.grid.querySelectorAll('[data-id]').forEach((card) => {
card.addEventListener('click', () => navTo(`/marketplace/agents/${card.dataset.id}`));
});
+ els.grid.querySelectorAll('[data-avatar-glb]').forEach((card) => {
+ card.addEventListener('click', () => {
+ const glb = card.dataset.avatarGlb;
+ if (glb) location.href = `/#model=${encodeURIComponent(glb)}`;
+ });
+ });
els.loadMore.hidden = !state.cursor;
}
+function renderAvatarCard(a) {
+ const name = escapeHtml(a.name || 'Untitled Avatar');
+ const desc = escapeHtml(a.description || '');
+ const date = a.createdAt ? formatDate(a.createdAt) : '';
+ const thumbStyle = a.image
+ ? `style="background-image:url('${escapeHtml(a.image)}')"`
+ : '';
+ const fallback = a.image ? '' : '◉';
+ return `<div class="market-card-avatar" data-avatar-glb="${escapeHtml(a.glbUrl || '')}">
+ <div class="thumb" ${thumbStyle}>${fallback}</div>
+ <div class="body">
+ <div class="title">${name}</div>
+ <div class="desc">${desc}</div>
+ <div class="footer">
+ <span>${date}</span>
+ <span class="avatar-pill">3D Avatar</span>
+ </div>
+ </div>
+ </div>`;
+}
+
function renderCard(a) {
const date = a.published ? formatDate(a.published) : '';
const skills = (a.skills || []).length;
diff --git a/src/pump/pump-modals.js b/src/pump/pump-modals.js
index 94ebfbc71..47929f54a 100644
--- a/src/pump/pump-modals.js
+++ b/src/pump/pump-modals.js
@@ -66,6 +66,13 @@ const M_STYLES = `
background: rgba(120,200,140,0.06); border: 1px solid rgba(120,200,140,0.18);
}
.pmodal-receipt-title { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: rgba(180,230,200,0.85); margin-bottom: 0.4rem; }
+.pmodal textarea { width: 100%; padding: 0.5rem 0.7rem; border-radius: 8px; resize: vertical;
+ background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
+ color: #fff; font-size: 0.85rem; font-family: inherit; }
+.pmodal-meta-building { font-size: 0.78rem; color: rgba(255,255,255,0.45); margin-top: 0.6rem;
+ animation: pmodal-pulse 1.4s ease-in-out infinite; }
+.pmodal-meta-ok { font-size: 0.78rem; color: #a4f0bc; margin-top: 0.6rem; }
+@keyframes pmodal-pulse { 0%,100% { opacity: 0.45 } 50% { opacity: 0.9 } }
`;
let stylesInjected = false;
@@ -371,18 +378,57 @@ function openGovernance({ mint, currentBps }) {
}
// ── Launch wizard ──────────────────────────────────────────────────────────
-function openLaunch({ identity, agentId, avatarId }) {
+// formData: { name, symbol, description, initialBuy, feeTier, image (File|null) }
+// Steps: 1 = token details (pre-filled) + metadata generation
+// 2 = buyback share + initial buy
+// 3 = review + sign
+function openLaunch({ identity, agentId, avatarId, formData }) {
const { inner, close } = openModal();
let step = 1;
+ async function buildMetadata(name, symbol) {
+ let imageDataUrl = null;
+ if (formData?.image instanceof File) {
+ imageDataUrl = await new Promise((resolve) => {
+ const reader = new FileReader();
+ reader.onload = (e) => resolve(e.target.result);
+ reader.onerror = () => resolve(null);
+ reader.readAsDataURL(formData.image);
+ });
+ }
+ const resp = await fetch('/api/pump/build-metadata', {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ credentials: 'include',
+ body: JSON.stringify({
+ name,
+ symbol,
+ description: formData?.description || identity?.description || '',
+ ...(avatarId ? { avatar_id: avatarId } : {}),
+ ...(agentId ? { agent_id: agentId } : {}),
+ ...(imageDataUrl ? { image_data_url: imageDataUrl } : {}),
+ }),
+ });
+ if (!resp.ok) throw new Error(`Metadata build failed: ${resp.status}`);
+ return resp.json(); // { metadata_url, image_url }
+ }
+
+ function esc(s) {
+ return String(s ?? '').replace(/[&<>"']/g, (c) =>
+ ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
+ );
+ }
+
function render() {
- const symbolDefault = (identity?.name || 'AGENT')
+ const nameDefault = formData?.name || identity?.name || 'Agent';
+ const symbolDefault = (formData?.symbol || nameDefault)
.toUpperCase()
.replace(/[^A-Z0-9]/g, '')
.slice(0, 8) || 'AGENT';
+
inner.innerHTML = `
- <h3>Launch $${symbolDefault}</h3>
- <div class="pmodal-sub">Pump.fun bonding curve + agent-payments PDA. Three steps.</div>
+ <h3>Launch $${esc(symbolDefault)}</h3>
+ <div class="pmodal-sub">Pump.fun bonding curve · Three steps.</div>
<div class="pmodal-steps">
<div class="pmodal-step ${step >= 1 ? (step === 1 ? 'active' : 'done') : ''}"></div>
<div class="pmodal-step ${step >= 2 ? (step === 2 ? 'active' : 'done') : ''}"></div>
@@ -396,16 +442,21 @@ function openLaunch({ identity, agentId, avatarId }) {
</div>
`;
const body = inner.querySelector('#pmodal-launch-body');
+
if (step === 1) {
+ const cachedName = inner._formCache?.name || nameDefault;
+ const cachedSymbol = inner._formCache?.symbol || symbolDefault;
body.innerHTML = `
- <label>Name</label>
- <input type="text" id="pmodal-launch-name" value="${identity?.name || 'Agent'}" />
+ <label>Token name</label>
+ <input type="text" id="pmodal-launch-name" maxlength="32" value="${esc(cachedName)}" />
<label>Symbol</label>
- <input type="text" id="pmodal-launch-symbol" maxlength="10" value="${symbolDefault}" />
- <label>Metadata URI <span style="color:rgba(255,255,255,0.4)">(IPFS or HTTPS to a JSON manifest with avatar + bio)</span></label>
- <input type="text" id="pmodal-launch-uri" placeholder="https://three.ws/agent/${agentId || avatarId || 'me'}/pump-metadata.json" />
+ <input type="text" id="pmodal-launch-symbol" maxlength="10" value="${esc(cachedSymbol)}" />
+ <label>Description</label>
+ <textarea id="pmodal-launch-desc" rows="2" maxlength="500">${esc(formData?.description || identity?.description || '')}</textarea>
+ <div class="pmodal-sub" style="margin-top:0.5rem">Token image and metadata are generated automatically from your avatar.</div>
`;
} else if (step === 2) {
+ const initialBuyVal = formData?.initialBuy || inner._formCache?.buyin || 0;
body.innerHTML = `
<label>Buyback share</label>
<input type="range" min="0" max="5000" step="50" value="500" id="pmodal-launch-bps" />
@@ -418,11 +469,10 @@ function openLaunch({ identity, agentId, avatarId }) {
<span>If this agent earns $10/mo:</span>
<b id="pmodal-launch-projection">$0.50/mo burned</b>
</div>
- <label>Creator initial buy <span style="color:rgba(255,255,255,0.4)">(SOL, optional)</span></label>
- <input type="number" id="pmodal-launch-buyin" value="0" min="0" max="50" step="0.1" />
+ <label>Creator initial buy (SOL, optional)</label>
+ <input type="number" id="pmodal-launch-buyin" value="${Number(initialBuyVal) || 0}" min="0" max="50" step="0.1" />
<div class="pmodal-sub" style="margin-top:0.7rem">
- Buyback share is locked once configured (per the SDK fee-share policy).
- Choose carefully — it can't be changed later via this wizard.
+ Buyback share is locked at launch — choose carefully.
</div>
`;
const bps = body.querySelector('#pmodal-launch-bps');
@@ -435,19 +485,17 @@ function openLaunch({ identity, agentId, avatarId }) {
};
bps.addEventListener('input', update);
} else if (step === 3) {
- const name = inner._formCache?.name || identity?.name;
- const symbol = inner._formCache?.symbol || symbolDefault;
- const bps = inner._formCache?.bps || 500;
- const buyin = inner._formCache?.buyin || 0;
+ const f = inner._formCache || {};
+ const name = f.name || nameDefault;
+ const symbol = f.symbol || symbolDefault;
body.innerHTML = `
- <div class="pmodal-row"><span>Name</span><b>${name}</b></div>
- <div class="pmodal-row"><span>Symbol</span><b>$${symbol}</b></div>
- <div class="pmodal-row"><span>Buyback</span><b>${(bps / 100).toFixed(1)}%</b></div>
- <div class="pmodal-row"><span>Initial buy</span><b>${buyin} SOL</b></div>
- <div class="pmodal-row"><span>Tx contains</span><b>createInstruction + PumpAgent.create</b></div>
+ <div class="pmodal-row"><span>Name</span><b>${esc(name)}</b></div>
+ <div class="pmodal-row"><span>Symbol</span><b>$${esc(symbol)}</b></div>
+ <div class="pmodal-row"><span>Buyback</span><b>${((f.bps || 500) / 100).toFixed(1)}%</b></div>
+ <div class="pmodal-row"><span>Initial buy</span><b>${f.buyin || 0} SOL</b></div>
+ <div class="pmodal-row"><span>Tx</span><b>createInstruction + PumpAgent.create</b></div>
<div class="pmodal-sub" style="margin-top:0.7rem">
- You'll be asked to sign once with your Solana wallet. Both the new
- mint keypair and your wallet co-sign.
+ You'll sign once with your Solana wallet. The new mint keypair and your wallet co-sign.
</div>
`;
}
@@ -456,18 +504,39 @@ function openLaunch({ identity, agentId, avatarId }) {
step = Math.max(1, step - 1);
render();
});
+
inner.querySelector('#pmodal-launch-next').addEventListener('click', async () => {
const errEl = inner.querySelector('#pmodal-launch-err');
errEl.textContent = '';
+
if (step === 1) {
const name = inner.querySelector('#pmodal-launch-name').value.trim();
const symbol = inner.querySelector('#pmodal-launch-symbol').value.trim().toUpperCase();
- const uri = inner.querySelector('#pmodal-launch-uri').value.trim();
- if (!name || !symbol || !uri) {
- errEl.textContent = 'All three fields are required.';
+ const desc = inner.querySelector('#pmodal-launch-desc').value.trim();
+ if (!name || !symbol) {
+ errEl.textContent = 'Name and symbol are required.';
return;
}
- inner._formCache = { ...(inner._formCache || {}), name, symbol, uri };
+ const nextBtn = inner.querySelector('#pmodal-launch-next');
+ // Rebuild metadata if name/symbol changed or we have no URI yet
+ const nameChanged = inner._formCache?.name !== name || inner._formCache?.symbol !== symbol;
+ inner._formCache = { ...(inner._formCache || {}), name, symbol, desc };
+ if (nameChanged) inner._formCache.uri = null;
+ if (!inner._formCache.uri) {
+ nextBtn.disabled = true;
+ nextBtn.textContent = 'Building metadata…';
+ try {
+ const data = await buildMetadata(name, symbol);
+ inner._formCache.uri = data.metadata_url;
+ } catch (e) {
+ errEl.textContent = `Metadata failed: ${e.message}`;
+ nextBtn.disabled = false;
+ nextBtn.textContent = 'Next';
+ return;
+ }
+ nextBtn.disabled = false;
+ nextBtn.textContent = 'Next';
+ }
step = 2;
render();
} else if (step === 2) {
@@ -482,10 +551,10 @@ function openLaunch({ identity, agentId, avatarId }) {
btn.textContent = 'Preparing…';
try {
const wallet = detectSolanaWallet();
- if (!wallet) throw new Error('No Solana wallet detected.');
+ if (!wallet) throw new Error('No Solana wallet detected. Install Phantom or Backpack.');
if (!wallet.isConnected) await wallet.connect?.();
- const payer =
- wallet.publicKey?.toBase58?.() || wallet.publicKey?.toString();
+ const payer = wallet.publicKey?.toBase58?.() || wallet.publicKey?.toString();
+ if (!payer) throw new Error('Could not read wallet public key.');
const f = inner._formCache || {};
const prep = await fetch('/api/pump/launch-prep', {
method: 'POST',
@@ -523,11 +592,17 @@ function openLaunch({ identity, agentId, avatarId }) {
body: JSON.stringify({ prep_id: prep.prep_id, tx_signature: sig }),
}).then((r) => r.json());
if (confirm.error) throw new Error(confirm.error_description || confirm.error);
- btn.textContent = 'Launched 🎉';
+ btn.textContent = 'Launched!';
+ // Redirect to the agent's page to see the new token
+ const resolvedAgentId = prep.agent_id || agentId;
setTimeout(() => {
close();
- window.location.reload();
- }, 1200);
+ if (resolvedAgentId) {
+ window.location.href = `/agent/${resolvedAgentId}`;
+ } else {
+ window.location.reload();
+ }
+ }, 900);
} catch (e) {
errEl.textContent = e.message || String(e);
const btn = inner.querySelector('#pmodal-launch-next');
@@ -557,6 +632,6 @@ export function mountPumpModals({ identity, agentId } = {}) {
);
}
-export function openPumpLaunchWizard(identity, agentId, avatarId) {
- openLaunch({ identity, agentId, avatarId });
+export function openPumpLaunchWizard(identity, agentId, avatarId, formData) {
+ openLaunch({ identity, agentId, avatarId, formData });
}
diff --git a/tutorials.html b/tutorials.html
index 68fb936b8..cebcc4c6e 100644
--- a/tutorials.html
+++ b/tutorials.html
@@ -431,6 +431,9 @@
<li role="none">
<a href="/vanity-wallet" role="menuitem"><span class="nav-mi-title">Vanity wallet</span><span class="nav-mi-sub">Grind a Solana address</span></a>
</li>
+ <li role="none">
+ <a href="/eth-vanity" role="menuitem"><span class="nav-mi-title">ETH vanity (CREATE2)</span><span class="nav-mi-sub">Grind a smart-contract address</span></a>
+ </li>
<li role="none">
<a href="/strategy-lab" role="menuitem"><span class="nav-mi-title">Strategy Lab</span><span class="nav-mi-sub">DCA + subscriptions</span></a>
</li>
@@ -747,6 +750,11 @@ console.log(agent.attestation); // ERC-8004 attestation URI</code></pre>
<svg viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M2 6h8M6 2l4 4-4 4"/></svg>
</a>
<span class="tut-cta-sep">·</span>
+ <a href="/eth-vanity" class="tut-cta-link">
+ ETH vanity (CREATE2)
+ <svg viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M2 6h8M6 2l4 4-4 4"/></svg>
+ </a>
+ <span class="tut-cta-sep">·</span>
<a href="/docs#solana" class="tut-cta-link">
Solana SDK docs
<svg viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M2 6h8M6 2l4 4-4 4"/></svg>
diff --git a/tweet-metrics.json b/tweet-metrics.json
new file mode 100644
index 000000000..53a028004
--- /dev/null
+++ b/tweet-metrics.json
@@ -0,0 +1,534 @@
+{
+ "refreshed_at": "2026-05-10T00:24:45.624Z",
+ "count": 33,
+ "tweets": {
+ "2049355559225503889": {
+ "id": "2049355559225503889",
+ "created_at": "2026-04-29T05:10:15.000Z",
+ "author": {
+ "username": "nichxbt",
+ "name": "nich"
+ },
+ "metrics": {
+ "retweet_count": 37,
+ "reply_count": 64,
+ "like_count": 282,
+ "quote_count": 20,
+ "bookmark_count": 51,
+ "impression_count": 135671
+ }
+ },
+ "2049360194128507336": {
+ "id": "2049360194128507336",
+ "created_at": "2026-04-29T05:28:40.000Z",
+ "author": {
+ "username": "nichxbt",
+ "name": "nich"
+ },
+ "metrics": {
+ "retweet_count": 8,
+ "reply_count": 3,
+ "like_count": 31,
+ "quote_count": 1,
+ "bookmark_count": 8,
+ "impression_count": 3740
+ }
+ },
+ "2049391191771562038": {
+ "id": "2049391191771562038",
+ "created_at": "2026-04-29T07:31:50.000Z",
+ "author": {
+ "username": "nichxbt",
+ "name": "nich"
+ },
+ "metrics": {
+ "retweet_count": 4,
+ "reply_count": 7,
+ "like_count": 18,
+ "quote_count": 2,
+ "bookmark_count": 0,
+ "impression_count": 4107
+ }
+ },
+ "2049684977600909769": {
+ "id": "2049684977600909769",
+ "created_at": "2026-04-30T02:59:14.000Z",
+ "author": {
+ "username": "nichxbt",
+ "name": "nich"
+ },
+ "metrics": {
+ "retweet_count": 10,
+ "reply_count": 10,
+ "like_count": 82,
+ "quote_count": 3,
+ "bookmark_count": 0,
+ "impression_count": 13483
+ }
+ },
+ "2049412062837928202": {
+ "id": "2049412062837928202",
+ "created_at": "2026-04-29T08:54:46.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 6,
+ "reply_count": 14,
+ "like_count": 41,
+ "quote_count": 0,
+ "bookmark_count": 0,
+ "impression_count": 1720
+ }
+ },
+ "2049447738434339171": {
+ "id": "2049447738434339171",
+ "created_at": "2026-04-29T11:16:32.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 13,
+ "reply_count": 7,
+ "like_count": 32,
+ "quote_count": 0,
+ "bookmark_count": 0,
+ "impression_count": 1960
+ }
+ },
+ "2049458671139336613": {
+ "id": "2049458671139336613",
+ "created_at": "2026-04-29T11:59:58.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 16,
+ "reply_count": 9,
+ "like_count": 39,
+ "quote_count": 0,
+ "bookmark_count": 0,
+ "impression_count": 4110
+ }
+ },
+ "2049567362693963905": {
+ "id": "2049567362693963905",
+ "created_at": "2026-04-29T19:11:53.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 14,
+ "reply_count": 12,
+ "like_count": 25,
+ "quote_count": 0,
+ "bookmark_count": 0,
+ "impression_count": 5791
+ }
+ },
+ "2049573582247022869": {
+ "id": "2049573582247022869",
+ "created_at": "2026-04-29T19:36:35.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 10,
+ "reply_count": 11,
+ "like_count": 98,
+ "quote_count": 0,
+ "bookmark_count": 0,
+ "impression_count": 5346
+ }
+ },
+ "2049557523330638269": {
+ "id": "2049557523330638269",
+ "created_at": "2026-04-29T18:32:47.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 7,
+ "reply_count": 13,
+ "like_count": 97,
+ "quote_count": 2,
+ "bookmark_count": 0,
+ "impression_count": 2558
+ }
+ },
+ "2049762179042484636": {
+ "id": "2049762179042484636",
+ "created_at": "2026-04-30T08:06:00.000Z",
+ "author": {
+ "username": "nichxbt",
+ "name": "nich"
+ },
+ "metrics": {
+ "retweet_count": 13,
+ "reply_count": 7,
+ "like_count": 36,
+ "quote_count": 2,
+ "bookmark_count": 0,
+ "impression_count": 5519
+ }
+ },
+ "2049997615421649363": {
+ "id": "2049997615421649363",
+ "created_at": "2026-04-30T23:41:33.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 18,
+ "reply_count": 2,
+ "like_count": 232,
+ "quote_count": 0,
+ "bookmark_count": 0,
+ "impression_count": 6905
+ }
+ },
+ "2050049239301165535": {
+ "id": "2050049239301165535",
+ "created_at": "2026-05-01T03:06:41.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 8,
+ "reply_count": 16,
+ "like_count": 165,
+ "quote_count": 2,
+ "bookmark_count": 3,
+ "impression_count": 2109
+ }
+ },
+ "2050226678321102975": {
+ "id": "2050226678321102975",
+ "created_at": "2026-05-01T14:51:46.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 30,
+ "reply_count": 25,
+ "like_count": 277,
+ "quote_count": 7,
+ "bookmark_count": 7,
+ "impression_count": 22526
+ }
+ },
+ "2050585585191186781": {
+ "id": "2050585585191186781",
+ "created_at": "2026-05-02T14:37:56.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 16,
+ "reply_count": 16,
+ "like_count": 54,
+ "quote_count": 7,
+ "bookmark_count": 4,
+ "impression_count": 7199
+ }
+ },
+ "2050627547394916768": {
+ "id": "2050627547394916768",
+ "created_at": "2026-05-02T17:24:40.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 15,
+ "reply_count": 7,
+ "like_count": 40,
+ "quote_count": 1,
+ "bookmark_count": 1,
+ "impression_count": 1628
+ }
+ },
+ "2050680402923471106": {
+ "id": "2050680402923471106",
+ "created_at": "2026-05-02T20:54:42.000Z",
+ "author": {
+ "username": "nichxbt",
+ "name": "nich"
+ },
+ "metrics": {
+ "retweet_count": 14,
+ "reply_count": 8,
+ "like_count": 33,
+ "quote_count": 1,
+ "bookmark_count": 8,
+ "impression_count": 2366
+ }
+ },
+ "2050753406109880576": {
+ "id": "2050753406109880576",
+ "created_at": "2026-05-03T01:44:47.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 17,
+ "reply_count": 10,
+ "like_count": 41,
+ "quote_count": 2,
+ "bookmark_count": 8,
+ "impression_count": 3740
+ }
+ },
+ "2051126902447124561": {
+ "id": "2051126902447124561",
+ "created_at": "2026-05-04T02:28:56.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 17,
+ "reply_count": 4,
+ "like_count": 41,
+ "quote_count": 2,
+ "bookmark_count": 4,
+ "impression_count": 4332
+ }
+ },
+ "2051261108506558901": {
+ "id": "2051261108506558901",
+ "created_at": "2026-05-04T11:22:13.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 611,
+ "reply_count": 316,
+ "like_count": 2841,
+ "quote_count": 9,
+ "bookmark_count": 11,
+ "impression_count": 42926
+ }
+ },
+ "2051616708482498843": {
+ "id": "2051616708482498843",
+ "created_at": "2026-05-05T10:55:15.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 18,
+ "reply_count": 7,
+ "like_count": 49,
+ "quote_count": 6,
+ "bookmark_count": 7,
+ "impression_count": 12449
+ }
+ },
+ "2051689230997618690": {
+ "id": "2051689230997618690",
+ "created_at": "2026-05-05T15:43:25.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 11,
+ "reply_count": 7,
+ "like_count": 46,
+ "quote_count": 2,
+ "bookmark_count": 1,
+ "impression_count": 2500
+ }
+ },
+ "2051762380686946592": {
+ "id": "2051762380686946592",
+ "created_at": "2026-05-05T20:34:06.000Z",
+ "author": {
+ "username": "nichxbt",
+ "name": "nich"
+ },
+ "metrics": {
+ "retweet_count": 12,
+ "reply_count": 6,
+ "like_count": 52,
+ "quote_count": 2,
+ "bookmark_count": 2,
+ "impression_count": 2458
+ }
+ },
+ "2051774915876098063": {
+ "id": "2051774915876098063",
+ "created_at": "2026-05-05T21:23:54.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 8,
+ "reply_count": 6,
+ "like_count": 42,
+ "quote_count": 1,
+ "bookmark_count": 3,
+ "impression_count": 1610
+ }
+ },
+ "2052402481024667887": {
+ "id": "2052402481024667887",
+ "created_at": "2026-05-07T14:57:37.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 12,
+ "reply_count": 1,
+ "like_count": 41,
+ "quote_count": 2,
+ "bookmark_count": 2,
+ "impression_count": 3884
+ }
+ },
+ "2052424777223336058": {
+ "id": "2052424777223336058",
+ "created_at": "2026-05-07T16:26:13.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 13,
+ "reply_count": 14,
+ "like_count": 48,
+ "quote_count": 1,
+ "bookmark_count": 4,
+ "impression_count": 3439
+ }
+ },
+ "2052418108837781511": {
+ "id": "2052418108837781511",
+ "created_at": "2026-05-07T15:59:43.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 10,
+ "reply_count": 4,
+ "like_count": 30,
+ "quote_count": 2,
+ "bookmark_count": 2,
+ "impression_count": 1149
+ }
+ },
+ "2052186605360943431": {
+ "id": "2052186605360943431",
+ "created_at": "2026-05-07T00:39:49.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 12,
+ "reply_count": 11,
+ "like_count": 40,
+ "quote_count": 1,
+ "bookmark_count": 1,
+ "impression_count": 1977
+ }
+ },
+ "2052610261140598848": {
+ "id": "2052610261140598848",
+ "created_at": "2026-05-08T04:43:16.000Z",
+ "author": {
+ "username": "0xdetweiler",
+ "name": "Theo"
+ },
+ "metrics": {
+ "retweet_count": 16,
+ "reply_count": 12,
+ "like_count": 62,
+ "quote_count": 3,
+ "bookmark_count": 2,
+ "impression_count": 11217
+ }
+ },
+ "2052685648377913671": {
+ "id": "2052685648377913671",
+ "created_at": "2026-05-08T09:42:50.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 23,
+ "reply_count": 7,
+ "like_count": 55,
+ "quote_count": 2,
+ "bookmark_count": 9,
+ "impression_count": 4366
+ }
+ },
+ "2052790746256920583": {
+ "id": "2052790746256920583",
+ "created_at": "2026-05-08T16:40:27.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 13,
+ "reply_count": 10,
+ "like_count": 50,
+ "quote_count": 2,
+ "bookmark_count": 2,
+ "impression_count": 2978
+ }
+ },
+ "2053025259645981078": {
+ "id": "2053025259645981078",
+ "created_at": "2026-05-09T08:12:19.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 22,
+ "reply_count": 14,
+ "like_count": 77,
+ "quote_count": 6,
+ "bookmark_count": 5,
+ "impression_count": 5963
+ }
+ },
+ "2050221870264545681": {
+ "id": "2050221870264545681",
+ "created_at": "2026-05-01T14:32:39.000Z",
+ "author": {
+ "username": "trythreews",
+ "name": "three.ws"
+ },
+ "metrics": {
+ "retweet_count": 2,
+ "reply_count": 0,
+ "like_count": 11,
+ "quote_count": 0,
+ "bookmark_count": 0,
+ "impression_count": 631
+ }
+ }
+ }
+}
\ No newline at end of file