swap
FreeRuns bundled scriptsNot checkedBuy and sell tokens on pump.fun bonding curve and pump swap AMM pool, and query SOL/token balances. Prefer runnable Node scripts in this skill folder; use…
by nirholas★ 289 GitHub starsAbout this skill
Before Starting Work Critical - Ask these from user
MANDATORY — Do NOT write or modify any code until every item below is answered by the user:
- RPC URL provided or a fallback agreed upon (for any on-chain or tx-building step)
- Signer wallet public key (fee payer / user)
- Framework confirmed (Next.js, Express, CLI scripts only, other)
- Operation type confirmed (buy or sell)
- Coin mint address provided
- Amount confirmed (SOL lamports for buy; token smallest units for sell)
- Front-runner protection desired? If yes, confirm tip amount (default 0.0001 SOL). Transactions will be sent only to Jito block engine endpoints.
You MUST ask the user for ALL unchecked items in your very first response. Do not assume defaults. Do not proceed until the user has explicitly answered each one.
API (preferred) — https://fun-block.pump.fun
Use the API to build swap transactions instead of running scripts directly. The API automatically determines coin state (bonding curve vs AMM) and builds the correct transaction.
POST /agents/swap
Builds a buy or sell transaction. Set inputMint to So11111111111111111111111111111111111111112 (NATIVE_MINT) for buys, or set outputMint to NATIVE_MINT for sells.
Request body:
{
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "<TOKEN_MINT>",
"amount": "1000000",
"user": "<PUBKEY>",
"slippagePct": 2,
"feePayer": "<PUBKEY>",
"frontRunningProtection": false,
"tipAmount": 0,
"encoding": "base64"
}
Only inputMint, outputMint, amount, and user are required. All other fields have defaults.
tipAmountis a Jito tip in SOL (e.g.0.0001for 100,000 lamports). Only relevant whenfrontRunningProtectionistrue.
Encoding: The API defaults to
"base58"encoding. Always pass"encoding": "base64"in the request body — scripts already output base64. When sending the signed transaction to an RPC or Jito endpoint, the encoding used to serialize the transaction must match theencodingparameter passed in the send call. Mismatched encodings will cause transaction failures. Always explicitly passencoding: "base64"insendTransaction/simulateTransactionRPC calls — never rely on the RPC's default.
- Buy:
inputMint= NATIVE_MINT,outputMint= token mint,amount= SOL in lamports - Sell:
inputMint= token mint,outputMint= NATIVE_MINT,amount= token amount (6 decimals)
Response:
{
"transaction": "<base64-encoded VersionedTransaction>",
"pumpMintInfo": { "hasGraduated": false, "expectedOutAmount": "123456", "..." : "..." }
}
Deserialize the transaction, have the user wallet sign, and submit to chain.
Runnable examples (Node scripts — only when user explicitly requests)
Use {baseDir} as the path to this skill folder (OpenClaw and Agent Skills clients often expose this placeholder).
cd {baseDir}
npm install
export SOLANA_RPC_URL=https://rpc.solanatracker.io/public
| Operation | Script | Example |
|---|---|---|
| Fetch coin state (HTTP) | scripts/fetch-coin.mjs |
node scripts/fetch-coin.mjs --mint <MINT> --subset |
| Buy (bonding curve) | scripts/build-buy-bonding-tx.mjs |
node scripts/build-buy-bonding-tx.mjs --mint <MINT> --user <PUBKEY> --amount 1000000 |
| Sell (bonding curve) | scripts/build-sell-bonding-tx.mjs |
node scripts/build-sell-bonding-tx.mjs --mint <MINT> --user <PUBKEY> --amount 1000000 |
| Buy (AMM) | scripts/build-buy-amm-tx.mjs |
node scripts/build-buy-amm-tx.mjs --mint <MINT> --user <PUBKEY> --amount 1000000 |
| Sell (AMM) | scripts/build-sell-amm-tx.mjs |
node scripts/build-sell-amm-tx.mjs --mint <MINT> --user <PUBKEY> --amount 1000000 |
| Balances | scripts/print-balances.mjs |
node scripts/print-balances.mjs --wallet <PUBKEY> --mint <MINT> |
- Run any script with
--helpfor full flags (--slippage,--compute-units,--priority-micro-lamports,--front-runner-protection,--tip-sol,--poolvs--mintfor AMM, etc.). - Tx builders print one JSON object on stdout with
transaction(base64-encoded VersionedTransaction). Never pass end-user private keys into these scripts. - OpenClaw: If YAML
metadataever fails to parse, collapsemetadatato a single-line JSON object per OpenClaw skills; optionalmetadata.openclaw.requires.env: ["SOLANA_RPC_URL"]can gate load-time eligibility.
Safety Rules
- NEVER log, print, or return private keys or secret key material.
- NEVER sign transactions on behalf of a user — scripts build txs; the user (or their wallet) co-signs and sends.
- Always validate that amounts are
> 0before building instructions. - Use the correct decimal precision: 9 decimals for SOL (1 SOL = 1,000,000,000 lamports), 6 decimals for pump tokens.
- Always check the coin state (bonding curve vs AMM pool) before
Install swap in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the swap skill do?
Buy and sell tokens on pump.fun bonding curve and pump swap AMM pool, and query SOL/token balances. Prefer runnable Node scripts in this skill folder; use @pump-fun/pump-sdk and @pump-fun/pump-swap-sdk for custom integrations.
How do I install the swap skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the swap skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic