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 Pump.fun functionality and autonomous skills for Solana agents

nirholas0dff1062ed37
diff --git a/api/agents/solana-attest-event.js b/api/agents/solana-attest-event.js
index d5ad202d8..94a79e911 100644
--- a/api/agents/solana-attest-event.js
+++ b/api/agents/solana-attest-event.js
@@ -176,19 +176,36 @@ export default wrap(async (req, res) => {
// Mirror into the index immediately; crawler dedupes via unique signature.
// Verified semantics match _lib/solana-attestations.js#computeVerified for
// non-owner kinds (feedback/validation/task): structurally valid -> true.
- await sql`
- insert into solana_attestations (
- signature, network, slot, block_time, agent_asset, attester,
- kind, payload, task_id, target_signature, verified
- )
- values (
- ${signature}, ${body.network}, null, now(),
- ${body.agent_asset}, ${attester.publicKey.toBase58()},
- ${payload.kind}, ${JSON.stringify(payload)}::jsonb,
- ${payload.task_id ?? null}, null, true
- )
- on conflict (signature) do nothing
- `;
+ //
+ // The partial unique index solana_attestations_event_id_uniq closes the
+ // race window between the dedupe SELECT above and this INSERT. If a
+ // concurrent webhook delivery already inserted, we catch 23505 and
+ // return the winning signature.
+ try {
+ await sql`
+ insert into solana_attestations (
+ signature, network, slot, block_time, agent_asset, attester,
+ kind, payload, task_id, target_signature, verified
+ )
+ values (
+ ${signature}, ${body.network}, null, now(),
+ ${body.agent_asset}, ${attester.publicKey.toBase58()},
+ ${payload.kind}, ${JSON.stringify(payload)}::jsonb,
+ ${payload.task_id ?? null}, null, true
+ )
+ on conflict (signature) do nothing
+ `;
+ } catch (e) {
+ if (e?.code !== '23505') throw e;
+ const [winner] = await sql`
+ select signature from solana_attestations
+ where agent_asset = ${body.agent_asset}
+ and network = ${body.network}
+ and payload->>'event_id' = ${body.event_id}
+ limit 1
+ `;
+ return json(res, 200, { data: { signature: winner?.signature ?? null, deduped: true } });
+ }
return json(res, 201, { data: { signature, kind: payload.kind, deduped: false } });
});
diff --git a/examples/skills/pump-fun-compose/handlers.js b/examples/skills/pump-fun-compose/handlers.js
index 16bcb645e..e575d333d 100644
--- a/examples/skills/pump-fun-compose/handlers.js
+++ b/examples/skills/pump-fun-compose/handlers.js
@@ -1,6 +1,8 @@
// pump-fun-compose — agent-level loops over the read + trade skills.
// All sibling-skill calls go through ctx.skills.invoke('skill.tool', args).
+const _sessions = new Map();
+
function cfg(ctx, key, fallback) {
return ctx?.skillConfig?.[key] ?? fallback;
}
@@ -11,6 +13,45 @@ async function call(ctx, tool, args) {
return res.data;
}
+async function loadState(ctx, sessionId, init) {
+ if (!sessionId) return { ...init };
+ if (_sessions.has(sessionId)) return _sessions.get(sessionId);
+ try {
+ const recalled = await ctx?.memory?.recall?.({ key: `compose:${sessionId}` });
+ const prior = recalled?.value ?? recalled?.[0]?.value ?? recalled;
+ if (prior && typeof prior === 'object') {
+ const restored = { ...init, ...prior, seen: new Set(prior.seen || []), mirrored: new Set(prior.mirrored || []), exited: new Set(prior.exited || []) };
+ _sessions.set(sessionId, restored);
+ return restored;
+ }
+ } catch {}
+ const fresh = { ...init };
+ _sessions.set(sessionId, fresh);
+ return fresh;
+}
+
+async function saveState(ctx, sessionId, state) {
+ if (!sessionId) return;
+ _sessions.set(sessionId, state);
+ const serializable = {
+ ...state,
+ seen: state.seen ? [...state.seen] : undefined,
+ mirrored: state.mirrored ? [...state.mirrored] : undefined,
+ exited: state.exited ? [...state.exited] : undefined,
+ };
+ try {
+ await ctx?.memory?.note?.({ key: `compose:${sessionId}`, value: serializable });
+ } catch {}
+}
+
+async function maybeTrade(ctx, simulate, tool, args) {
+ if (simulate) {
+ await ctx?.memory?.note?.({ tag: 'simulate', tool, args });
+ return { sig: `SIMULATED:${tool}:${args.mint}:${args.amountSol ?? args.percent ?? ''}`, simulated: true };
+ }
+ return call(ctx, tool, args);
+}
+
function passesFilters(ctx, { creator, holders }) {
const rugCount = creator?.rugCount ?? creator?.rugFlags?.length ?? 0;
if (rugCount >= cfg(ctx, 'rejectIfCreatorRugCount', 1)) {
@@ -40,95 +81,104 @@ async function vetMint(ctx, mint) {
}
export async function researchAndBuy(args, ctx) {
+ const simulate = !!args.simulate;
const search = await call(ctx, 'pump-fun.searchTokens', { query: args.query, limit: 1 });
const mint = search?.results?.[0]?.mint ?? search?.[0]?.mint ?? args.query;
const vet = await vetMint(ctx, mint);
- if (!vet.verdict.ok) return { ok: true, data: { mint, decision: 'skip', reason: vet.verdict.reason } };
+ if (!vet.verdict.ok) return { ok: true, data: { mint, decision: 'skip', reason: vet.verdict.reason, simulate } };
const amountSol = args.amountSol ?? cfg(ctx, 'perTradeSol', 0.05);
const quote = await call(ctx, 'pump-fun-trade.quoteTrade', { mint, side: 'buy', amountSol });
- const buy = await call(ctx, 'pump-fun-trade.buyToken', { mint, amountSol });
- return { ok: true, data: { mint, decision: 'buy', quote, sig: buy.sig } };
+ const buy = await maybeTrade(ctx, simulate, 'pump-fun-trade.buyToken', { mint, amountSol });
+ return { ok: true, data: { mint, decision: 'buy', quote, sig: buy.sig, simulate } };
}
export async function autoSnipe(args, ctx) {
+ const simulate = !!args.simulate;
+ const sessionId = args.sessionId;
const deadline = Date.now() + args.durationSec * 1000;
const perTrade = args.perTradeSol ?? cfg(ctx, 'perTradeSol', 0.05);
const cap = cfg(ctx, 'sessionSpendCapSol', 1.0);
- const seen = new Set();
- const log = [];
- let spent = 0;
- while (Date.now() < deadline && spent + perTrade <= cap) {
+ const state = await loadState(ctx, sessionId, { seen: new Set(), spent: 0, log: [] });
+
+ while (Date.now() < deadline && state.spent + perTrade <= cap) {
const fresh = await call(ctx, 'pump-fun.getNewTokens', { limit: 20 });
const items = fresh?.tokens ?? fresh ?? [];
for (const t of items) {
const mint = t.mint ?? t.address;
- if (!mint || seen.has(mint)) continue;
- seen.add(mint);
+ if (!mint || state.seen.has(mint)) continue;
+ state.seen.add(mint);
const vet = await vetMint(ctx, mint).catch((e) => ({ verdict: { ok: false, reason: e.message } }));
if (!vet.verdict.ok) {
- log.push({ mint, action: 'skip', reason: vet.verdict.reason });
+ state.log.push({ mint, action: 'skip', reason: vet.verdict.reason });
continue;
}
try {
- const buy = await call(ctx, 'pump-fun-trade.buyToken', { mint, amountSol: perTrade });
- spent += perTrade;
- log.push({ mint, action: 'buy', sig: buy.sig, spent });
- if (spent + perTrade > cap) break;
+ const buy = await maybeTrade(ctx, simulate, 'pump-fun-trade.buyToken', { mint, amountSol: perTrade });
+ state.spent += perTrade;
+ state.log.push({ mint, action: simulate ? 'simulate-buy' : 'buy', sig: buy.sig, spent: state.spent });
+ await saveState(ctx, sessionId, state);
+ if (state.spent + perTrade > cap) break;
} catch (e) {
- log.push({ mint, action: 'error', reason: e.message });
+ state.log.push({ mint, action: 'error', reason: e.message });
}
}
+ await saveState(ctx, sessionId, state);
await new Promise((r) => setTimeout(r, cfg(ctx, 'pollMs', 5000)));
}
- return { ok: true, data: { spent, trades: log } };
+ return { ok: true, data: { spent: state.spent, trades: state.log, simulate, sessionId } };
}
export async function copyTrade(args, ctx) {
+ const simulate = !!args.simulate;
+ const sessionId = args.sessionId;
const deadline = Date.now() + args.durationSec * 1000;
const mult = args.sizeMultiplier ?? 1;
const cap = cfg(ctx, 'sessionSpendCapSol', 1.0);
- const mirrored = new Set();
- const log = [];
- let spent = 0;
- while (Date.now() < deadline && spent < cap) {
+ const state = await loadState(ctx, sessionId, { mirrored: new Set(), spent: 0, log: [] });
+
+ while (Date.now() < deadline && state.spent < cap) {
const profile = await call(ctx, 'pump-fun.getCreatorProfile', { creator: args.wallet });
const recentMints = (profile?.tokens ?? []).map((t) => t.mint).filter(Boolean);
for (const mint of recentMints) {
const trades = await call(ctx, 'pump-fun.getTokenTrades', { mint, limit: 20 });
const buys = (trades?.trades ?? trades ?? []).filter(
- (t) => t.side === 'buy' && t.wallet === args.wallet && !mirrored.has(t.sig),
+ (t) => t.side === 'buy' && t.wallet === args.wallet && !state.mirrored.has(t.sig),
);
for (const b of buys) {
- mirrored.add(b.sig);
- const amountSol = Math.min((b.solAmount ?? 0) * mult, cap - spent);
+ state.mirrored.add(b.sig);
+ const amountSol = Math.min((b.solAmount ?? 0) * mult, cap - state.spent);
if (amountSol <= 0) break;
try {
- const r = await call(ctx, 'pump-fun-trade.buyToken', { mint, amountSol });
- spent += amountSol;
- log.push({ mint, mirroredFrom: b.sig, sig: r.sig, amountSol });
+ const r = await maybeTrade(ctx, simulate, 'pump-fun-trade.buyToken', { mint, amountSol });
+ state.spent += amountSol;
+ state.log.push({ mint, mirroredFrom: b.sig, sig: r.sig, amountSol, simulate });
+ await saveState(ctx, sessionId, state);
} catch (e) {
- log.push({ mint, error: e.message });
+ state.log.push({ mint, error: e.message });
}
}
}
+ await saveState(ctx, sessionId, state);
await new Promise((r) => setTimeout(r, cfg(ctx, 'pollMs', 5000)));
}
- return { ok: true, data: { spent, mirrors: log } };
+ return { ok: true, data: { spent: state.spent, mirrors: state.log, simulate, sessionId } };
}
export async function rugExitWatch(args, ctx) {
+ const simulate = !!args.simulate;
+ const sessionId = args.sessionId;
const deadline = Date.now() + args.durationSec * 1000;
const concentrationLimit = cfg(ctx, 'exitOnConcentrationPct', 40);
const devSellLimit = cfg(ctx, 'exitOnDevSellPct', 25);
- const exited = new Set();
- const log = [];
- while (Date.now() < deadline && exited.size < args.mints.length) {
+ const state = await loadState(ctx, sessionId, { exited: new Set(), log: [] });
+
+ while (Date.now() < deadline && state.exited.size < args.mints.length) {
for (const mint of args.mints) {
- if (exited.has(mint)) continue;
+ if (state.exited.has(mint)) continue;
const [holders, trades, details] = await Promise.all([
call(ctx, 'pump-fun.getTokenHolders', { mint, limit: 10 }),
call(ctx, 'pump-fun.getTokenTrades', { mint, limit: 50 }),
@@ -147,14 +197,16 @@ export async function rugExitWatch(args, ctx) {
if (!trigger) continue;
try {
- const sell = await call(ctx, 'pump-fun-trade.sellToken', { mint, percent: 100 });
- exited.add(mint);
- log.push({ mint, trigger, sig: sell.sig });
+ const sell = await maybeTrade(ctx, simulate, 'pump-fun-trade.sellToken', { mint, percent: 100 });
+ state.exited.add(mint);
+ state.log.push({ mint, trigger, sig: sell.sig, simulate });
+ await saveState(ctx, sessionId, state);
} catch (e) {
- log.push({ mint, trigger, error: e.message });
+ state.log.push({ mint, trigger, error: e.message });
}
}
+ await saveState(ctx, sessionId, state);
await new Promise((r) => setTimeout(r, cfg(ctx, 'pollMs', 5000)));
}
- return { ok: true, data: { exited: [...exited], events: log } };
+ return { ok: true, data: { exited: [...state.exited], events: state.log, simulate, sessionId } };
}
diff --git a/examples/skills/pump-fun/handlers.js b/examples/skills/pump-fun/handlers.js
index 749b5288d..3795b4dad 100644
--- a/examples/skills/pump-fun/handlers.js
+++ b/examples/skills/pump-fun/handlers.js
@@ -1,13 +1,13 @@
// pump-fun skill — proxies tool calls to the pump-fun-workers MCP server.
// https://github.com/nirholas/pump-fun-workers
-const DEFAULT_ENDPOINT = 'https://pump-fun-sdk.modelcontextprotocol.name/mcp';
+const ENDPOINT = 'https://pump-fun-sdk.modelcontextprotocol.name/mcp';
let _rpcId = 0;
-async function callMcp(endpoint, name, args, ctx) {
+async function callMcp(name, args, ctx) {
const fetchImpl = ctx?.fetch ?? globalThis.fetch;
- const res = await fetchImpl(endpoint, {
+ const res = await fetchImpl(ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -18,26 +18,28 @@ async function callMcp(endpoint, name, args, ctx) {
}),
});
- if (!res.ok) throw new Error(`pump-fun MCP HTTP ${res.status}`);
+ if (!res.ok) return { ok: false, error: `pump-fun MCP HTTP ${res.status}` };
const body = await res.json();
- if (body.error) throw new Error(body.error.message ?? 'pump-fun MCP error');
+ if (body.error) return { ok: false, error: body.error.message ?? 'pump-fun MCP error' };
const content = body.result?.content ?? [];
const text = content.find((c) => c.type === 'text')?.text;
- if (!text) return body.result;
- try {
- return JSON.parse(text);
- } catch {
- return text;
+ let data = body.result;
+ if (text) {
+ try {
+ data = JSON.parse(text);
+ } catch {
+ data = text;
+ }
}
+ return { ok: true, data };
}
function makeHandler(toolName) {
return async (args, ctx) => {
- const endpoint = ctx?.skillConfig?.endpoint ?? DEFAULT_ENDPOINT;
- const data = await callMcp(endpoint, toolName, args, ctx);
- ctx?.memory?.note?.(`pump-fun:${toolName}`, { args });
- return { ok: true, data };
+ const result = await callMcp(toolName, args, ctx);
+ if (result.ok) ctx?.memory?.note?.(`pump-fun:${toolName}`, { args });
+ return result;
};
}
diff --git a/examples/skills/pump-fun/manifest.json b/examples/skills/pump-fun/manifest.json
index 343c93f9d..b68ba3df3 100644
--- a/examples/skills/pump-fun/manifest.json
+++ b/examples/skills/pump-fun/manifest.json
@@ -23,8 +23,5 @@
"getTokenHolders"
],
"triggers": ["token_lookup", "market_check", "rug_check"]
- },
- "config": {
- "endpoint": "https://pump-fun-sdk.modelcontextprotocol.name/mcp"
}
}
diff --git a/examples/skills/solana-wallet/handlers.js b/examples/skills/solana-wallet/handlers.js
new file mode 100644
index 000000000..6197c2260
--- /dev/null
+++ b/examples/skills/solana-wallet/handlers.js
@@ -0,0 +1,166 @@
+// solana-wallet — generic Solana primitives. Uses ctx.wallet (the contract from
+// api/_lib/solana-wallet.js: { publicKey, signTransaction, sendAndConfirm }).
+
+import {
+ Connection,
+ PublicKey,
+ SystemProgram,
+ Transaction,
+ LAMPORTS_PER_SOL,
+ ComputeBudgetProgram,
+} from '@solana/web3.js';
+import {
+ NATIVE_MINT,
+ createAssociatedTokenAccountIdempotentInstruction,
+ createSyncNativeInstruction,
+ createTransferCheckedInstruction,
+ createCloseAccountInstruction,
+ getAssociatedTokenAddressSync,
+ getMint,
+ getAccount,
+} from '@solana/spl-token';
+
+function getConn(ctx) {
+ const rpc = ctx?.skillConfig?.rpc ?? 'https://api.mainnet-beta.solana.com';
+ return new Connection(rpc, 'confirmed');
+}
+
+function priorityIxs(ctx) {
+ const micro = ctx?.skillConfig?.priorityFeeMicroLamports ?? 0;
+ return micro > 0 ? [ComputeBudgetProgram.setComputeUnitPrice({ microLamports: micro })] : [];
+}
+
+function requireWallet(ctx) {
+ if (!ctx?.wallet?.publicKey) throw new Error('solana-wallet requires ctx.wallet');
+ return ctx.wallet;
+}
+
+function resolveAddr(ctx, addr) {
+ if (addr) return new PublicKey(addr);
+ return requireWallet(ctx).publicKey;
+}
+
+export async function getAddress(_args, ctx) {
+ return { ok: true, data: { address: requireWallet(ctx).publicKey.toBase58() } };
+}
+
+export async function getBalance(args, ctx) {
+ const conn = getConn(ctx);
+ const pk = resolveAddr(ctx, args?.address);
+ const lamports = await conn.getBalance(pk);
+ return { ok: true, data: { address: pk.toBase58(), lamports, sol: lamports / LAMPORTS_PER_SOL } };
+}
+
+export async function getSplBalances(args, ctx) {
+ const conn = getConn(ctx);
+ const pk = resolveAddr(ctx, args?.address);
+ const resp = await conn.getParsedTokenAccountsByOwner(pk, {
+ programId: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'),
+ });
+ const balances = resp.value
+ .map((acc) => {
+ const info = acc.account.data.parsed.info;
+ return {
+ mint: info.mint,
+ amount: info.tokenAmount.uiAmount,
+ decimals: info.tokenAmount.decimals,
+ };
+ })
+ .filter((b) => (b.amount ?? 0) > 0);
+ return { ok: true, data: { address: pk.toBase58(), balances } };
+}
+
+export async function transferSol(args, ctx) {
+ const cap = ctx?.skillConfig?.maxTransferSol ?? Infinity;
+ if (args.amountSol > cap) {
+ return { ok: false, error: `amountSol ${args.amountSol} exceeds cap ${cap}` };
+ }
+ const conn = getConn(ctx);
+ const wallet = requireWallet(ctx);
+ const tx = new Transaction().add(
+ ...priorityIxs(ctx),
+ SystemProgram.transfer({
+ fromPubkey: wallet.publicKey,
+ toPubkey: new PublicKey(args.to),
+ lamports: Math.round(args.amountSol * LAMPORTS_PER_SOL),
+ }),
+ );
+ const { blockhash } = await conn.getLatestBlockhash();
+ tx.recentBlockhash = blockhash;
+ tx.feePayer = wallet.publicKey;
+ const sig = await wallet.sendAndConfirm(tx, conn);
+ ctx?.memory?.note?.('solana-wallet:transferSol', { to: args.to, amountSol: args.amountSol, sig });
+ return { ok: true, data: { sig } };
+}
+
+export async function transferSpl(args, ctx) {
+ const conn = getConn(ctx);
+ const wallet = requireWallet(ctx);
+ const mintPk = new PublicKey(args.mint);
+ const toPk = new PublicKey(args.to);
+
+ const mintInfo = await getMint(conn, mintPk);
+ const fromAta = getAssociatedTokenAddressSync(mintPk, wallet.publicKey);
+ const toAta = getAssociatedTokenAddressSync(mintPk, toPk);
+ const rawAmount = BigInt(Math.round(args.amount * 10 ** mintInfo.decimals));
+
+ const tx = new Transaction().add(
+ ...priorityIxs(ctx),
+ createAssociatedTokenAccountIdempotentInstruction(wallet.publicKey, toAta, toPk, mintPk),
+ createTransferCheckedInstruction(
+ fromAta,
+ mintPk,
+ toAta,
+ wallet.publicKey,
+ rawAmount,
+ mintInfo.decimals,
+ ),
+ );
+ const { blockhash } = await conn.getLatestBlockhash();
+ tx.recentBlockhash = blockhash;
+ tx.feePayer = wallet.publicKey;
+ const sig = await wallet.sendAndConfirm(tx, conn);
+ ctx?.memory?.note?.('solana-wallet:transferSpl', { mint: args.mint, to: args.to, amount: args.amount, sig });
+ return { ok: true, data: { sig } };
+}
+
+export async function wrapSol(args, ctx) {
+ const conn = getConn(ctx);
+ const wallet = requireWallet(ctx);
+ const ata = getAssociatedTokenAddressSync(NATIVE_MINT, wallet.publicKey);
+ const lamports = Math.round(args.amountSol * LAMPORTS_PER_SOL);
+ const tx = new Transaction().add(
+ ...priorityIxs(ctx),
+ createAssociatedTokenAccountIdempotentInstruction(wallet.publicKey, ata, wallet.publicKey, NATIVE_MINT),
+ SystemProgram.transfer({ fromPubkey: wallet.publicKey, toPubkey: ata, lamports }),
+ createSyncNativeInstruction(ata),
+ );
+ const { blockhash } = await conn.getLatestBlockhash();
+ tx.recentBlockhash = blockhash;
+ tx.feePayer = wallet.publicKey;
+ const sig = await wallet.sendAndConfirm(tx, conn);
+ return { ok: true, data: { sig, wsolAta: ata.toBase58() } };
+}
+
+export async function unwrapSol(_args, ctx) {
+ const conn = getConn(ctx);
+ const wallet = requireWallet(ctx);
+ const ata = getAssociatedTokenAddressSync(NATIVE_MINT, wallet.publicKey);
+ await getAccount(conn, ata);
+ const tx = new Transaction().add(
+ ...priorityIxs(ctx),
+ createCloseAccountInstruction(ata, wallet.publicKey, wallet.publicKey),
+ );
+ const { blockhash } = await conn.getLatestBlockhash();
+ tx.recentBlockhash = blockhash;
+ tx.feePayer = wallet.publicKey;
+ const sig = await wallet.sendAndConfirm(tx, conn);
+ return { ok: true, data: { sig } };
+}
+
+export async function getRecentSignatures(args, ctx) {
+ const conn = getConn(ctx);
+ const pk = resolveAddr(ctx, args?.address);
+ const sigs = await conn.getSignaturesForAddress(pk, { limit: args?.limit ?? 25 });
+ return { ok: true, data: { signatures: sigs } };
+}
diff --git a/examples/skills/solana-wallet/manifest.json b/examples/skills/solana-wallet/manifest.json
new file mode 100644
index 000000000..b8368ebef
--- /dev/null
+++ b/examples/skills/solana-wallet/manifest.json
@@ -0,0 +1,30 @@
+{
+ "spec": "skill/0.1",
+ "name": "solana-wallet",
+ "version": "0.1.0",
+ "description": "Generic Solana wallet primitives: balances, transfers (SOL & SPL), wrap/unwrap SOL, recent signatures. Provides the ctx.wallet contract for sibling signing skills.",
+ "license": "MIT",
+ "tags": ["solana", "wallet", "primitives"],
+ "requires": {
+ "runtime": ">=0.1.0",
+ "capabilities": ["wallet.sign", "solana.rpc"]
+ },
+ "provides": {
+ "tools": [
+ "getAddress",
+ "getBalance",
+ "getSplBalances",
+ "transferSol",
+ "transferSpl",
+ "wrapSol",
+ "unwrapSol",
+ "getRecentSignatures"
+ ],
+ "triggers": ["wallet_query", "wallet_transfer"]
+ },
+ "config": {
+ "rpc": "https://api.mainnet-beta.solana.com",
+ "priorityFeeMicroLamports": 50000,
+ "maxTransferSol": 1.0
+ }
+}
diff --git a/examples/skills/solana-wallet/tools.json b/examples/skills/solana-wallet/tools.json
new file mode 100644
index 000000000..eba6e5700
--- /dev/null
+++ b/examples/skills/solana-wallet/tools.json
@@ -0,0 +1,75 @@
+{
+ "tools": [
+ {
+ "name": "getAddress",
+ "description": "Return the wallet's public address.",
+ "input_schema": { "type": "object", "properties": {} }
+ },
+ {
+ "name": "getBalance",
+ "description": "Get SOL balance for the wallet (or a given address).",
+ "input_schema": {
+ "type": "object",
+ "properties": { "address": { "type": "string" } }
+ }
+ },
+ {
+ "name": "getSplBalances",
+ "description": "List all SPL token balances for the wallet (or address).",
+ "input_schema": {
+ "type": "object",
+ "properties": { "address": { "type": "string" } }
+ }
+ },
+ {
+ "name": "transferSol",
+ "description": "Send SOL to a recipient. Capped by manifest.config.maxTransferSol.",
+ "input_schema": {
+ "type": "object",
+ "properties": {
+ "to": { "type": "string" },
+ "amountSol": { "type": "number" }
+ },
+ "required": ["to", "amountSol"]
+ }
+ },
+ {
+ "name": "transferSpl",
+ "description": "Send an SPL token to a recipient. Auto-creates recipient ATA.",
+ "input_schema": {
+ "type": "object",
+ "properties": {
+ "mint": { "type": "string" },
+ "to": { "type": "string" },
+ "amount": { "type": "number", "description": "ui amount (decimals applied internally)" }
+ },
+ "required": ["mint", "to", "amount"]
+ }
+ },
+ {
+ "name": "wrapSol",
+ "description": "Wrap SOL into wSOL (SPL).",
+ "input_schema": {
+ "type": "object",
+ "properties": { "amountSol": { "type": "number" } },
+ "required": ["amountSol"]
+ }
+ },
+ {
+ "name": "unwrapSol",
+ "description": "Close the wSOL ATA and reclaim SOL.",
+ "input_schema": { "type": "object", "properties": {} }
+ },
+ {
+ "name": "getRecentSignatures",
+ "description": "Recent transaction signatures for the wallet (or address).",
+ "input_schema": {
+ "type": "object",
+ "properties": {
+ "address": { "type": "string" },
+ "limit": { "type": "integer", "minimum": 1, "maximum": 100, "default": 25 }
+ }
+ }
+ }
+ ]
+}
diff --git a/public/skills/pump-fun/handlers.js b/public/skills/pump-fun/handlers.js
index 749b5288d..3795b4dad 100644
--- a/public/skills/pump-fun/handlers.js
+++ b/public/skills/pump-fun/handlers.js
@@ -1,13 +1,13 @@
// pump-fun skill — proxies tool calls to the pump-fun-workers MCP server.
// https://github.com/nirholas/pump-fun-workers
-const DEFAULT_ENDPOINT = 'https://pump-fun-sdk.modelcontextprotocol.name/mcp';
+const ENDPOINT = 'https://pump-fun-sdk.modelcontextprotocol.name/mcp';
let _rpcId = 0;
-async function callMcp(endpoint, name, args, ctx) {
+async function callMcp(name, args, ctx) {
const fetchImpl = ctx?.fetch ?? globalThis.fetch;
- const res = await fetchImpl(endpoint, {
+ const res = await fetchImpl(ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -18,26 +18,28 @@ async function callMcp(endpoint, name, args, ctx) {
}),
});
- if (!res.ok) throw new Error(`pump-fun MCP HTTP ${res.status}`);
+ if (!res.ok) return { ok: false, error: `pump-fun MCP HTTP ${res.status}` };
const body = await res.json();
- if (body.error) throw new Error(body.error.message ?? 'pump-fun MCP error');
+ if (body.error) return { ok: false, error: body.error.message ?? 'pump-fun MCP error' };
const content = body.result?.content ?? [];
const text = content.find((c) => c.type === 'text')?.text;
- if (!text) return body.result;
- try {
- return JSON.parse(text);
- } catch {
- return text;
+ let data = body.result;
+ if (text) {
+ try {
+ data = JSON.parse(text);
+ } catch {
+ data = text;
+ }
}
+ return { ok: true, data };
}
function makeHandler(toolName) {
return async (args, ctx) => {
- const endpoint = ctx?.skillConfig?.endpoint ?? DEFAULT_ENDPOINT;
- const data = await callMcp(endpoint, toolName, args, ctx);
- ctx?.memory?.note?.(`pump-fun:${toolName}`, { args });
- return { ok: true, data };
+ const result = await callMcp(toolName, args, ctx);
+ if (result.ok) ctx?.memory?.note?.(`pump-fun:${toolName}`, { args });
+ return result;
};
}
diff --git a/public/skills/pump-fun/manifest.json b/public/skills/pump-fun/manifest.json
index 343c93f9d..b68ba3df3 100644
--- a/public/skills/pump-fun/manifest.json
+++ b/public/skills/pump-fun/manifest.json
@@ -23,8 +23,5 @@
"getTokenHolders"
],
"triggers": ["token_lookup", "market_check", "rug_check"]
- },
- "config": {
- "endpoint": "https://pump-fun-sdk.modelcontextprotocol.name/mcp"
}
}
diff --git a/scripts/migrations/add-solana-attestations-event-id-index.sql b/scripts/migrations/add-solana-attestations-event-id-index.sql
new file mode 100644
index 000000000..233302f66
--- /dev/null
+++ b/scripts/migrations/add-solana-attestations-event-id-index.sql
@@ -0,0 +1,20 @@
+-- Indexes the event_id stored in solana_attestations.payload for the
+-- pumpkit -> attestation bridge (api/agents/solana-attest-event.js).
+--
+-- Two effects:
+-- 1. Performance: the idempotency lookup
+-- select 1 from solana_attestations
+-- where agent_asset = $1 and network = $2 and payload->>'event_id' = $3
+-- becomes O(log n) instead of a sequential scan.
+-- 2. Correctness: the unique partial index serializes concurrent webhook
+-- retries at the DB layer. If two webhook deliveries race past the
+-- app-level dedupe check, the second insert hits unique_violation
+-- (Postgres 23505) and the handler returns deduped:true.
+--
+-- Partial because legacy attestations (user-submitted feedback memos) do
+-- not carry an event_id, and we don't want to constrain those.
+
+create unique index concurrently if not exists
+ solana_attestations_event_id_uniq
+ on solana_attestations (agent_asset, network, (payload->>'event_id'))
+ where payload ? 'event_id';
diff --git a/src/agent-skills-pumpfun-autonomous.js b/src/agent-skills-pumpfun-autonomous.js
new file mode 100644
index 000000000..ff5a6522c
--- /dev/null
+++ b/src/agent-skills-pumpfun-autonomous.js
@@ -0,0 +1,209 @@
+/**
+ * Pump.fun autonomous skills for Solana agents
+ * --------------------------------------------
+ * These skills make an agent act with its OWN server-side Solana wallet
+ * (provisioned in api/_lib/agent-pumpfun.js). Distinct from
+ * agent-skills-pumpfun.js, which signs with the human owner's browser wallet.
+ *
+ * Use cases:
+ * - Agent pays for its own services / subscriptions on chain
+ * - Agent autonomously launches a follow-up token without user click
+ * - Agent rebalances its treasury (swap)
+ * - Agent withdraws collected payments to its main vault
+ *
+ * Auth: relies on session cookie or bearer token from the calling environment.
+ * The server-side endpoints already verify caller ownership of the agent.
+ *
+ * No keys touched here. No SDK imports. Pure HTTP fetch.
+ */
+
+const ENDPOINT = (id, leaf) =>
+ `/api/agents/${encodeURIComponent(id)}/pumpfun/${leaf}`;
+
+async function postJson(url, body) {
+ const res = await fetch(url, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify(body || {}),
+ });
+ const data = await res.json().catch(() => ({}));
+ if (!res.ok) {
+ const msg = data?.error_description || `${url} returned ${res.status}`;
+ const err = new Error(msg);
+ err.status = res.status;
+ err.code = data?.error;
+ throw err;
+ }
+ return data;
+}
+
+function requireAgentId(ctx) {
+ const id = ctx?.identity?.id;
+ if (!id) throw new Error('No agent identity in context.');
+ return id;
+}
+
+/**
+ * @param {import('./agent-skills.js').AgentSkills} skills
+ */
+export function registerPumpFunAutonomousSkills(skills) {
+ // ── pumpfun-self-launch ───────────────────────────────────────────────────
+ skills.register({
+ name: 'pumpfun-self-launch',
+ description:
+ "Launch a pump.fun token signed by the agent's own Solana wallet (server-side). The agent becomes the creator.",
+ instruction:
+ 'POSTs to /api/agents/:id/pumpfun/launch. The user must own the agent (server enforces).',
+ animationHint: 'celebrate',
+ voicePattern: 'Launching {{symbol}} from my own wallet…',
+ mcpExposed: true,
+ inputSchema: {
+ type: 'object',
+ properties: {
+ name: { type: 'string' },
+ symbol: { type: 'string' },
+ uri: { type: 'string', description: 'Pre-uploaded metadata URI' },
+ solAmount: { type: 'number', description: 'Optional initial dev-buy in SOL' },
+ network: { type: 'string', enum: ['mainnet', 'devnet'] },
+ },
+ required: ['symbol', 'uri'],
+ },
+ handler: async (args, ctx) => {
+ const id = requireAgentId(ctx);
+ const data = await postJson(ENDPOINT(id, 'launch'), {
+ name: args.name || ctx.identity?.name,
+ symbol: args.symbol,
+ uri: args.uri,
+ solAmount: args.solAmount,
+ network: args.network,
+ });
+ return {
+ success: true,
+ output: `Launched ${data.symbol || args.symbol}. Mint: ${data.mint}`,
+ sentiment: 0.9,
+ data,
+ };
+ },
+ });
+
+ // ── pumpfun-self-launch-from-identity ─────────────────────────────────────
+ skills.register({
+ name: 'pumpfun-self-launch-from-identity',
+ description:
+ 'One-shot: agent autonomously launches a token whose metadata is auto-derived from its identity (name, GLB, bio).',
+ instruction:
+ 'Resolves /api/agents/pumpfun-metadata?id=<id>, then calls pumpfun-self-launch.',
+ animationHint: 'celebrate',
+ voicePattern: 'Minting myself…',
+ mcpExposed: true,
+ inputSchema: {
+ type: 'object',
+ properties: {
+ symbol: { type: 'string' },
+ solAmount: { type: 'number' },
+ network: { type: 'string', enum: ['mainnet', 'devnet'] },
+ },
+ },
+ handler: async (args, ctx) => {
+ const id = requireAgentId(ctx);
+ const origin = (typeof window !== 'undefined' && window.location?.origin) || '';
+ const uri = `${origin}/api/agents/pumpfun-metadata?id=${encodeURIComponent(id)}`;
+ const symbol =
+ args.symbol ||
+ (ctx.identity?.name || 'AGENT')
+ .toUpperCase()
+ .replace(/[^A-Z0-9]/g, '')
+ .slice(0, 10) ||
+ 'AGENT';
+ return skills.perform(
+ 'pumpfun-self-launch',
+ { name: ctx.identity?.name, symbol, uri, solAmount: args.solAmount, network: args.network },
+ ctx,
+ );
+ },
+ });
+
+ // ── pumpfun-self-swap ─────────────────────────────────────────────────────
+ skills.register({
+ name: 'pumpfun-self-swap',
+ description:
+ "Buy or sell a pump.fun token from the agent's own wallet. Auto-routes bonding-curve vs AMM by graduation status.",
+ instruction:
+ 'POSTs to /api/agents/:id/pumpfun/swap. Server picks pump-sdk or pump-swap-sdk by curve state.',
+ animationHint: 'gesture',
+ voicePattern: '{{side}} {{mint}}…',
+ mcpExposed: true,
+ inputSchema: {
+ type: 'object',
+ properties: {
+ mint: { type: 'string' },
+ side: { type: 'string', enum: ['buy', 'sell'] },
+ solAmount: { type: 'number', description: 'For buy: SOL to spend' },
+ tokenAmount: { type: 'string', description: 'For sell: tokens (raw units)' },
+ slippageBps: { type: 'integer', minimum: 0, maximum: 10000 },
+ network: { type: 'string', enum: ['mainnet', 'devnet'] },
+ },
+ required: ['mint', 'side'],
+ },
+ handler: async (args, ctx) => {
+ const id = requireAgentId(ctx);
+ const data = await postJson(ENDPOINT(id, 'swap'), {
+ mint: args.mint,
+ side: args.side,
+ solAmount: args.solAmount,
+ tokenAmount: args.tokenAmount,
+ slippageBps: args.slippageBps ?? 500,
+ network: args.network || 'mainnet',
+ });
+ return {
+ success: true,
+ output:
+ args.side === 'buy'
+ ? `Bought ${args.mint.slice(0, 8)}… for ${args.solAmount} SOL.`
+ : `Sold ${args.tokenAmount} of ${args.mint.slice(0, 8)}…`,
+ sentiment: 0.5,
+ data,
+ };
+ },
+ });
+
+ // ── pumpfun-self-pay ──────────────────────────────────────────────────────
+ skills.register({
+ name: 'pumpfun-self-pay',
+ description:
+ "Agent-side payment ops: accept (pay an agent), withdraw (pull collected fees), balances (read).",
+ instruction: 'POSTs to /api/agents/:id/pumpfun/pay with { action, ... }.',
+ animationHint: 'gesture',
+ voicePattern: 'Pump payment {{action}}…',
+ mcpExposed: true,
+ inputSchema: {
+ type: 'object',
+ properties: {
+ action: { type: 'string', enum: ['accept', 'withdraw', 'balances'] },
+ tokenMint: { type: 'string' },
+ currencyMint: { type: 'string' },
+ amount: { type: 'string' },
+ memo: { type: 'string' },
+ startTime: { type: 'number' },
+ endTime: { type: 'number' },
+ receiverAta: { type: 'string', description: 'For withdraw' },
+ network: { type: 'string', enum: ['mainnet', 'devnet'] },
+ },
+ required: ['action'],
+ },
+ handler: async (args, ctx) => {
+ const id = requireAgentId(ctx);
+ const data = await postJson(ENDPOINT(id, 'pay'), args);
+ let output;
+ if (args.action === 'balances') {
+ output = `Balances: ${JSON.stringify(data.balances || data)}`;
+ } else if (args.action === 'accept') {
+ output = `Payment accepted (${args.amount}).`;
+ } else {
+ output = `Withdraw complete.`;
+ }
+ return { success: true, output, sentiment: 0.5, data };
+ },
+ });
+}
diff --git a/src/agent-skills.js b/src/agent-skills.js
index eb26d1cd5..845424eb4 100644
--- a/src/agent-skills.js
+++ b/src/agent-skills.js
@@ -14,6 +14,7 @@ import { ACTION_TYPES } from './agent-protocol.js';
import { MEMORY_TYPES } from './agent-memory.js';
import { registerPumpFunSkills } from './agent-skills-pumpfun.js';
import { registerPumpFunWatchSkills } from './agent-skills-pumpfun-watch.js';
+import { registerPumpFunAutonomousSkills } from './agent-skills-pumpfun-autonomous.js';
/**
* @typedef {Object} SkillContext
@@ -57,6 +58,7 @@ export class AgentSkills {
this._registerBuiltins();
registerPumpFunSkills(this);
registerPumpFunWatchSkills(this);
+ registerPumpFunAutonomousSkills(this);
}
// ── Registry ──────────────────────────────────────────────────────────────
diff --git a/src/erc8004/deploy-button.js b/src/erc8004/deploy-button.js
index 297e6a4c2..c0574348b 100644
--- a/src/erc8004/deploy-button.js
+++ b/src/erc8004/deploy-button.js
@@ -279,13 +279,31 @@ export class DeployButton {
}
const network = _solanaNetwork(this._chainId);
- const steps = ['Connecting wallet', 'Sign tx', 'Confirming on-chain', 'Saving'];
+ 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'];
this._renderProgress(steps, 0);
let result;
try {
+ result = await runSolanaDeploy({
+ agent,
+ network,
+ vanity: vanityPrefix ? {
+ prefix: vanityPrefix,
+ onProgress: ({ attempts, rate, eta }) => {
+ const live = this._root.querySelector('.deploy-progress');
+ if (live) {
+ live.setAttribute(
+ 'aria-label',
+ `Grinding ${vanityPrefix}: ${attempts.toLocaleString()} tries, ${Math.round(rate).toLocaleString()}/s, eta ${eta}`,
+ );
+ }
+ },
+ } : undefined,
+ });
this._renderProgress(steps, 1);
- result = await runSolanaDeploy({ agent, network });
this._renderProgress(steps, 3);
} catch (err) {
if (_isUserRejection(err)) return this._renderDeployButton();
@@ -299,6 +317,16 @@ export class DeployButton {
);
return;
}
+ if (err.code === 'payment_required') {
+ this._renderError(
+ `${err.message || 'Paid plan required'} — upgrade to use 5+ character vanity prefixes.`,
+ {
+ label: 'View plans',
+ handler: () => (window.location.href = '/billing.html'),
+ },
+ );
+ return;
+ }
this._renderError(`Solana deploy failed: ${_humanError(err)}`);
return;
}
diff --git a/src/onchain/launch-token-button.js b/src/onchain/launch-token-button.js
new file mode 100644
index 000000000..9496ed1a8
--- /dev/null
+++ b/src/onchain/launch-token-button.js
@@ -0,0 +1,188 @@
+/**
+ * LaunchTokenButton — UI for launching an agent's Pump.fun token.
+ *
+ * Mounting contract:
+ * const btn = new LaunchTokenButton({ agent, container });
+ * btn.mount();
+ *
+ * Visibility:
+ * • If agent already has a launched token → renders a chip linking to it.
+ * • If agent isn't deployed on Solana → renders disabled with tooltip.
+ * • Otherwise → renders the launch button.
+ */
+
+import { getTokenAdapter } from './tokens/index.js';
+import { isUserRejection } from './adapters/index.js';
+
+function _esc(s) {
+ return String(s ?? '')
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+}
+
+export class LaunchTokenButton {
+ /**
+ * @param {object} opts
+ * @param {object} opts.agent
+ * @param {HTMLElement} opts.container
+ * @param {string} [opts.provider] Defaults to 'pumpfun'.
+ */
+ constructor({ agent, container, provider = 'pumpfun' }) {
+ this._agent = agent;
+ this._container = container;
+ this._provider = provider;
+ this._adapter = getTokenAdapter(provider);
+ this._root = null;
+ }
+
+ mount() {
+ this._root = document.createElement('div');
+ this._root.className = 'launch-token-root';
+ this._container.appendChild(this._root);
+ this._render();
+ }
+
+ unmount() {
+ this._root?.remove();
+ this._root = null;
+ }
+
+ _render() {
+ if (!this._root) return;
+ const token = this._agent.token || this._agent.meta?.token;
+ if (token?.mint) return this._renderChip(token);
+
+ const pre = this._adapter.validatePreconditions({ agent: this._agent });
+ if (!pre.ok) return this._renderDisabled(pre.reason);
+
+ this._renderLaunchButton();
+ }
+
+ _renderLaunchButton() {
+ this._root.innerHTML = `
+ <button class="launch-token-btn" title="Launch this agent's token on Pump.fun">
+ &#x1F680; Launch token
+ </button>
+ `;
+ this._root.querySelector('.launch-token-btn').addEventListener('click', () => this._openModal());
+ }
+
+ _renderDisabled(reason) {
+ this._root.innerHTML = `
+ <button class="launch-token-btn launch-token-btn--disabled" disabled title="${_esc(reason)}">
+ &#x1F680; Launch token
+ </button>
+ <span class="launch-token-tooltip">${_esc(reason)}</span>
+ `;
+ }
+
+ _renderChip(token) {
+ const url = token.pumpfun_url || token.explorer_url || '#';
+ this._root.innerHTML = `
+ <a class="launch-token-chip" href="${_esc(url)}" target="_blank" rel="noopener noreferrer"
+ aria-label="View ${_esc(token.symbol)} on Pump.fun">
+ &#x1F680; $${_esc(token.symbol)} &middot; view on ${_esc(token.cluster === 'devnet' ? 'explorer' : 'pump.fun')}
+ </a>
+ `;
+ }
+
+ _renderProgress(step) {
+ const labels = {
+ connect: 'Connecting wallet…',
+ prep: 'Preparing launch…',
+ sign: 'Sign in your wallet…',
+ submit: 'Submitting on-chain…',
+ confirm: 'Saving…',
+ };
+ this._root.innerHTML = `
+ <div class="launch-token-progress" role="status" aria-live="polite">
+ ${_esc(labels[step] || step)}
+ </div>
+ `;
+ }
+
+ _renderError(msg) {
+ this._root.innerHTML = `
+ <div class="launch-token-error" role="alert">
+ <span>${_esc(msg)}</span>
+ <button class="launch-token-retry">Try again</button>
+ </div>
+ `;
+ this._root.querySelector('.launch-token-retry').addEventListener('click', () => this._render());
+ }
+
+ _openModal() {
+ // Inline lightweight modal — keeps this component self-contained.
+ const overlay = document.createElement('div');
+ overlay.className = 'launch-token-modal-overlay';
+ overlay.innerHTML = `
+ <div class="launch-token-modal" role="dialog" aria-label="Launch agent token">
+ <h3>Launch \$${_esc(this._agent.name || 'AGENT')}</h3>
+ <p>Mint a token tied to this agent on Pump.fun's bonding curve. The token's metadata will point to your agent.</p>
+ <form class="launch-token-form">
+ <label>Name <input name="name" maxlength="32" required value="${_esc(this._agent.name || '')}"></label>
+ <label>Symbol (ticker) <input name="symbol" maxlength="10" required pattern="[A-Za-z0-9]{2,10}" value="${_esc((this._agent.name || 'AGT').slice(0, 6).toUpperCase())}"></label>
+ <label>Description <textarea name="description" maxlength="280">${_esc(this._agent.description || '')}</textarea></label>
+ <label>Initial buy (SOL, optional)
+ <input name="initial_buy" type="number" min="0" max="50" step="0.01" value="0">
+ </label>
+ <div class="launch-token-modal-actions">
+ <button type="button" class="launch-token-cancel">Cancel</button>
+ <button type="submit" class="launch-token-submit">Launch</button>
+ </div>
+ </form>
+ </div>
+ `;
+ document.body.appendChild(overlay);
+
+ const close = () => overlay.remove();
+ overlay.querySelector('.launch-token-cancel').addEventListener('click', close);
+ overlay.addEventListener('click', (e) => {
+ if (e.target === overlay) close();
+ });
+
+ overlay.querySelector('.launch-token-form').addEventListener('submit', async (ev) => {
+ ev.preventDefault();
+ const fd = new FormData(ev.target);
+ const params = {
+ name: String(fd.get('name') || '').trim(),
+ symbol: String(fd.get('symbol') || '')
+ .trim()
+ .toUpperCase(),
+ description: String(fd.get('description') || '').trim(),
+ image: this._agent.thumbnailUrl || this._agent.avatar?.thumbnailUrl || '',
+ initialBuySol: Number(fd.get('initial_buy') || 0),
+ };
+ close();
+ await this._launch(params);
+ });
+ }
+
+ async _launch(params) {
+ try {
+ const result = await this._adapter.launch({
+ agent: this._agent,
+ params,
+ onProgress: (step) => this._renderProgress(step),
+ });
+ this._agent.token = {
+ provider: result.provider,
+ mint: result.mint,
+ symbol: params.symbol,
+ name: params.name,
+ cluster: result.cluster,
+ pumpfun_url: result.pumpfunUrl,
+ };
+ this._renderChip(this._agent.token);
+ } catch (err) {
+ if (isUserRejection(err)) return this._render();
+ if (err.code === 'NO_PROVIDER') {
+ this._renderError(`${err.message} Install at ${err.installUrl}`);
+ return;
+ }
+ this._renderError(err.message || 'Token launch failed.');
+ }
+ }
+}
diff --git a/src/widget-types.js b/src/widget-types.js
index cc78391e0..be5643ac8 100644
--- a/src/widget-types.js
+++ b/src/widget-types.js
@@ -38,6 +38,12 @@ export const WIDGET_TYPES = {
status: 'ready',
icon: '⌖',
},
+ 'pumpfun-feed': {
+ label: 'Pump.fun Live Feed',
+ desc: 'Solana agent narrates live pump.fun claims and graduations.',
+ status: 'ready',
+ icon: '✦',
+ },
};
export const WIDGET_TYPE_KEYS = Object.keys(WIDGET_TYPES);
@@ -89,6 +95,12 @@ const TYPE_DEFAULTS = {
showPoweredBy: true,
},
'hotspot-tour': { hotspots: [] },
+ 'pumpfun-feed': {
+ kind: 'all',
+ minTier: '',
+ autoNarrate: true,
+ maxCards: 8,
+ },
};
const hexColor = z.string().regex(/^#[0-9a-fA-F]{3,8}$/, 'must be a hex color');
@@ -197,6 +209,12 @@ const TYPE_SCHEMAS = {
.max(40)
.default([]),
}),
+ 'pumpfun-feed': brandSchema.extend({
+ kind: z.enum(['all', 'claims', 'graduations']).default('all'),
+ minTier: z.enum(['', 'notable', 'influencer', 'mega']).default(''),
+ autoNarrate: z.boolean().default(true),
+ maxCards: z.number().int().min(1).max(50).default(8),
+ }),
};
export function defaultConfig(type) {
diff --git a/tests/src/onchain-tokens.test.js b/tests/src/onchain-tokens.test.js
new file mode 100644
index 000000000..d117c14f3
--- /dev/null
+++ b/tests/src/onchain-tokens.test.js
@@ -0,0 +1,67 @@
+/**
+ * Tests for the token-launch facade. Pure-logic only — wallet I/O and the
+ * Pump.fun SDK are exercised in integration tests.
+ */
+
+import { describe, it, expect } from 'vitest';
+import {
+ getTokenAdapter,
+ listProviders,
+ _resetTokenAdapters,
+} from '../../src/onchain/tokens/index.js';
+
+describe('TokenAdapter factory', () => {
+ it('lists known providers', () => {
+ expect(listProviders()).toContain('pumpfun');
+ });
+
+ it('returns and caches the pumpfun adapter', () => {
+ _resetTokenAdapters();
+ const a = getTokenAdapter('pumpfun');
+ const b = getTokenAdapter('pumpfun');
+ expect(a).toBe(b);
+ expect(a.provider).toBe('pumpfun');
+ expect(a.family).toBe('solana');
+ });
+
+ it('throws for unknown providers', () => {
+ expect(() => getTokenAdapter('zora')).toThrow(/no token adapter/i);
+ });
+});
+
+describe('PumpfunTokenAdapter.validatePreconditions', () => {
+ const adapter = getTokenAdapter('pumpfun');
+
+ it('rejects an agent that is not deployed on-chain', () => {
+ const r = adapter.validatePreconditions({ agent: { id: 'a' } });
+ expect(r.ok).toBe(false);
+ expect(r.reason).toMatch(/deployed/i);
+ });
+
+ it('rejects an agent deployed on EVM', () => {
+ const r = adapter.validatePreconditions({
+ agent: { id: 'a', onchain: { family: 'evm', chain: 'eip155:8453' } },
+ });
+ expect(r.ok).toBe(false);
+ expect(r.reason).toMatch(/solana/i);
+ });
+
+ it('rejects an agent that already launched a token', () => {
+ const r = adapter.validatePreconditions({
+ agent: {
+ id: 'a',
+ onchain: { family: 'solana', cluster: 'mainnet' },
+ token: { mint: 'AbC' },
+ },
+ });
+ expect(r.ok).toBe(false);
+ expect(r.reason).toMatch(/already/i);
+ });
+
+ it('accepts a Solana-deployed agent without a token', () => {
+ const r = adapter.validatePreconditions({
+ agent: { id: 'a', onchain: { family: 'solana', cluster: 'devnet' } },
+ });
+ expect(r.ok).toBe(true);
+ });
+});