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: add new fields for vanity suffix and icon in agent-pumpfun, enhance confirmExtra structure in agent-skills-pumpfun, and create migration for pump_agent_price_points table

nirholas9bc5302a2889
diff --git a/api/_lib/migrations/2026-04-29-pump-price-points.sql b/api/_lib/migrations/2026-04-29-pump-price-points.sql
new file mode 100644
index 000000000..464c49031
--- /dev/null
+++ b/api/_lib/migrations/2026-04-29-pump-price-points.sql
@@ -0,0 +1,21 @@
+-- Migration: per-mint price-point time series.
+-- Apply: psql "$DATABASE_URL" -f api/_lib/migrations/2026-04-29-pump-price-points.sql
+-- Idempotent.
+--
+-- Writers: api/cron/pump-agent-stats.js
+-- Readers: api/agents/solana-price-history.js
+
+begin;
+
+create table if not exists pump_agent_price_points (
+ id bigserial primary key,
+ mint_id uuid not null references pump_agent_mints(id) on delete cascade,
+ ts timestamptz not null default now(),
+ sol_per_token double precision,
+ market_cap_lamports numeric(40, 0),
+ source text not null check (source in ('bonding_curve','amm','none'))
+);
+create index if not exists pump_agent_price_points_mint_ts
+ on pump_agent_price_points(mint_id, ts desc);
+
+commit;
diff --git a/api/admin/pump-cron-health.js b/api/admin/pump-cron-health.js
new file mode 100644
index 000000000..69236223d
--- /dev/null
+++ b/api/admin/pump-cron-health.js
@@ -0,0 +1,77 @@
+// GET /api/admin/pump-cron-health
+//
+// Aggregates last-run status / errors across the four pump-related cron tables
+// so silent breakage (RPC throttling, SDK API drift) is visible. Auth: session
+// + admin plan, OR `Bearer $CRON_SECRET` for monitoring scrapers.
+
+import { sql } from '../_lib/db.js';
+import { getSessionUser } from '../_lib/auth.js';
+import { cors, json, method, wrap, error } from '../_lib/http.js';
+import { env } from '../_lib/env.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const auth = req.headers.authorization || '';
+ const isCron = env.CRON_SECRET && auth === `Bearer ${env.CRON_SECRET}`;
+ const user = isCron ? null : await getSessionUser(req);
+ if (!isCron) {
+ if (!user) return error(res, 401, 'unauthorized', 'sign in required');
+ if (user.plan !== 'admin') return error(res, 403, 'forbidden', 'admin only');
+ }
+
+ const [distribute, buyback, stats, trades] = await Promise.all([
+ sql`
+ select count(*)::int as runs_24h,
+ count(*) filter (where status='confirmed')::int as confirmed_24h,
+ count(*) filter (where status='failed')::int as failed_24h,
+ max(created_at) as last_run,
+ (array_agg(error order by created_at desc) filter (where error is not null))[1] as last_error
+ from pump_distribute_runs where created_at > now() - interval '24 hours'
+ `.catch(() => [{}]),
+ sql`
+ select count(*)::int as runs_24h,
+ count(*) filter (where status='confirmed')::int as confirmed_24h,
+ count(*) filter (where status='failed')::int as failed_24h,
+ max(created_at) as last_run,
+ (array_agg(error order by created_at desc) filter (where error is not null))[1] as last_error
+ from pump_buyback_runs where created_at > now() - interval '24 hours'
+ `.catch(() => [{}]),
+ sql`
+ select count(*)::int as tracked_mints,
+ count(*) filter (where graduated)::int as graduated,
+ count(*) filter (where error is not null)::int as errored,
+ max(refreshed_at) as last_refresh,
+ (array_agg(error order by refreshed_at desc) filter (where error is not null))[1] as last_error
+ from pump_agent_stats
+ `.catch(() => [{}]),
+ sql`
+ select count(*)::int as trades_24h,
+ count(*) filter (where direction='buy')::int as buys_24h,
+ count(*) filter (where direction='sell')::int as sells_24h,
+ max(created_at) as last_trade
+ from pump_agent_trades where created_at > now() - interval '24 hours'
+ `.catch(() => [{}]),
+ ]);
+
+ const health = {
+ distribute_payments: distribute[0] || {},
+ buyback: buyback[0] || {},
+ agent_stats: stats[0] || {},
+ trades: trades[0] || {},
+ now: new Date().toISOString(),
+ };
+
+ // Liveness threshold: stats cron should run every 10 min.
+ const lastRefresh = stats[0]?.last_refresh ? new Date(stats[0].last_refresh).getTime() : 0;
+ health.warnings = [];
+ if (lastRefresh && Date.now() - lastRefresh > 30 * 60 * 1000) {
+ health.warnings.push('pump-agent-stats cron stale (>30 min)');
+ }
+ if ((stats[0]?.errored || 0) > 0) {
+ health.warnings.push(`${stats[0].errored} mints failed last snapshot`);
+ }
+
+ return json(res, 200, health);
+});
diff --git a/api/agents/solana-card.js b/api/agents/solana-card.js
index f30c150c7..83d3ae6df 100644
--- a/api/agents/solana-card.js
+++ b/api/agents/solana-card.js
@@ -117,6 +117,12 @@ export default wrap(async (req, res) => {
chat: `${origin}/api/agents/${a.id}/chat`,
attestations: `${origin}/api/agents/solana-attestations?asset=${asset}&network=${network}`,
reputation: `${origin}/api/agents/solana-reputation?asset=${asset}&network=${network}`,
+ ...(token_stats
+ ? {
+ quote: `${origin}/api/pump/quote?mint=${asset}&network=${network}`,
+ price_history: `${origin}/api/agents/solana-price-history?asset=${asset}&network=${network}`,
+ }
+ : {}),
},
attestation: {
schemas_url: `${origin}/.well-known/agent-attestation-schemas`,
diff --git a/api/agents/solana-price-history.js b/api/agents/solana-price-history.js
new file mode 100644
index 000000000..ca2b1c04d
--- /dev/null
+++ b/api/agents/solana-price-history.js
@@ -0,0 +1,47 @@
+// GET /api/agents/solana-price-history?asset=<mint>&network=mainnet|devnet&hours=24
+//
+// Returns sparkline-friendly price points for an agent's pump.fun mint.
+
+import { sql } from '../_lib/db.js';
+import { cors, json, method, wrap, error } from '../_lib/http.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const url = new URL(req.url, `http://${req.headers.host}`);
+ const asset = url.searchParams.get('asset');
+ const network = url.searchParams.get('network') === 'devnet' ? 'devnet' : 'mainnet';
+ const hours = Math.max(1, Math.min(720, Number(url.searchParams.get('hours') || 24)));
+ if (!asset) return error(res, 400, 'validation_error', 'asset required');
+
+ const [mintRow] = await sql`
+ select id from pump_agent_mints where mint=${asset} and network=${network} limit 1
+ `;
+ if (!mintRow) return error(res, 404, 'not_found', 'mint not tracked');
+
+ const points = await sql`
+ select ts, sol_per_token, market_cap_lamports, source
+ from pump_agent_price_points
+ where mint_id=${mintRow.id} and ts > now() - (${hours} || ' hours')::interval
+ order by ts asc
+ `;
+
+ return json(
+ res,
+ 200,
+ {
+ mint: asset,
+ network,
+ hours,
+ point_count: points.length,
+ points: points.map((p) => ({
+ ts: p.ts,
+ sol_per_token: p.sol_per_token,
+ market_cap_lamports: p.market_cap_lamports?.toString?.() ?? p.market_cap_lamports,
+ source: p.source,
+ })),
+ },
+ { 'cache-control': 'public, max-age=60', 'access-control-allow-origin': '*' },
+ );
+});
diff --git a/api/agents/solana-reputation.js b/api/agents/solana-reputation.js
index 89df8a470..388855646 100644
--- a/api/agents/solana-reputation.js
+++ b/api/agents/solana-reputation.js
@@ -156,6 +156,34 @@ export default wrap(async (req, res) => {
// pumpfun_signals table may not exist yet — silently ignore.
}
+ // Pump.fun token activity from indexer snapshot: graduation + recent tx
+ // count contribute small positive weights to overall agent reputation.
+ let tokenActivity = { graduated: false, recent_tx_count: 0, trade_count: 0, weight: 0 };
+ try {
+ const [row] = await sql`
+ select s.graduated, s.recent_tx_count,
+ (select count(*)::int from pump_agent_trades t where t.mint_id = m.id) as trade_count
+ from pump_agent_stats s
+ join pump_agent_mints m on m.id = s.mint_id
+ where m.mint = ${asset} and m.network = ${network}
+ limit 1
+ `;
+ if (row) {
+ const w =
+ (row.graduated ? 0.3 : 0) +
+ Math.min(0.4, (row.recent_tx_count || 0) * 0.005) +
+ Math.min(0.3, (row.trade_count || 0) * 0.01);
+ tokenActivity = {
+ graduated: !!row.graduated,
+ recent_tx_count: row.recent_tx_count || 0,
+ trade_count: row.trade_count || 0,
+ weight: Number(w.toFixed(3)),
+ };
+ }
+ } catch {
+ // tables not present
+ }
+
// Pump.fun agent-payments signal: confirmed acceptPayment receipts add a
// volume-weighted, Sybil-resistant reputation lane on top of memo attestations.
let pumpPayments = { confirmed_count: 0, unique_payers: 0, total_atomics: '0' };
@@ -180,6 +208,7 @@ export default wrap(async (req, res) => {
network,
pump_payments: pumpPayments,
pumpfun_signals: pumpfunSignals,
+ token_activity: tokenActivity,
feedback: {
total: fb.total,
verified: fb.verified,
diff --git a/api/cron/pump-agent-stats.js b/api/cron/pump-agent-stats.js
index 21c982685..4d8da9924 100644
--- a/api/cron/pump-agent-stats.js
+++ b/api/cron/pump-agent-stats.js
@@ -35,10 +35,17 @@ export default wrap(async (req, res) => {
order by id limit ${MAX_PER_RUN}
`;
- const report = { scanned: mints.length, updated: 0, errors: 0 };
+ const report = { scanned: mints.length, updated: 0, errors: 0, graduations: 0 };
for (const m of mints) {
try {
const stats = await snapshotMint(m);
+
+ // Detect graduation flip false→true vs prior snapshot.
+ const [prior] = await sql`
+ select graduated from pump_agent_stats where mint_id=${m.id} limit 1
+ `;
+ const justGraduated = stats.graduated && prior && !prior.graduated;
+
await sql`
insert into pump_agent_stats
(mint_id, network, mint, graduated, bonding_curve, amm,
@@ -60,6 +67,34 @@ export default wrap(async (req, res) => {
refreshed_at = now(),
error = null
`;
+
+ // Price-point time series.
+ const price = derivePrice(stats);
+ if (price) {
+ await sql`
+ insert into pump_agent_price_points (mint_id, sol_per_token, market_cap_lamports, source)
+ values (${m.id}, ${price.sol_per_token}, ${price.market_cap_lamports?.toString() ?? null}, ${price.source})
+ `;
+ }
+
+ // Emit a self-sourced graduation signal (no upstream bot needed).
+ if (justGraduated) {
+ report.graduations++;
+ try {
+ await sql`
+ insert into pumpfun_signals (wallet, agent_asset, kind, weight, payload, tx_signature)
+ values (
+ null, ${m.mint}, 'graduation', 0.3,
+ ${JSON.stringify({ source: 'pump-agent-stats', network: m.network })}::jsonb,
+ ${`graduated:${m.mint}:${Date.now()}`}
+ )
+ on conflict (tx_signature) do nothing
+ `;
+ } catch {
+ // pumpfun_signals table optional
+ }
+ }
+
report.updated++;
} catch (e) {
report.errors++;
@@ -150,3 +185,30 @@ async function snapshotMint({ network, mint }) {
return out;
}
+
+// Compute coarse sol-per-token + market_cap_lamports from a stats snapshot.
+// Bonding curve: virtual_sol / virtual_token (the AMM-style invariant pump uses).
+// AMM: quote_reserve / base_reserve.
+function derivePrice(stats) {
+ if (stats.bonding_curve) {
+ const vSol = Number(stats.bonding_curve.virtual_sol || 0);
+ const vTok = Number(stats.bonding_curve.virtual_token || 0);
+ if (vSol > 0 && vTok > 0) {
+ const sol_per_token = vSol / vTok;
+ // total supply ≈ virtual_token + real_token (heuristic, sufficient for charting)
+ const totalTok =
+ BigInt(stats.bonding_curve.virtual_token || 0) +
+ BigInt(stats.bonding_curve.real_token || 0);
+ const market_cap_lamports = totalTok > 0n ? BigInt(Math.floor(sol_per_token * Number(totalTok))) : null;
+ return { sol_per_token, market_cap_lamports, source: 'bonding_curve' };
+ }
+ }
+ if (stats.amm) {
+ const q = Number(stats.amm.quote_reserve || 0);
+ const b = Number(stats.amm.base_reserve || 0);
+ if (q > 0 && b > 0) {
+ return { sol_per_token: q / b, market_cap_lamports: null, source: 'amm' };
+ }
+ }
+ return null;
+}
diff --git a/api/wk-x402.js b/api/wk-x402.js
index 861a2a948..5e6b81e6b 100644
--- a/api/wk-x402.js
+++ b/api/wk-x402.js
@@ -1,7 +1,6 @@
// /.well-known/x402 — x402 resource discovery (fallback; /openapi.json is preferred)
// Spec: https://x402scan.com/discovery
-import { env } from './_lib/env.js';
import { cors, json, method, wrap } from './_lib/http.js';
export default wrap(async (req, res) => {
@@ -13,19 +12,6 @@ export default wrap(async (req, res) => {
{
version: 1,
resources: ['POST /api/mcp'],
- schemes: ['solana-pay', 'evm-erc20', 'pump-agent-payments'],
- // pump-agent-payments: settlement via @pump-fun/agent-payments-sdk
- // acceptPayment ix. Each paid call funds an on-chain receipt PDA tied
- // to the resource's agent mint, automatically splitting revenue into
- // buyback + withdraw vaults per the agent's configured buybackBps.
- // Discovery: GET /api/pump/balances?mint=<agent_mint> returns vault
- // state for the resource. Settlement endpoint:
- // POST /api/pump/accept-payment-prep + /api/pump/accept-payment-confirm.
- pump_agent_payments: {
- prep: '/api/pump/accept-payment-prep',
- confirm: '/api/pump/accept-payment-confirm',
- balances: '/api/pump/balances',
- },
},
{ 'cache-control': 'public, max-age=300' },
);
diff --git a/public/dashboard/agent-pumpfun.html b/public/dashboard/agent-pumpfun.html
index 8ecd136f3..d730dba93 100644
--- a/public/dashboard/agent-pumpfun.html
+++ b/public/dashboard/agent-pumpfun.html
@@ -290,6 +290,8 @@
launchName: $('#launch-name'),
launchSymbol: $('#launch-symbol'),
launchVanity: $('#launch-vanity'),
+ launchVanitySuffix: $('#launch-vanity-suffix'),
+ launchVanityIc: $('#launch-vanity-ic'),
launchSol: $('#launch-sol'),
launchUri: $('#launch-uri'),
launchBtn: $('#launch-btn'),
@@ -424,18 +426,23 @@
return;
}
const vanity = els.launchVanity.value.trim();
+ const vanitySuffix = els.launchVanitySuffix.value.trim();
if (vanity) body.vanityPrefix = vanity;
+ if (vanitySuffix) body.vanitySuffix = vanitySuffix;
+ if (els.launchVanityIc.checked) body.vanityIgnoreCase = true;
const sol = parseFloat(els.launchSol.value);
if (sol > 0) body.solAmount = sol;
els.launchBtn.disabled = true;
- els.launchBtn.textContent = vanity ? 'Grinding & launching…' : 'Launching…';
+ els.launchBtn.textContent = vanity || vanitySuffix ? 'Grinding & launching…' : 'Launching…';
try {
const { data } = await api(`/api/agents/${id}/pumpfun/launch`, {
method: 'POST',
body: JSON.stringify(body),
});
logResponse('launch', data);
- toast(`Launched ${data.mint.slice(0, 8)}… (${data.vanity_iterations} attempts)`);
+ toast(
+ `Launched ${data.mint.slice(0, 12)}… (${data.vanity_iterations.toLocaleString()} attempts in ${data.vanity_duration_ms}ms)`,
+ );
els.tradeMint.value = data.mint;
await refreshAgent();
await refreshPortfolio();
diff --git a/src/agent-skills-pumpfun.js b/src/agent-skills-pumpfun.js
index 9188e5b46..e4b7596a4 100644
--- a/src/agent-skills-pumpfun.js
+++ b/src/agent-skills-pumpfun.js
@@ -451,13 +451,14 @@ export function registerPumpFunSkills(skills) {
wallet_address: pk.toBase58(),
},
confirmPath: '/api/pump/sell-confirm',
- confirmExtra: {
+ confirmExtra: (prep) => ({
mint: args.mint,
network,
wallet_address: pk.toBase58(),
tokens: String(args.tokenAmount),
slippage_bps: slippageBps,
- },
+ route: prep.route,
+ }),
});
const route = r.prep.route;
return {
diff --git a/src/erc8004/deploy-button.js b/src/erc8004/deploy-button.js
index bb63155ad..a3088feeb 100644
--- a/src/erc8004/deploy-button.js
+++ b/src/erc8004/deploy-button.js
@@ -179,8 +179,17 @@ export class DeployButton {
initial: this._vanityPrefix || '',
});
if (chosen === null) return; // dismissed
- this._vanityPrefix = chosen;
- _saveVanity(this._agent?.id, chosen);
+
+ // Modal returns either a string (prefix to grind in browser) or
+ // { prefix, secretKey } when the user pasted a CLI-ground keypair.
+ if (chosen && typeof chosen === 'object') {
+ this._vanityPrefix = chosen.prefix || '';
+ this._preGroundSecretKey = chosen.secretKey;
+ } else {
+ this._vanityPrefix = chosen;
+ this._preGroundSecretKey = null;
+ }
+ _saveVanity(this._agent?.id, this._vanityPrefix);
this._renderDeployButton(); // re-render to update label
});
@@ -303,14 +312,20 @@ export class DeployButton {
const network = _solanaNetwork(this._chainId);
const vanityPrefix = (this._vanityPrefix || '').trim();
- const steps = vanityPrefix
- ? ['Grinding vanity address', 'Sign tx', 'Confirming on-chain', 'Saving']
- : ['Connecting wallet', 'Sign tx', 'Confirming on-chain', 'Saving'];
+ const preGround = this._preGroundSecretKey || null;
+ const willGrind = vanityPrefix && !preGround;
+ const steps = preGround
+ ? ['Loading pre-ground keypair', 'Sign tx', 'Confirming on-chain', 'Saving']
+ : willGrind
+ ? ['Grinding vanity address', 'Sign tx', 'Confirming on-chain', 'Saving']
+ : ['Connecting wallet', 'Sign tx', 'Confirming on-chain', 'Saving'];
const abort = new AbortController();
- this._renderProgress(steps, 0, vanityPrefix ? {
+ this._renderProgress(steps, 0, willGrind ? {
text: `searching for "${vanityPrefix}…"`,
cancelable: true,
onCancel: () => abort.abort(),
+ } : preGround ? {
+ text: `using CLI-ground keypair${vanityPrefix ? ` for "${vanityPrefix}…"` : ''}`,
} : undefined);
let result;
@@ -318,16 +333,17 @@ export class DeployButton {
result = await runSolanaDeploy({
agent,
network,
- vanity: vanityPrefix ? {
- prefix: vanityPrefix,
+ vanity: (vanityPrefix || preGround) ? {
+ prefix: vanityPrefix || undefined,
+ preGroundSecretKey: preGround || undefined,
signal: abort.signal,
- onProgress: ({ attempts, rate, eta }) => {
+ onProgress: willGrind ? ({ attempts, rate, eta }) => {
const detail = this._root.querySelector('.deploy-progress-detail');
if (detail) {
detail.textContent =
`🔍 "${vanityPrefix}…" ${attempts.toLocaleString()} tries · ${Math.round(rate).toLocaleString()}/s · eta ${eta}`;
}
- },
+ } : undefined,
} : undefined,
});
this._renderProgress(steps, 1);
@@ -362,6 +378,7 @@ export class DeployButton {
this._agent.txHash = result.txSignature;
this._agent.contractAddress = result.assetPubkey;
_saveVanity(this._agent?.id, ''); // clear after successful deploy
+ this._preGroundSecretKey = null;
this._renderSuccessChip(this._chainId, result.txSignature, result.assetPubkey, result.vanityPrefix);
}
diff --git a/src/erc8004/solana-deploy.js b/src/erc8004/solana-deploy.js
index 285b71c01..579226a2f 100644
--- a/src/erc8004/solana-deploy.js
+++ b/src/erc8004/solana-deploy.js
@@ -79,8 +79,14 @@ export async function runSolanaDeploy({ agent, network, vanity }) {
if (!walletAddress) throw new Error('Could not read Solana wallet address.');
// Optional: grind a vanity asset keypair before asking the server to build the tx.
+ // Or accept a pre-ground keypair from a CLI grinder (faster for prefixes >=5 chars).
let vanityKeypair = null;
- if (vanity?.prefix) {
+ if (vanity?.preGroundSecretKey) {
+ vanityKeypair = Keypair.fromSecretKey(vanity.preGroundSecretKey);
+ if (vanity.prefix && !vanityKeypair.publicKey.toBase58().startsWith(vanity.prefix)) {
+ throw new Error(`Pre-ground keypair does not start with prefix "${vanity.prefix}".`);
+ }
+ } else if (vanity?.prefix) {
const result = await grindVanity({
prefix: vanity.prefix,
onProgress: vanity.onProgress,
diff --git a/src/erc8004/vanity-modal.js b/src/erc8004/vanity-modal.js
index 08cb2360a..6de325a39 100644
--- a/src/erc8004/vanity-modal.js
+++ b/src/erc8004/vanity-modal.js
@@ -94,6 +94,15 @@ const STYLE = `
.vm-btn.primary { background: #111; color: #fff; border-color: #111; }
.vm-btn:disabled { opacity: .4; cursor: not-allowed; }
.vm-skip { background: none; border: none; color: #666; font-size: .75rem; cursor: pointer; margin-top: .5rem; padding: 0; }
+.vm-cli { margin-top: .85rem; padding: .55rem .65rem; background: #f7f7f8; border: 1px solid #eee; border-radius: 6px; font-size: .72rem; color: #555; }
+.vm-cli code { background: #fff; padding: .1rem .3rem; border-radius: 3px; border: 1px solid #e0e0e0; font-family: ui-monospace, monospace; }
+.vm-cli a { color: #0d47a1; }
+.vm-cli .vm-paste-toggle { background: none; border: none; color: #0d47a1; cursor: pointer; padding: 0; font-size: .72rem; text-decoration: underline; }
+.vm-paste { margin-top: .55rem; }
+.vm-paste textarea { font: inherit; font-family: ui-monospace, monospace; font-size: .7rem; width: 100%; min-height: 70px; box-sizing: border-box; padding: .4rem .5rem; border: 1px solid #ccc; border-radius: 6px; resize: vertical; }
+.vm-paste-status { margin-top: .35rem; font-size: .72rem; min-height: 1em; }
+.vm-paste-status.ok { color: #1b5e20; }
+.vm-paste-status.bad { color: #b71c1c; }
`;
let _styleInjected = false;
@@ -112,7 +121,12 @@ function _injectStyle() {
* @param {object} opts
* @param {string} [opts.agentName] Used to seed suggestion chips.
* @param {string} [opts.initial] Pre-fill (e.g. from localStorage).
- * @returns {Promise<string|null>} Selected prefix, or null on dismiss.
+ * @returns {Promise<string | { prefix: string, secretKey: Uint8Array } | null>}
+ * - `null` → user dismissed
+ * - `''` → user chose "skip"
+ * - `string` → prefix to grind in the browser
+ * - `{ prefix, secretKey }` → pre-ground keypair from a CLI tool
+ * (e.g. nirholas/solana-wallet-toolkit); skip the in-browser grinder.
*/
export function openVanityModal({ agentName = '', initial = '' } = {}) {
_injectStyle();
@@ -156,6 +170,17 @@ export function openVanityModal({ agentName = '', initial = '' } = {}) {
${isMobile ? `<div class="vm-warn">⚠️ Vanity addresses work best on desktop — your device has limited CPU cores.</div>` : ''}
+ <div class="vm-cli">
+ Got a long prefix? Grind offline with
+ <a href="https://github.com/nirholas/solana-wallet-toolkit" target="_blank" rel="noopener">solana-wallet-toolkit</a>
+ (50–100k keys/s/core), then
+ <button class="vm-paste-toggle" id="vm-paste-toggle" type="button">paste the keypair JSON</button>.
+ <div class="vm-paste" id="vm-paste" hidden>
+ <textarea id="vm-paste-input" placeholder="[12, 34, 56, ... ] — solana-keygen JSON, 64 bytes"></textarea>
+ <div class="vm-paste-status" id="vm-paste-status"></div>
+ </div>
+ </div>
+
<div class="vm-actions">
<button class="vm-btn" id="vm-cancel" type="button">Cancel</button>
<button class="vm-btn primary" id="vm-ok" type="button" disabled>Use prefix</button>
@@ -171,6 +196,61 @@ export function openVanityModal({ agentName = '', initial = '' } = {}) {
const estEl = overlay.querySelector('#vm-est');
const tierEl = overlay.querySelector('#vm-tier');
const okBtn = overlay.querySelector('#vm-ok');
+ const pasteToggle = overlay.querySelector('#vm-paste-toggle');
+ const pastePanel = overlay.querySelector('#vm-paste');
+ const pasteInput = overlay.querySelector('#vm-paste-input');
+ const pasteStatus = overlay.querySelector('#vm-paste-status');
+
+ /** @type {{ secretKey: Uint8Array, publicKey: string } | null} */
+ let pasteResult = null;
+
+ pasteToggle.addEventListener('click', () => {
+ const open = pastePanel.hasAttribute('hidden');
+ pastePanel.toggleAttribute('hidden', !open);
+ if (open) pasteInput.focus();
+ });
+
+ pasteInput.addEventListener('input', async () => {
+ pasteResult = null;
+ const raw = pasteInput.value.trim();
+ if (!raw) {
+ pasteStatus.textContent = '';
+ pasteStatus.className = 'vm-paste-status';
+ update();
+ return;
+ }
+ let bytes;
+ try {
+ const arr = JSON.parse(raw);
+ if (!Array.isArray(arr) || arr.length !== 64) throw new Error('expected a 64-element JSON array');
+ if (!arr.every((n) => Number.isInteger(n) && n >= 0 && n <= 255)) throw new Error('values must be 0–255');
+ bytes = new Uint8Array(arr);
+ } catch (e) {
+ pasteStatus.textContent = `invalid: ${e.message}`;
+ pasteStatus.className = 'vm-paste-status bad';
+ update();
+ return;
+ }
+ try {
+ const { Keypair } = await import('@solana/web3.js');
+ const kp = Keypair.fromSecretKey(bytes);
+ const pubkey = kp.publicKey.toBase58();
+ const wantedPrefix = input.value.trim();
+ if (wantedPrefix && !pubkey.startsWith(wantedPrefix)) {
+ pasteStatus.textContent = `address ${pubkey.slice(0, 8)}… does not start with "${wantedPrefix}"`;
+ pasteStatus.className = 'vm-paste-status bad';
+ update();
+ return;
+ }
+ pasteResult = { secretKey: bytes, publicKey: pubkey };
+ pasteStatus.textContent = `✓ ${pubkey.slice(0, 12)}… ready`;
+ pasteStatus.className = 'vm-paste-status ok';
+ } catch (e) {
+ pasteStatus.textContent = `invalid keypair: ${e.message || e}`;
+ pasteStatus.className = 'vm-paste-status bad';
+ }
+ update();
+ });
let previewTimer = null;
function update() {
@@ -182,6 +262,16 @@ export function openVanityModal({ agentName = '', initial = '' } = {}) {
seg.className = 'seg' + (raw.length > idx ? ` lit-${raw.length}` : '');
});
+ if (pasteResult) {
+ preview.innerHTML = `<span class="pfx">${_esc(pasteResult.publicKey.slice(0, raw.length || 0))}</span><span class="rest">${_esc(pasteResult.publicKey.slice(raw.length || 0))}</span>`;
+ estEl.textContent = `pre-ground (no browser grind)`;
+ tierEl.innerHTML = `<span style="color:#1b5e20;font-weight:600">CLI</span>`;
+ okBtn.disabled = false;
+ okBtn.textContent = 'Use pre-ground keypair';
+ return;
+ }
+ okBtn.textContent = 'Use prefix';
+
if (!raw) {
preview.innerHTML = '<span class="rest">' + _esc(_sampleAddress()) + '</span>';
estEl.textContent = 'enter a prefix above';
@@ -238,13 +328,18 @@ export function openVanityModal({ agentName = '', initial = '' } = {}) {
document.removeEventListener('keydown', onKey);
resolve(value);
}
+ function resolveValue() {
+ const prefix = input.value.trim();
+ if (pasteResult) return { prefix, secretKey: pasteResult.secretKey };
+ return prefix;
+ }
function onKey(e) {
if (e.key === 'Escape') close(null);
- if (e.key === 'Enter' && !okBtn.disabled) close(input.value.trim());
+ if (e.key === 'Enter' && !okBtn.disabled && document.activeElement !== pasteInput) close(resolveValue());
}
overlay.querySelector('#vm-cancel').addEventListener('click', () => close(null));
overlay.querySelector('#vm-skip').addEventListener('click', () => close(''));
- overlay.querySelector('#vm-ok').addEventListener('click', () => close(input.value.trim()));
+ overlay.querySelector('#vm-ok').addEventListener('click', () => close(resolveValue()));
overlay.addEventListener('click', (e) => { if (e.target === overlay) close(null); });
document.addEventListener('keydown', onKey);