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(pump): inaugural USDC launch scripts + self-contained prompts

nirholas08160ddceded
diff --git a/prompts/pumpfun-usdc-deploy.md b/prompts/pumpfun-usdc-deploy.md
new file mode 100644
index 000000000..0ffae6bb8
--- /dev/null
+++ b/prompts/pumpfun-usdc-deploy.md
@@ -0,0 +1,103 @@
+# Task: Launch the inaugural USDC-paired pump.fun coin
+
+## Project overview
+
+This is the **three.ws** workspace at `/workspaces/three.ws` — a Three.js / Vite + Vercel-functions app for AI-agent tokenization on pump.fun. Pump.fun is enabling USDC as a quote mint on **Thursday, 2026-05-21** (the SDK and our backend wiring are already in place; this task is the first real on-chain USDC launch).
+
+## Goal
+
+Deploy a USDC-paired pump.fun coin via direct SDK call (bypassing the API auth flow), then write the result to `~/.claude/pump-deploy/launch-result.json`. Coin parameters:
+
+- **name:** `USDC`
+- **symbol:** `USDC`
+- **description:** `testing 3D AI Agents with USDC on PumpFun`
+- **initial buy:** 10 USDC
+- **quote mint:** `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` (mainnet USDC)
+
+## Preconditions (verify before doing anything)
+
+Run these checks and abort with a clear message if any fail:
+
+```bash
+# 1. Deploy wallet keypair exists
+test -f ~/.claude/pump-deploy/wallet.json || { echo "Missing wallet.json — generate via scripts/pump-vanity-grind.mjs"; exit 1; }
+
+# 2. Vanity mint keypair exists
+test -f ~/.claude/pump-deploy/mint-latest.json || { echo "Missing mint-latest.json — run: PREFIX=usdc node scripts/pump-vanity-grind.mjs"; exit 1; }
+
+# 3. Wallet is funded with >= 0.03 SOL + >= 10 USDC
+node -e "
+const { Connection, Keypair, PublicKey } = require('@solana/web3.js');
+const { getAssociatedTokenAddress, getAccount } = require('@solana/spl-token');
+const fs = require('fs'), os = require('os'), path = require('path');
+const w = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(fs.readFileSync(path.join(os.homedir(), '.claude/pump-deploy/wallet.json')))));
+const USDC = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
+(async () => {
+ const c = new Connection(process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com', 'confirmed');
+ const sol = await c.getBalance(w.publicKey);
+ let usdc = 0n;
+ try {
+ const ata = await getAssociatedTokenAddress(USDC, w.publicKey, false);
+ const acc = await getAccount(c, ata);
+ usdc = acc.amount;
+ } catch {}
+ console.log('SOL:', (sol/1e9).toFixed(6), 'USDC:', (Number(usdc)/1e6).toFixed(6));
+ if (sol < 0.03e9 || usdc < 10_000_000n) { console.error('Underfunded'); process.exit(1); }
+})();
+"
+```
+
+The deploy wallet pubkey is `4dERfsqLVcqBuULpXYTpBtgZB9X62LfowfxqVL4aAPsH`. If the user hasn't funded it, surface the address and bail — don't try to deploy.
+
+## Execute
+
+The complete launch script is in this repo at `scripts/pump-launch-usdc.mjs`. It:
+
+1. Loads the wallet + vanity mint keypairs from `~/.claude/pump-deploy/`
+2. Verifies SOL + USDC balances on mainnet
+3. Reads `Global.whitelistedQuoteMints` and reports whether the USDC gate is open
+4. Uploads metadata (1×1 PNG + JSON descriptor) to `https://pump.fun/api/ipfs`
+5. Calls `offline.createV2AndBuyV2Instructions({ quoteMint: USDC, … })`
+6. Builds + signs a v0 versioned tx (wallet + mint as co-signers)
+7. **Simulates against mainnet first**
+ - If sim fails AND USDC gate is closed → records `{ ok: false, reason: 'usdc_gate_closed' }` and exits; **does not submit**
+ - If sim fails for any other reason and not DRY_RUN → records the error and exits
+ - If sim passes → proceeds
+8. Submits, waits for confirmation
+9. Writes `~/.claude/pump-deploy/launch-result.json` with the outcome
+
+Run:
+
+```bash
+cd /workspaces/three.ws
+node scripts/pump-launch-usdc.mjs
+```
+
+Optional env overrides:
+
+- `SOLANA_RPC_URL=https://…helius…` (recommended — public RPC is rate-limited)
+- `DRY_RUN=1` simulate only, never submit
+- `USDC_BUY_IN_ATOMICS=5000000` override initial buy (default 10000000 = 10 USDC)
+
+## Success criteria
+
+`~/.claude/pump-deploy/launch-result.json` has `{ "ok": true, "tx_signature": "…", "mint": "…", "pump_url": "https://pump.fun/coin/…" }`.
+
+If `ok: false` with `reason: "usdc_gate_closed"`: pump.fun's whitelist hasn't flipped yet. **Do not delete this prompt** — re-run after Thursday 2026-05-21 (see `prompts/pumpfun-usdc-monitor-gate.md` if it still exists).
+
+If `ok: false` for any other reason: read the recorded error, fix the underlying issue (insufficient funds, RPC failure, etc.) and re-run.
+
+## On completion
+
+When `~/.claude/pump-deploy/launch-result.json` shows `ok: true`:
+
+1. Print the mint, tx signature, and pump.fun URL to the user.
+2. Delete this prompt file: `rm /workspaces/three.ws/prompts/pumpfun-usdc-deploy.md`
+3. Commit the deletion + any related changes as `nirholas <[email protected]>`, push to both `origin` and `threews`.
+4. If the user wants the coin linked to a three.ws agent_identity, hand off to `prompts/pumpfun-usdc-link-agent.md`.
+
+## Notes
+
+- This bypasses the `/api/pump/launch-prep` flow because that path requires session-cookie auth that isn't available to a script. The coin lands on-chain regardless; database linking is a separate prompt.
+- Do not commit anything under `~/.claude/pump-deploy/` — those files contain secret keys and live outside the repo for a reason.
+- The vanity mint was ground for `usdc`-prefix; the public address starts with `USDC…`. Don't regenerate unless explicitly asked.
diff --git a/prompts/pumpfun-usdc-link-agent.md b/prompts/pumpfun-usdc-link-agent.md
new file mode 100644
index 000000000..38738fcbe
--- /dev/null
+++ b/prompts/pumpfun-usdc-link-agent.md
@@ -0,0 +1,69 @@
+# Task: Link the launched USDC pump.fun coin to an agent_identity
+
+## Project overview
+
+This is the **three.ws** workspace at `/workspaces/three.ws`. A separate task (`prompts/pumpfun-usdc-deploy.md`) launches a USDC-paired pump.fun coin via direct SDK call. Because that path bypasses the API/session-auth flow, the new coin lands on-chain but has no row in our `pump_agent_mints` DB table — which means it doesn't show up on any agent's profile page. This task patches that.
+
+## Preconditions
+
+```bash
+# 1. The launch must have succeeded.
+test -f ~/.claude/pump-deploy/launch-result.json || { echo "No launch result yet."; exit 1; }
+node -e "const r=JSON.parse(require('fs').readFileSync(require('os').homedir()+'/.claude/pump-deploy/launch-result.json'));if(!r.ok){console.error('launch did not succeed:',r.reason);process.exit(1)}console.log('mint:',r.mint)"
+
+# 2. DATABASE_URL must be set (Neon connection string for the three.ws DB).
+test -n "$DATABASE_URL" || { echo "Export DATABASE_URL from your three.ws Vercel env."; exit 1; }
+```
+
+If `DATABASE_URL` isn't available locally, the user can run this same workflow from a Vercel function or a machine that has it. The script also works in the production environment.
+
+## Execute
+
+The script is in this repo at `scripts/pump-link-mint.mjs`. It reads `~/.claude/pump-deploy/launch-result.json` and upserts into `pump_agent_mints` (idempotent on `mint, network`).
+
+### Step 1: pick an agent
+
+```bash
+cd /workspaces/three.ws
+node scripts/pump-link-mint.mjs
+```
+
+With no `AGENT_ID` env var, the script lists up to 20 recent agent_identities and exits. Pick the one to link.
+
+### Step 2: link
+
+```bash
+AGENT_ID=<uuid> node scripts/pump-link-mint.mjs
+```
+
+Optional env:
+- `NETWORK=mainnet` (default) | `devnet`
+- `BUYBACK_BPS=0` (default; set 0–10000 to enable buyback share)
+- `USER_ID=<uuid>` override the user the link is recorded under (defaults to the agent's owner)
+
+The script inserts into `pump_agent_mints` with `agent_authority` = the deploy wallet pubkey, `metadata_uri` = the IPFS URI from the launch, and the coin's name/symbol.
+
+## Success criteria
+
+- A row exists in `pump_agent_mints` with `mint = <launched mint>` and `agent_id = <chosen agent_id>`.
+- Visiting `/agent/<agent_id>` on three.ws shows the coin in the agent's token section.
+
+Verify by querying:
+
+```bash
+psql "$DATABASE_URL" -c "select id, name, symbol, mint, agent_id, created_at from pump_agent_mints where mint = '$(node -e "console.log(require(require('os').homedir()+'/.claude/pump-deploy/launch-result.json').mint)")';"
+```
+
+## On completion
+
+When the row is confirmed in `pump_agent_mints`:
+
+1. Print the agent page URL to the user (`https://three.ws/agent/<agent_id>`).
+2. Delete this prompt: `rm /workspaces/three.ws/prompts/pumpfun-usdc-link-agent.md`
+3. Commit the deletion as `nirholas <[email protected]>`, push to both `origin` and `threews`.
+
+## Notes
+
+- This prompt is independent of `pumpfun-usdc-deploy.md` — they communicate only through `~/.claude/pump-deploy/launch-result.json` on disk. Either prompt can be re-run idempotently.
+- If no agent exists yet, the user should create one first via the `/studio` UI on three.ws, then return here.
+- For the inaugural USDC coin, the user wanted the agent named "USDC" too. If a matching agent doesn't already exist, ask the user to create one with name="USDC" before linking — but never auto-create on their behalf (that's a UI flow).
diff --git a/prompts/pumpfun-usdc-monitor-gate.md b/prompts/pumpfun-usdc-monitor-gate.md
new file mode 100644
index 000000000..322b45c24
--- /dev/null
+++ b/prompts/pumpfun-usdc-monitor-gate.md
@@ -0,0 +1,59 @@
+# Task: Monitor the pump.fun USDC quote-mint whitelist gate
+
+## Project overview
+
+This is the **three.ws** workspace at `/workspaces/three.ws`. Pump.fun announced that on **Thursday, 2026-05-21**, USDC (`EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`) will be added as an accepted quote mint on their v2 bonding-curve program. Until that flip, any `buy_v2` / `sell_v2` / `create_v2` instruction with `quoteMint = USDC` is rejected by the program.
+
+The exact moment of the flip isn't published. The gate is observable on-chain via `Global.whitelistedQuoteMints` (read from the pump.fun Global PDA). Today that list contains only the System Program ID (placeholder for native SOL).
+
+## Goal
+
+Detect when USDC is added to `Global.whitelistedQuoteMints` and hand off to the deploy task. This prompt should be runnable at any time — it self-discovers state from the chain.
+
+## Execute
+
+Run the status probe (already in repo):
+
+```bash
+cd /workspaces/three.ws
+SOLANA_RPC_URL="${SOLANA_RPC_URL:-https://api.mainnet-beta.solana.com}" node scripts/pump-usdc-status.mjs
+```
+
+The script reads `Global.whitelistedQuoteMints` directly and additionally simulates a real `buyV2Instructions(quoteMint=USDC)` against mainnet to confirm the program would accept it. It exits 0 either way; parse the output:
+
+- If output contains `USDC whitelisted: YES` → **the gate is open**. Proceed.
+- Otherwise → still closed.
+
+## When the gate is open
+
+1. Verify funding for the deploy wallet `4dERfsqLVcqBuULpXYTpBtgZB9X62LfowfxqVL4aAPsH`:
+
+ ```bash
+ node -e "const {Connection,PublicKey}=require('@solana/web3.js');const c=new Connection(process.env.SOLANA_RPC_URL||'https://api.mainnet-beta.solana.com');c.getBalance(new PublicKey('4dERfsqLVcqBuULpXYTpBtgZB9X62LfowfxqVL4aAPsH')).then(b=>console.log((b/1e9).toFixed(6),'SOL'));"
+ ```
+
+2. If `prompts/pumpfun-usdc-deploy.md` still exists, run that prompt — it has the full launch instructions.
+3. If the deploy prompt is gone (already executed and removed), no action; the coin already launched (check `~/.claude/pump-deploy/launch-result.json` for the mint).
+
+## When the gate is still closed
+
+1. Print the current whitelist contents and `createV2Enabled` value to the user.
+2. **Do not delete this prompt.** It remains valid until the flip happens.
+3. Schedule the next check via `/loop 30m /run-prompt pumpfun-usdc-monitor-gate.md` or have the user re-trigger it.
+
+## Success criteria
+
+- The gate flip is detected within a reasonable window of pump.fun's actual rollout.
+- The deploy script runs immediately afterward and either succeeds or surfaces a clear error.
+
+## On completion
+
+When the gate has flipped AND the deploy task has completed successfully (`~/.claude/pump-deploy/launch-result.json` shows `ok: true`):
+
+1. Delete this prompt: `rm /workspaces/three.ws/prompts/pumpfun-usdc-monitor-gate.md`
+2. Commit the deletion as `nirholas <[email protected]>`, push to both `origin` and `threews`.
+
+## Notes
+
+- `scripts/pump-usdc-status.mjs` makes 2 mainnet RPC calls (fetchGlobal + fetchBuyState + 1 simulateTransaction). Public RPC is fine but rate-limited; set `SOLANA_RPC_URL=…helius…` for production polling.
+- The whitelist flip is the authoritative signal. Marketing dates can slip — only trust the on-chain state.
diff --git a/claude.sh b/scripts/claude.sh
similarity index 100%
rename from claude.sh
rename to scripts/claude.sh
diff --git a/gitpretty.sh b/scripts/gitpretty.sh
similarity index 100%
rename from gitpretty.sh
rename to scripts/gitpretty.sh
diff --git a/scripts/pump-launch-usdc.mjs b/scripts/pump-launch-usdc.mjs
new file mode 100644
index 000000000..8fe7d358c
--- /dev/null
+++ b/scripts/pump-launch-usdc.mjs
@@ -0,0 +1,258 @@
+// Inaugural USDC-paired pump.fun launch.
+//
+// Reads:
+// ~/.claude/pump-deploy/wallet.json fee payer + creator + signer
+// ~/.claude/pump-deploy/mint-latest.json vanity mint keypair (co-signer)
+//
+// Defaults match the brief: name="USDC", symbol="USDC",
+// description="testing 3D AI Agents with USDC on PumpFun", initial buy=10 USDC.
+// Override via env:
+// COIN_NAME, COIN_SYMBOL, COIN_DESCRIPTION, COIN_IMAGE_URL
+// USDC_BUY_IN_ATOMICS (default 10000000 = 10 USDC)
+// SOLANA_RPC_URL (default mainnet-beta public)
+// DRY_RUN=1 — simulate only, never submit
+//
+// Writes ~/.claude/pump-deploy/launch-result.json with the outcome (success
+// or rejection details) so follow-up prompts (link-to-agent, retry) have a
+// known state to read.
+
+import { Connection, Keypair, PublicKey, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
+import BN from 'bn.js';
+import fs from 'fs';
+import os from 'os';
+import path from 'path';
+import {
+ PumpSdk,
+ OnlinePumpSdk,
+ isLegacyQuoteMint,
+ getBuyTokenAmountFromSolAmount,
+} from '@pump-fun/pump-sdk';
+import { getAssociatedTokenAddress, getAccount } from '@solana/spl-token';
+
+const RPC = process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com';
+const USDC_MAINNET = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');
+
+const COIN_NAME = process.env.COIN_NAME || 'USDC';
+const COIN_SYMBOL = process.env.COIN_SYMBOL || 'USDC';
+const COIN_DESCRIPTION = process.env.COIN_DESCRIPTION || 'testing 3D AI Agents with USDC on PumpFun';
+const COIN_IMAGE_URL = process.env.COIN_IMAGE_URL || ''; // optional; falls back to a 1x1 png if blank
+const USDC_BUY_IN_ATOMICS = BigInt(process.env.USDC_BUY_IN_ATOMICS || '10000000'); // 10 USDC default
+const DRY_RUN = process.env.DRY_RUN === '1';
+
+const DEPLOY_DIR = path.join(os.homedir(), '.claude', 'pump-deploy');
+
+function loadKp(file) {
+ const raw = fs.readFileSync(path.join(DEPLOY_DIR, file), 'utf8');
+ return Keypair.fromSecretKey(Uint8Array.from(JSON.parse(raw)));
+}
+
+function writeResult(obj) {
+ const out = path.join(DEPLOY_DIR, 'launch-result.json');
+ fs.writeFileSync(out, JSON.stringify({ ...obj, written_at: new Date().toISOString() }, null, 2));
+ console.log(`\nResult written: ${out}`);
+}
+
+async function uploadMetadata() {
+ // pump.fun needs a hosted JSON descriptor at a public URL. We host on R2 via
+ // the existing /api/pump/build-metadata endpoint when available; for a
+ // scripted deploy we use the public ipfs-pinning endpoint pump.fun's own
+ // frontend uses so the descriptor is durable.
+ const form = new FormData();
+ const body = {
+ name: COIN_NAME,
+ symbol: COIN_SYMBOL,
+ description: COIN_DESCRIPTION,
+ twitter: '',
+ telegram: '',
+ website: 'https://three.ws',
+ };
+ if (COIN_IMAGE_URL) body.image = COIN_IMAGE_URL;
+ // Pump.fun's "ipfs" endpoint expects multipart with a `file` (image) and
+ // metadata fields. For a no-image launch we synthesise a 1×1 transparent PNG.
+ const onePxPng = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=', 'base64');
+ form.append('file', new Blob([onePxPng], { type: 'image/png' }), 'token.png');
+ for (const [k, v] of Object.entries(body)) form.append(k, v);
+ form.append('showName', 'true');
+ const r = await fetch('https://pump.fun/api/ipfs', { method: 'POST', body: form });
+ if (!r.ok) throw new Error(`metadata upload failed: ${r.status} ${await r.text().catch(()=>'')}`);
+ const json = await r.json();
+ return json.metadataUri || json.metadata_uri || json.uri;
+}
+
+async function main() {
+ console.log('Pump.fun USDC-paired launch');
+ console.log(' rpc: ', RPC);
+ console.log(' name: ', COIN_NAME);
+ console.log(' symbol: ', COIN_SYMBOL);
+ console.log(' description:', COIN_DESCRIPTION);
+ console.log(' buy in: ', `${Number(USDC_BUY_IN_ATOMICS) / 1e6} USDC`);
+ console.log(' dry run: ', DRY_RUN);
+ console.log('');
+
+ const wallet = loadKp('wallet.json');
+ const mint = loadKp('mint-latest.json');
+ console.log(' wallet: ', wallet.publicKey.toBase58());
+ console.log(' mint: ', mint.publicKey.toBase58());
+ console.log('');
+
+ const connection = new Connection(RPC, 'confirmed');
+
+ // ── 1. Verify funding ──────────────────────────────────────────────────
+ const solBal = await connection.getBalance(wallet.publicKey);
+ const usdcAta = await getAssociatedTokenAddress(USDC_MAINNET, wallet.publicKey, false);
+ let usdcBal = 0n;
+ try {
+ const acc = await getAccount(connection, usdcAta);
+ usdcBal = acc.amount;
+ } catch {}
+ console.log(` sol bal: ${(solBal / 1e9).toFixed(6)} SOL`);
+ console.log(` usdc bal: ${(Number(usdcBal) / 1e6).toFixed(6)} USDC`);
+
+ const MIN_SOL = 0.03 * 1e9;
+ if (solBal < MIN_SOL) {
+ writeResult({ ok: false, reason: 'insufficient_sol', need_sol_atomics: MIN_SOL, have_sol_atomics: solBal });
+ console.error(`Aborting: wallet needs >= ${MIN_SOL / 1e9} SOL, has ${(solBal / 1e9).toFixed(6)}.`);
+ process.exit(1);
+ }
+ if (usdcBal < USDC_BUY_IN_ATOMICS) {
+ writeResult({ ok: false, reason: 'insufficient_usdc', need_usdc_atomics: USDC_BUY_IN_ATOMICS.toString(), have_usdc_atomics: usdcBal.toString() });
+ console.error(`Aborting: wallet needs >= ${Number(USDC_BUY_IN_ATOMICS) / 1e6} USDC, has ${(Number(usdcBal) / 1e6).toFixed(6)}.`);
+ process.exit(1);
+ }
+
+ // ── 2. Whitelist precheck ──────────────────────────────────────────────
+ const offline = new PumpSdk();
+ const online = new OnlinePumpSdk(connection);
+ const global = await online.fetchGlobal();
+ const list = (global.whitelistedQuoteMints || []).map((k) => k.toBase58());
+ const usdcWhitelisted = list.includes(USDC_MAINNET.toBase58());
+ console.log(` whitelist: ${list.join(', ')}`);
+ console.log(` usdc gate: ${usdcWhitelisted ? 'OPEN' : 'CLOSED (program will reject)'}`);
+ if (!usdcWhitelisted) {
+ console.log('\n Proceeding anyway to capture the rejection error.');
+ }
+ console.log('');
+
+ // ── 3. Upload metadata ─────────────────────────────────────────────────
+ console.log('Uploading metadata to pump.fun IPFS…');
+ const uri = await uploadMetadata();
+ console.log(` uri: ${uri}`);
+ console.log('');
+
+ // ── 4. Build createV2 + buyV2 instructions ─────────────────────────────
+ if (!isLegacyQuoteMint(USDC_MAINNET) !== true) {
+ // sanity: USDC must register as non-legacy
+ console.warn(' isLegacyQuoteMint(USDC) returned unexpected value');
+ }
+ const quoteAmount = new BN(USDC_BUY_IN_ATOMICS.toString());
+ const tokenAmount = getBuyTokenAmountFromSolAmount({
+ global,
+ feeConfig: null,
+ mintSupply: null,
+ bondingCurve: null,
+ amount: quoteAmount,
+ });
+ const ixs = await offline.createV2AndBuyV2Instructions({
+ global,
+ mint: mint.publicKey,
+ name: COIN_NAME,
+ symbol: COIN_SYMBOL,
+ uri,
+ creator: wallet.publicKey,
+ user: wallet.publicKey,
+ quoteAmount,
+ amount: tokenAmount,
+ mayhemMode: false,
+ quoteMint: USDC_MAINNET,
+ });
+ console.log(`Built ${ixs.length} instruction${ixs.length === 1 ? '' : 's'}.`);
+
+ // ── 5. Build + sign tx ─────────────────────────────────────────────────
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
+ const msg = new TransactionMessage({
+ payerKey: wallet.publicKey,
+ recentBlockhash: blockhash,
+ instructions: ixs,
+ }).compileToV0Message();
+ const vtx = new VersionedTransaction(msg);
+ vtx.sign([wallet, mint]);
+
+ // ── 6. Simulate ────────────────────────────────────────────────────────
+ console.log('Simulating against mainnet…');
+ const sim = await connection.simulateTransaction(vtx, { sigVerify: true });
+ if (sim.value.err) {
+ console.log(` sim err: ${JSON.stringify(sim.value.err)}`);
+ const logs = sim.value.logs || [];
+ const interesting = logs.filter((l) => /Error|fail|reject|invalid|whitelist|disabled/i.test(l));
+ if (interesting.length) {
+ console.log(' relevant logs:');
+ for (const l of interesting.slice(0, 8)) console.log(` ${l}`);
+ }
+ if (DRY_RUN || !usdcWhitelisted) {
+ writeResult({
+ ok: false,
+ reason: usdcWhitelisted ? 'simulation_error' : 'usdc_gate_closed',
+ err: sim.value.err,
+ logs: interesting,
+ mint: mint.publicKey.toBase58(),
+ wallet: wallet.publicKey.toBase58(),
+ });
+ console.log('\nNot submitting.');
+ process.exit(2);
+ }
+ } else {
+ console.log(' sim: OK');
+ }
+ console.log('');
+
+ if (DRY_RUN) {
+ writeResult({ ok: true, dry_run: true, sim_passed: !sim.value.err, mint: mint.publicKey.toBase58() });
+ console.log('Dry run; not submitting.');
+ return;
+ }
+
+ // ── 7. Submit ──────────────────────────────────────────────────────────
+ console.log('Submitting…');
+ const sig = await connection.sendRawTransaction(vtx.serialize(), { skipPreflight: false, maxRetries: 3 });
+ console.log(` sig: ${sig}`);
+ console.log(` solscan: https://solscan.io/tx/${sig}`);
+
+ console.log('Confirming…');
+ const confirmation = await connection.confirmTransaction(
+ { signature: sig, blockhash, lastValidBlockHeight },
+ 'confirmed',
+ );
+ if (confirmation.value.err) {
+ writeResult({
+ ok: false,
+ reason: 'tx_confirmed_with_error',
+ err: confirmation.value.err,
+ tx_signature: sig,
+ mint: mint.publicKey.toBase58(),
+ wallet: wallet.publicKey.toBase58(),
+ });
+ console.error(`Confirmed with error: ${JSON.stringify(confirmation.value.err)}`);
+ process.exit(3);
+ }
+
+ writeResult({
+ ok: true,
+ mint: mint.publicKey.toBase58(),
+ wallet: wallet.publicKey.toBase58(),
+ tx_signature: sig,
+ uri,
+ coin_name: COIN_NAME,
+ coin_symbol: COIN_SYMBOL,
+ usdc_buy_in_atomics: USDC_BUY_IN_ATOMICS.toString(),
+ pump_url: `https://pump.fun/coin/${mint.publicKey.toBase58()}`,
+ solscan: `https://solscan.io/tx/${sig}`,
+ });
+ console.log(`\nLaunched.`);
+ console.log(` pump.fun: https://pump.fun/coin/${mint.publicKey.toBase58()}`);
+}
+
+main().catch((err) => {
+ writeResult({ ok: false, reason: 'exception', err: err?.message || String(err) });
+ console.error(err);
+ process.exit(1);
+});
diff --git a/scripts/pump-link-mint.mjs b/scripts/pump-link-mint.mjs
new file mode 100644
index 000000000..b9a6f5d76
--- /dev/null
+++ b/scripts/pump-link-mint.mjs
@@ -0,0 +1,105 @@
+// Links a freshly-launched pump.fun coin to an agent_identity on three.ws.
+//
+// Reads:
+// ~/.claude/pump-deploy/launch-result.json outcome from pump-launch-usdc.mjs
+// $DATABASE_URL neon/postgres connection string
+//
+// Inserts into pump_agent_mints (so the coin shows up on the agent's page) and
+// optionally into coin_launches (for the lottery/reflection mechanic — skipped
+// by default since this is a vanilla token launch).
+//
+// Env:
+// AGENT_ID — required. The agent_identity uuid to link to. If unset, the
+// script lists candidate agents owned by the wallet's linked user
+// and exits with instructions.
+// USER_ID — optional override. Default: derived from agent_identities.user_id.
+// NETWORK — mainnet (default) | devnet
+// BUYBACK_BPS — int 0..10000 (default 0).
+
+import { neon } from '@neondatabase/serverless';
+import fs from 'fs';
+import os from 'os';
+import path from 'path';
+
+const DATABASE_URL = process.env.DATABASE_URL;
+if (!DATABASE_URL) {
+ console.error('DATABASE_URL not set. Export it from your three.ws env (Vercel/Neon URL).');
+ process.exit(2);
+}
+const sql = neon(DATABASE_URL);
+
+const RESULT_PATH = path.join(os.homedir(), '.claude', 'pump-deploy', 'launch-result.json');
+if (!fs.existsSync(RESULT_PATH)) {
+ console.error(`No launch-result.json at ${RESULT_PATH} — run pump-launch-usdc.mjs first.`);
+ process.exit(2);
+}
+const result = JSON.parse(fs.readFileSync(RESULT_PATH, 'utf8'));
+if (!result.ok) {
+ console.error(`Launch did not succeed (reason: ${result.reason}). Refusing to link.`);
+ process.exit(2);
+}
+
+const AGENT_ID = process.env.AGENT_ID || '';
+const NETWORK = process.env.NETWORK || 'mainnet';
+const BUYBACK_BPS = Number(process.env.BUYBACK_BPS || '0');
+
+async function main() {
+ console.log('Linking pump.fun mint to agent_identity');
+ console.log(' mint: ', result.mint);
+ console.log(' wallet: ', result.wallet);
+ console.log(' tx: ', result.tx_signature);
+ console.log('');
+
+ if (!AGENT_ID) {
+ console.log('AGENT_ID env var not set. Listing recent agent_identities so you can pick one:\n');
+ const rows = await sql`
+ select id, name, user_id, created_at
+ from agent_identities
+ where deleted_at is null
+ order by created_at desc
+ limit 20
+ `;
+ for (const r of rows) {
+ console.log(` ${r.id} ${r.name} (user ${r.user_id}) created ${r.created_at}`);
+ }
+ console.log('\nRe-run with: AGENT_ID=<id> node scripts/pump-link-mint.mjs');
+ process.exit(2);
+ }
+
+ // Verify the agent exists.
+ const [agent] = await sql`
+ select id, name, user_id from agent_identities
+ where id=${AGENT_ID} and deleted_at is null limit 1
+ `;
+ if (!agent) {
+ console.error(`agent_identities.id=${AGENT_ID} not found.`);
+ process.exit(3);
+ }
+ const userId = process.env.USER_ID || agent.user_id;
+ console.log(` agent: ${agent.id} "${agent.name}" (user ${userId})`);
+
+ // Insert into pump_agent_mints (idempotent on mint+network).
+ const inserted = await sql`
+ insert into pump_agent_mints
+ (agent_id, user_id, network, mint, name, symbol, metadata_uri, agent_authority, buyback_bps)
+ values
+ (${agent.id}, ${userId}, ${NETWORK}, ${result.mint},
+ ${result.coin_name}, ${result.coin_symbol}, ${result.uri},
+ ${result.wallet}, ${BUYBACK_BPS})
+ on conflict (mint, network) do update set
+ updated_at = now(),
+ name = excluded.name,
+ symbol = excluded.symbol,
+ metadata_uri = excluded.metadata_uri
+ returning id, created_at, updated_at
+ `;
+ const row = inserted[0];
+ console.log(` pump_agent_mints.id: ${row.id}`);
+ console.log(` created_at: ${row.created_at}`);
+ console.log(` updated_at: ${row.updated_at}`);
+
+ console.log('\nLinked.');
+ console.log(` /agent/${agent.id} should now show the coin.`);
+}
+
+main().catch((err) => { console.error(err); process.exit(1); });
diff --git a/trigger-bazaar.sh b/scripts/trigger-bazaar.sh
similarity index 100%
rename from trigger-bazaar.sh
rename to scripts/trigger-bazaar.sh