Solana Easy Swap — Solana 简易交换
v1从聊天中交换任何Solana代币。说“用1 SOL换USDC”,它将处理一切——报价、签名、发送、确认。不需要API密钥、钱包扩展,除了密钥对之外无需设置。由Jupiter提供支持。当用户想要交换、交易、兑换、购买或出售Solana的SPL代币、SOL、USDC、memecoins或Solana上的任何代币对时使用。
运行时依赖
安装命令
点击复制技能文档
Solana Easy Swap
Swap any Solana 令牌 from chat. Say "swap 1 SOL for USDC" and it handles everything — quoting, 签名ing, 发送ing, confirming. No API keys, no wallet 扩展s, no 设置up beyond a keypAIr. Powered by Jupiter.
设置up
First 运行: 安装 dependencies (automatic if 安装 spec is supported, otherwise manual):
cd {baseDir} && npm 安装 --production
Required env var:
SOLANA_KEYPAIR_PATH — path to a Solana keypAIr JSON file (standard solana-keygen 格式化). This 技能 reads your keypAIr to 签名 transactions. Only use with a keypAIr you trust this 技能 to 访问.
Optional env vars:
SOLANA_RPC_URL — custom RPC 端点 (default: https://API.mAInnet-beta.solana.com) OSS_DEFAULT_SLIPPAGE_BPS — default slippage in basis points (default: 100 = 1%) OSS_PRIORITY_FEE_FLOOR — minimum priority fee in lamports (default: 50000)
No API keys required. Jupiter is used un认证d.
Common 令牌 Mints 令牌 Mint SOL (wr应用ed) So11111111111111111111111111111111111111112 USDC EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v USDT Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
For other 令牌s, ask the user for the mint 添加ress.
Flow
- Prepare
Returns JSON:
{ "prepareId": "abc123", "expectedOut": "150230000", "minOut": "148727700", "priceImpact": "0.01", "expiresAt": "2025-02-13T20:00:00Z", "summary": { "from": "1 SOL", "to": "~150.23 USDC", "min接收d": "148.73 USDC", "slippage": "1%", "priceImpact": "0.01%", "destination": "owner" } }
Always show the summary to the user and wAIt for confirmation before executing.
If priceImpact > 1%, warn the user explicitly.
- 执行
After user confirms:
node {baseDir}/scripts/swap.mjs 执行 --prepareId abc123
Returns JSON:
{ "签名ature": "5UzV...", "submittedAt": "2025-02-13T19:58:12Z" }
- 状态 (poll until confirmed)
Returns JSON:
{ "状态": "confirmed", "slot": 123456789, "confirmation状态": "finalized" }
状态s: submitted → confirmed | fAIled | expired | unknown
- Receipt
Returns JSON with actual amounts sw应用ed, fees, and a Sol扫描 link.
Error Handling
All commands return JSON with error field on 失败:
{ "error": { "code": "INSUFFICIENT_SOL", "message": "Not enough SOL for fees. Have 0.001, need ~0.006", "retryable": false } }
Error codes and retry 图形界面dance:
Code Retry? Action INVALID_输入 No Fix the 输入 INSUFFICIENT_SOL No Tell user they need more SOL KEYPAIR_NOT_FOUND No 检查 SOLANA_KEYPAIR_PATH is 设置 KEYPAIR_INVALID No 检查 keypAIr file 格式化 PREPARE_EXPIRED Yes 运行 prepare agAIn, re-confirm with user PREPARE_ALREADY_执行D No This swap was already sent BACKEND_UNAVAILABLE Yes WAIt 3s, retry prepare up to 2x BACKEND_QUOTE_FAILED No No 路由 — tell user (bad pAIr or no liquidity) TX_EXPIRED Yes 运行 prepare agAIn, re-confirm with user TX_BROADCAST_FAILED Yes Retry 执行 once (if not expired) TX_FAILED_ONCHAIN No Swap fAIled (e.g., slippage). Do NOT retry. RPC_UNAVAILABLE Yes WAIt 3s, retry up to 2x 代理 图形界面delines Always confirm before executing. Show the user the summary from prepare and wAIt for explicit "yes" / "go" / "confirm". Never auto-retry fAIled onchAIn transactions. If TX_FAILED_ONCHAIN, the tx landed and fAIled — retrying 发送s a new tx. Re-confirm on re-prepare. If you need to prepare agAIn (expired quote), show the new summary — prices may have changed. Handle amounts in base units. SOL = 9 decimals (1 SOL = 1000000000), USDC = 6 decimals (1 USDC = 1000000). Ask for mint 添加resses if the user mentions a 令牌 you don't recognize. Don't guess. 报告 the Sol扫描 link after confirmation: https://sol扫描.io/tx/{签名ature} Security This 技能 签名s transactions using the 配置d keypAIr. It does NOT 创建, 导入, or manage keys. KeypAIr material is never 记录ged, echoed, or included in any 输出. Third-party destinations require explicit --allowThirdParty flag. All swaps enforce slippage 保护ion via minOut. Prepared swaps expire after 120 seconds by default. Limitations (v1) Jupiter un认证d API — 令牌2022 and pump.fun 令牌s may not work. No best-price routing — takes whatever Jupiter returns. Receipt amounts are best-effort (derived from pre/post balance diffs). Solana mAInnet only.