solana-agent-kit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Solana Agent Kit Development Guide

Solana Agent Kit 开发指南

Build AI agents that autonomously execute 60+ Solana blockchain operations using SendAI's open-source toolkit. Compatible with LangChain, Vercel AI SDK, and Claude via MCP.
使用SendAI的开源工具包构建可自主执行60余种Solana区块链操作的AI Agent。兼容LangChain、Vercel AI SDK以及通过MCP接入Claude。

Overview

概述

The Solana Agent Kit enables any AI model to:
  • Deploy and manage tokens (SPL & Token-2022)
  • Create and trade NFTs via Metaplex
  • Execute DeFi operations (Jupiter, Raydium, Orca, Meteora)
  • Stake SOL, bridge tokens, register domains
  • Run in interactive or fully autonomous modes
Solana Agent Kit支持任意AI模型实现以下功能:
  • 部署和管理代币(SPL及Token-2022标准)
  • 通过Metaplex创建和交易NFT
  • 执行DeFi操作(Jupiter、Raydium、Orca、Meteora)
  • 质押SOL、跨链桥接代币、注册域名
  • 支持交互式或完全自主运行模式

Key Features

核心特性

FeatureDescription
60+ ActionsToken, NFT, DeFi, staking, bridging operations
Plugin ArchitectureModular - use only what you need
Multi-FrameworkLangChain, Vercel AI SDK, MCP, Eliza
Model AgnosticWorks with OpenAI, Claude, Llama, Gemini
Autonomous ModeHands-off execution with error recovery
特性描述
60+操作代币、NFT、DeFi、质押、跨链桥接等各类操作
插件架构模块化设计 - 仅加载所需功能
多框架支持兼容LangChain、Vercel AI SDK、MCP、Eliza
模型无关支持OpenAI、Claude、Llama、Gemini等模型
自主模式无需人工干预的执行流程,附带错误恢复机制

Quick Start

快速开始

Installation

安装

bash
undefined
bash
undefined

Core package

核心包

npm install solana-agent-kit
npm install solana-agent-kit

With plugins (recommended)

带插件(推荐)

npm install solana-agent-kit
@solana-agent-kit/plugin-token
@solana-agent-kit/plugin-nft
@solana-agent-kit/plugin-defi
@solana-agent-kit/plugin-misc
@solana-agent-kit/plugin-blinks
undefined
npm install solana-agent-kit
@solana-agent-kit/plugin-token
@solana-agent-kit/plugin-nft
@solana-agent-kit/plugin-defi
@solana-agent-kit/plugin-misc
@solana-agent-kit/plugin-blinks
undefined

Environment Setup

环境配置

bash
undefined
bash
undefined

.env file

.env 文件

OPENAI_API_KEY=your_openai_api_key RPC_URL=https://api.mainnet-beta.solana.com # or devnet SOLANA_PRIVATE_KEY=your_base58_private_key
OPENAI_API_KEY=your_openai_api_key RPC_URL=https://api.mainnet-beta.solana.com # 或测试网devnet SOLANA_PRIVATE_KEY=your_base58_private_key

Optional API keys for enhanced features

可选API密钥,用于增强功能

COINGECKO_API_KEY=your_coingecko_key HELIUS_API_KEY=your_helius_key
undefined
COINGECKO_API_KEY=your_coingecko_key HELIUS_API_KEY=your_helius_key
undefined

Basic Agent Setup

基础Agent配置

typescript
import {
  SolanaAgentKit,
  createVercelAITools,
  KeypairWallet,
} from "solana-agent-kit";
import { Keypair } from "@solana/web3.js";
import bs58 from "bs58";

// Import plugins
import TokenPlugin from "@solana-agent-kit/plugin-token";
import NFTPlugin from "@solana-agent-kit/plugin-nft";
import DefiPlugin from "@solana-agent-kit/plugin-defi";
import MiscPlugin from "@solana-agent-kit/plugin-misc";
import BlinksPlugin from "@solana-agent-kit/plugin-blinks";

// Create wallet from private key
const privateKey = bs58.decode(process.env.SOLANA_PRIVATE_KEY!);
const keypair = Keypair.fromSecretKey(privateKey);
const wallet = new KeypairWallet(keypair);

// Initialize agent with plugins
const agent = new SolanaAgentKit(
  wallet,
  process.env.RPC_URL!,
  {
    OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
  }
)
  .use(TokenPlugin)
  .use(NFTPlugin)
  .use(DefiPlugin)
  .use(MiscPlugin)
  .use(BlinksPlugin);

// Create tools for AI framework
const tools = createVercelAITools(agent, agent.actions);
typescript
import {
  SolanaAgentKit,
  createVercelAITools,
  KeypairWallet,
} from "solana-agent-kit";
import { Keypair } from "@solana/web3.js";
import bs58 from "bs58";

// 导入插件
import TokenPlugin from "@solana-agent-kit/plugin-token";
import NFTPlugin from "@solana-agent-kit/plugin-nft";
import DefiPlugin from "@solana-agent-kit/plugin-defi";
import MiscPlugin from "@solana-agent-kit/plugin-misc";
import BlinksPlugin from "@solana-agent-kit/plugin-blinks";

// 从私钥创建钱包
const privateKey = bs58.decode(process.env.SOLANA_PRIVATE_KEY!);
const keypair = Keypair.fromSecretKey(privateKey);
const wallet = new KeypairWallet(keypair);

// 初始化Agent并加载插件
const agent = new SolanaAgentKit(
  wallet,
  process.env.RPC_URL!,
  {
    OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
  }
)
  .use(TokenPlugin)
  .use(NFTPlugin)
  .use(DefiPlugin)
  .use(MiscPlugin)
  .use(BlinksPlugin);

// 为AI框架创建工具
const tools = createVercelAITools(agent, agent.actions);

Plugins & Actions

插件与操作

Token Plugin (
@solana-agent-kit/plugin-token
)

代币插件(
@solana-agent-kit/plugin-token

ActionDescription
deployToken
Deploy new SPL token or Token-2022
transfer
Transfer SOL or SPL tokens
getBalance
Check token balances
stake
Stake SOL via Jupiter/Solayer
bridge
Bridge tokens via Wormhole
rugCheck
Analyze token safety
typescript
// Deploy a new token
const result = await agent.methods.deployToken({
  name: "My Token",
  symbol: "MTK",
  decimals: 9,
  initialSupply: 1000000,
});

// Transfer tokens
await agent.methods.transfer({
  to: "recipient_address",
  amount: 100,
  mint: "token_mint_address", // optional, defaults to SOL
});

// Check balance
const balance = await agent.methods.getBalance({
  tokenAddress: "token_mint_address", // optional
});
操作描述
deployToken
部署新的SPL代币或Token-2022代币
transfer
转账SOL或SPL代币
getBalance
查询代币余额
stake
通过Jupiter/Solayer质押SOL
bridge
通过Wormhole跨链桥接代币
rugCheck
分析代币安全性
typescript
// 部署新代币
const result = await agent.methods.deployToken({
  name: "My Token",
  symbol: "MTK",
  decimals: 9,
  initialSupply: 1000000,
});

// 转账代币
await agent.methods.transfer({
  to: "recipient_address",
  amount: 100,
  mint: "token_mint_address", // 可选,默认是SOL
});

// 查询余额
const balance = await agent.methods.getBalance({
  tokenAddress: "token_mint_address", // 可选
});

NFT Plugin (
@solana-agent-kit/plugin-nft
)

NFT插件(
@solana-agent-kit/plugin-nft

ActionDescription
createCollection
Create NFT collection via Metaplex
mintNFT
Mint NFT to collection
listNFT
List NFT on marketplaces
updateMetadata
Update NFT metadata
typescript
// Create collection
const collection = await agent.methods.createCollection({
  name: "My Collection",
  symbol: "MYCOL",
  uri: "https://arweave.net/metadata.json",
});

// Mint NFT to collection
const nft = await agent.methods.mintNFT({
  collectionMint: collection.collectionAddress,
  name: "NFT #1",
  uri: "https://arweave.net/nft1.json",
});
操作描述
createCollection
通过Metaplex创建NFT合集
mintNFT
向合集中铸造NFT
listNFT
在NFT市场上架NFT
updateMetadata
更新NFT元数据
typescript
// 创建合集
const collection = await agent.methods.createCollection({
  name: "My Collection",
  symbol: "MYCOL",
  uri: "https://arweave.net/metadata.json",
});

// 向合集中铸造NFT
const nft = await agent.methods.mintNFT({
  collectionMint: collection.collectionAddress,
  name: "NFT #1",
  uri: "https://arweave.net/nft1.json",
});

DeFi Plugin (
@solana-agent-kit/plugin-defi
)

DeFi插件(
@solana-agent-kit/plugin-defi

ActionDescription
trade
Swap tokens via Jupiter
createRaydiumPool
Create Raydium AMM pool
createOrcaPool
Create Orca Whirlpool
createMeteoraPool
Create Meteora DLMM pool
limitOrder
Place limit order via Manifest
lend
Lend assets via Lulo
perpetualTrade
Trade perps via Adrena/Drift
typescript
// Swap tokens via Jupiter
const swap = await agent.methods.trade({
  outputMint: "target_token_mint",
  inputAmount: 1.0,
  inputMint: "So11111111111111111111111111111111111111112", // SOL
  slippageBps: 50, // 0.5%
});

// Create Raydium CPMM pool
const pool = await agent.methods.createRaydiumCpmm({
  mintA: "token_a_mint",
  mintB: "token_b_mint",
  configId: "config_id",
  mintAAmount: 1000,
  mintBAmount: 1000,
});
操作描述
trade
通过Jupiter交换代币
createRaydiumPool
创建Raydium AMM池
createOrcaPool
创建Orca Whirlpool
createMeteoraPool
创建Meteora DLMM池
limitOrder
通过Manifest挂限价单
lend
通过Lulo出借资产
perpetualTrade
通过Adrena/Drift交易永续合约
typescript
// 通过Jupiter交换代币
const swap = await agent.methods.trade({
  outputMint: "target_token_mint",
  inputAmount: 1.0,
  inputMint: "So11111111111111111111111111111111111111112", // SOL
  slippageBps: 50, // 0.5%
});

// 创建Raydium CPMM池
const pool = await agent.methods.createRaydiumCpmm({
  mintA: "token_a_mint",
  mintB: "token_b_mint",
  configId: "config_id",
  mintAAmount: 1000,
  mintBAmount: 1000,
});

Misc Plugin (
@solana-agent-kit/plugin-misc
)

杂项插件(
@solana-agent-kit/plugin-misc

ActionDescription
airdrop
ZK-compressed airdrop via Helius
getPrice
Get token price via CoinGecko
registerDomain
Register .sol domain
resolveDomain
Resolve domain to address
getTPS
Get network TPS
typescript
// Compressed airdrop (cost-efficient)
const airdrop = await agent.methods.sendCompressedAirdrop({
  mintAddress: "token_mint",
  amount: 100,
  recipients: ["addr1", "addr2", "addr3"],
  priorityFeeInLamports: 10000,
});

// Get token price
const price = await agent.methods.getPrice({
  tokenId: "solana", // CoinGecko ID
});
操作描述
airdrop
通过Helius实现ZK压缩空投
getPrice
通过CoinGecko获取代币价格
registerDomain
注册.sol域名
resolveDomain
将域名解析为地址
getTPS
获取网络TPS
typescript
// 压缩空投(成本更低)
const airdrop = await agent.methods.sendCompressedAirdrop({
  mintAddress: "token_mint",
  amount: 100,
  recipients: ["addr1", "addr2", "addr3"],
  priorityFeeInLamports: 10000,
});

// 获取代币价格
const price = await agent.methods.getPrice({
  tokenId: "solana", // CoinGecko ID
});

Blinks Plugin (
@solana-agent-kit/plugin-blinks
)

Blinks插件(
@solana-agent-kit/plugin-blinks

Execute Solana Actions/Blinks directly:
typescript
// Execute a Blink
const result = await agent.methods.executeBlink({
  blinkUrl: "https://example.com/blink",
  params: { /* blink-specific params */ },
});
直接执行Solana Actions/Blinks:
typescript
// 执行Blink
const result = await agent.methods.executeBlink({
  blinkUrl: "https://example.com/blink",
  params: { /* blink专属参数 */ },
});

Integration Patterns

集成模式

LangChain Integration

LangChain集成

typescript
import { SolanaAgentKit, createSolanaTools } from "solana-agent-kit";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { MemorySaver } from "@langchain/langgraph";
import { HumanMessage } from "@langchain/core/messages";

async function createLangChainAgent() {
  // Initialize LLM
  const llm = new ChatOpenAI({
    modelName: "gpt-4-turbo-preview",
    temperature: 0.7,
  });

  // Initialize Solana Agent Kit
  const solanaKit = new SolanaAgentKit(
    wallet,
    process.env.RPC_URL!,
    { OPENAI_API_KEY: process.env.OPENAI_API_KEY! }
  )
    .use(TokenPlugin)
    .use(DefiPlugin);

  // Create LangChain tools
  const tools = createSolanaTools(solanaKit);

  // Create agent with memory
  const memory = new MemorySaver();
  const agent = createReactAgent({
    llm,
    tools,
    checkpointSaver: memory,
  });

  return agent;
}

// Run agent
async function chat(agent: any, message: string) {
  const config = { configurable: { thread_id: "solana-agent" } };

  const stream = await agent.stream(
    { messages: [new HumanMessage(message)] },
    config
  );

  for await (const chunk of stream) {
    if ("agent" in chunk) {
      console.log(chunk.agent.messages[0].content);
    }
  }
}
typescript
import { SolanaAgentKit, createSolanaTools } from "solana-agent-kit";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { MemorySaver } from "@langchain/langgraph";
import { HumanMessage } from "@langchain/core/messages";

async function createLangChainAgent() {
  // 初始化大语言模型
  const llm = new ChatOpenAI({
    modelName: "gpt-4-turbo-preview",
    temperature: 0.7,
  });

  // 初始化Solana Agent Kit
  const solanaKit = new SolanaAgentKit(
    wallet,
    process.env.RPC_URL!,
    { OPENAI_API_KEY: process.env.OPENAI_API_KEY! }
  )
    .use(TokenPlugin)
    .use(DefiPlugin);

  // 创建LangChain工具
  const tools = createSolanaTools(solanaKit);

  // 创建带记忆功能的Agent
  const memory = new MemorySaver();
  const agent = createReactAgent({
    llm,
    tools,
    checkpointSaver: memory,
  });

  return agent;
}

// 运行Agent
async function chat(agent: any, message: string) {
  const config = { configurable: { thread_id: "solana-agent" } };

  const stream = await agent.stream(
    { messages: [new HumanMessage(message)] },
    config
  );

  for await (const chunk of stream) {
    if ("agent" in chunk) {
      console.log(chunk.agent.messages[0].content);
    }
  }
}

Vercel AI SDK Integration

Vercel AI SDK集成

typescript
import { SolanaAgentKit, createVercelAITools } from "solana-agent-kit";
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";

async function runVercelAgent(prompt: string) {
  const agent = new SolanaAgentKit(wallet, rpcUrl, options)
    .use(TokenPlugin)
    .use(DefiPlugin);

  const tools = createVercelAITools(agent, agent.actions);

  const result = await generateText({
    model: openai("gpt-4-turbo"),
    tools,
    maxSteps: 10,
    prompt,
  });

  return result.text;
}

// Usage
const response = await runVercelAgent(
  "Swap 0.1 SOL for USDC using the best rate"
);
typescript
import { SolanaAgentKit, createVercelAITools } from "solana-agent-kit";
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";

async function runVercelAgent(prompt: string) {
  const agent = new SolanaAgentKit(wallet, rpcUrl, options)
    .use(TokenPlugin)
    .use(DefiPlugin);

  const tools = createVercelAITools(agent, agent.actions);

  const result = await generateText({
    model: openai("gpt-4-turbo"),
    tools,
    maxSteps: 10,
    prompt,
  });

  return result.text;
}

// 使用示例
const response = await runVercelAgent(
  "用最优汇率将0.1 SOL兑换为USDC"
);

MCP Server for Claude

用于Claude的MCP服务器

Install and configure the MCP server for Claude Desktop:
bash
undefined
为Claude Desktop安装并配置MCP服务器:
bash
undefined

Install globally

全局安装

npm install -g solana-mcp
npm install -g solana-mcp

Or run directly

或直接运行

npx solana-mcp

Add to Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "solana": {
      "command": "npx",
      "args": ["solana-mcp"],
      "env": {
        "RPC_URL": "https://api.mainnet-beta.solana.com",
        "SOLANA_PRIVATE_KEY": "your_base58_private_key",
        "OPENAI_API_KEY": "your_openai_key"
      }
    }
  }
}
Available MCP tools:
  • GET_ASSET
    - Get token/asset info
  • DEPLOY_TOKEN
    - Create new token
  • GET_PRICE
    - Fetch token price
  • WALLET_ADDRESS
    - Get wallet address
  • BALANCE
    - Check balance
  • TRANSFER
    - Send tokens
  • MINT_NFT
    - Create NFT
  • TRADE
    - Execute swap
  • REQUEST_FUNDS
    - Get devnet SOL
  • RESOLVE_DOMAIN
    - Lookup .sol domain
  • GET_TPS
    - Network throughput
npx solana-mcp

添加到Claude Desktop配置文件(`~/Library/Application Support/Claude/claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "solana": {
      "command": "npx",
      "args": ["solana-mcp"],
      "env": {
        "RPC_URL": "https://api.mainnet-beta.solana.com",
        "SOLANA_PRIVATE_KEY": "your_base58_private_key",
        "OPENAI_API_KEY": "your_openai_key"
      }
    }
  }
}
可用的MCP工具:
  • GET_ASSET
    - 获取代币/资产信息
  • DEPLOY_TOKEN
    - 创建新代币
  • GET_PRICE
    - 获取代币价格
  • WALLET_ADDRESS
    - 获取钱包地址
  • BALANCE
    - 查询余额
  • TRANSFER
    - 发送代币
  • MINT_NFT
    - 创建NFT
  • TRADE
    - 执行代币交换
  • REQUEST_FUNDS
    - 获取测试网SOL
  • RESOLVE_DOMAIN
    - 查找.sol域名
  • GET_TPS
    - 获取网络吞吐量

Autonomous Mode

自主模式

Run agent in fully autonomous mode:
typescript
import { SolanaAgentKit } from "solana-agent-kit";

const agent = new SolanaAgentKit(wallet, rpcUrl, options)
  .use(TokenPlugin)
  .use(DefiPlugin);

// Configure autonomous behavior
const autonomousConfig = {
  intervalMs: 60000,        // Check every minute
  maxActions: 100,          // Max actions per session
  errorRecovery: true,      // Auto-retry on failures
  dryRun: false,            // Set true for testing
};

// Start autonomous loop
async function runAutonomous() {
  while (true) {
    try {
      // Agent decides what to do based on market conditions
      const decision = await agent.analyze({
        context: "Monitor my portfolio and rebalance if needed",
        constraints: [
          "Keep at least 1 SOL for gas",
          "Max 10% allocation per token",
        ],
      });

      if (decision.shouldAct) {
        await agent.execute(decision.action);
      }

      await sleep(autonomousConfig.intervalMs);
    } catch (error) {
      if (autonomousConfig.errorRecovery) {
        console.error("Error, recovering:", error);
        await sleep(5000);
      } else {
        throw error;
      }
    }
  }
}
以完全自主模式运行Agent:
typescript
import { SolanaAgentKit } from "solana-agent-kit";

const agent = new SolanaAgentKit(wallet, rpcUrl, options)
  .use(TokenPlugin)
  .use(DefiPlugin);

// 配置自主行为
const autonomousConfig = {
  intervalMs: 60000,        // 每分钟检查一次
  maxActions: 100,          // 每次会话最多执行100个操作
  errorRecovery: true,      // 失败时自动重试
  dryRun: false,            // 测试时设为true
};

// 启动自主循环
async function runAutonomous() {
  while (true) {
    try {
      // Agent根据市场状况决定执行操作
      const decision = await agent.analyze({
        context: "监控我的投资组合,必要时进行再平衡",
        constraints: [
          "保留至少1 SOL作为手续费",
          "单一代币最大配置比例不超过10%",
        ],
      });

      if (decision.shouldAct) {
        await agent.execute(decision.action);
      }

      await sleep(autonomousConfig.intervalMs);
    } catch (error) {
      if (autonomousConfig.errorRecovery) {
        console.error("发生错误,正在恢复:", error);
        await sleep(5000);
      } else {
        throw error;
      }
    }
  }
}

Creating Custom Actions

创建自定义操作

Extend the agent with custom actions:
typescript
import { Action, Tool, SolanaAgentKit } from "solana-agent-kit";

// Define the Tool (tells LLM HOW to use it)
const myCustomTool: Tool = {
  name: "my_custom_action",
  description: "Does something custom on Solana",
  parameters: {
    type: "object",
    properties: {
      param1: {
        type: "string",
        description: "First parameter",
      },
      param2: {
        type: "number",
        description: "Second parameter",
      },
    },
    required: ["param1"],
  },
};

// Define the Action (tells agent WHEN and WHY to use it)
const myCustomAction: Action = {
  name: "my_custom_action",
  description: "Use this when you need to do something custom",
  similes: ["custom thing", "special operation"],
  examples: [
    {
      input: "Do the custom thing with value X",
      output: "Custom action executed with param1=X",
    },
  ],
  handler: async (agent: SolanaAgentKit, params: any) => {
    const { param1, param2 } = params;

    // Your custom logic here
    const connection = agent.connection;
    const wallet = agent.wallet;

    // Execute Solana operations...

    return {
      success: true,
      result: `Executed with ${param1}`,
    };
  },
};

// Register custom action
agent.registerAction(myCustomAction);
agent.registerTool(myCustomTool);
通过自定义操作扩展Agent功能:
typescript
import { Action, Tool, SolanaAgentKit } from "solana-agent-kit";

// 定义工具(告诉大语言模型如何使用)
const myCustomTool: Tool = {
  name: "my_custom_action",
  description: "在Solana上执行自定义操作",
  parameters: {
    type: "object",
    properties: {
      param1: {
        type: "string",
        description: "第一个参数",
      },
      param2: {
        type: "number",
        description: "第二个参数",
      },
    },
    required: ["param1"],
  },
};

// 定义操作(告诉Agent何时及为何使用)
const myCustomAction: Action = {
  name: "my_custom_action",
  description: "当你需要执行自定义操作时使用",
  similes: ["custom thing", "special operation"],
  examples: [
    {
      input: "用值X执行自定义操作",
      output: "已执行自定义操作,param1=X",
    },
  ],
  handler: async (agent: SolanaAgentKit, params: any) => {
    const { param1, param2 } = params;

    // 你的自定义逻辑
    const connection = agent.connection;
    const wallet = agent.wallet;

    // 执行Solana操作...

    return {
      success: true,
      result: `已执行,参数为${param1}`,
    };
  },
};

// 注册自定义操作
agent.registerAction(myCustomAction);
agent.registerTool(myCustomTool);

Best Practices

最佳实践

Security

安全

  1. Never expose private keys - Use environment variables
  2. Use dedicated wallets - Separate agent wallet from main funds
  3. Set spending limits - Implement max transaction amounts
  4. Test on devnet first - Always test before mainnet
  5. Audit agent actions - Log all operations
  1. 绝不暴露私钥 - 使用环境变量存储
  2. 使用专用钱包 - 将Agent钱包与主资金钱包分离
  3. 设置支出限额 - 实现最大交易金额限制
  4. 先在测试网测试 - 上线主网前务必测试
  5. 审计Agent操作 - 记录所有操作

Performance

性能

  1. Use appropriate RPC - Helius, Triton for production
  2. Batch operations - Combine related transactions
  3. Handle rate limits - Implement backoff strategies
  4. Cache when possible - Price feeds, token metadata
  1. 使用合适的RPC - 生产环境使用Helius、Triton
  2. 批量操作 - 合并相关交易
  3. 处理速率限制 - 实现退避策略
  4. 尽可能缓存 - 价格馈送、代币元数据

Agent Design

Agent设计

  1. Limit plugin scope - Only load needed plugins (reduces hallucinations)
  2. Provide clear context - Detailed prompts improve accuracy
  3. Add constraints - Prevent unwanted actions
  4. Monitor and iterate - Review agent decisions
  1. 限制插件范围 - 仅加载所需插件(减少幻觉)
  2. 提供清晰上下文 - 详细的提示词提升准确性
  3. 添加约束条件 - 防止不必要的操作
  4. 监控并迭代 - 审核Agent的决策

Guidelines

指南

  • Always test on devnet before mainnet
  • Set maximum transaction limits
  • Monitor agent activity logs
  • Use dedicated wallets for agents
  • Implement proper error handling
  • Keep private keys secure
  • 上线主网前务必在测试网测试
  • 设置最大交易限额
  • 监控Agent活动日志
  • 为Agent使用专用钱包
  • 实现完善的错误处理
  • 安全存储私钥

Files in This Skill

本技能包含的文件

solana-agent-kit/
├── SKILL.md                           # This file
├── resources/
│   ├── actions-reference.md           # Complete actions list
│   ├── plugins-guide.md               # Plugin deep dive
│   └── security-checklist.md          # Security best practices
├── examples/
│   ├── langchain/                     # LangChain integration
│   ├── vercel-ai/                     # Vercel AI SDK
│   ├── mcp-server/                    # Claude MCP setup
│   └── autonomous-agent/              # Autonomous patterns
├── templates/
│   └── agent-template.ts              # Starter template
└── docs/
    ├── custom-actions.md              # Creating custom actions
    └── troubleshooting.md             # Common issues
solana-agent-kit/
├── SKILL.md                           # 本文档
├── resources/
│   ├── actions-reference.md           # 完整操作列表
│   ├── plugins-guide.md               # 插件深度指南
│   └── security-checklist.md          # 安全最佳实践
├── examples/
│   ├── langchain/                     # LangChain集成示例
│   ├── vercel-ai/                     # Vercel AI SDK示例
│   ├── mcp-server/                    # Claude MCP配置示例
│   └── autonomous-agent/              # 自主Agent模式示例
├── templates/
│   └── agent-template.ts              # 入门模板
└── docs/
    ├── custom-actions.md              # 创建自定义操作指南
    └── troubleshooting.md             # 常见问题排查

V2 Highlights

V2 亮点

Version 2 represents a complete evolution of the toolkit with key improvements:
版本2是工具包的全面升级,带来以下关键改进:

Plugin Architecture

插件架构

V2 directly addresses two major V1 challenges:
  1. Security: Input private key method wasn't 100% secure
  2. Hallucinations: 100+ aggregate tools caused LLM confusion
The modular plugin system lets you install only what you need, reducing context bloat and hallucinations.
V2直接解决了V1的两大痛点:
  1. 安全性:输入私钥的方式并非100%安全
  2. 幻觉问题:100+聚合工具导致大语言模型混淆
模块化插件系统允许你仅安装所需功能,减少上下文冗余和幻觉问题。

Embedded Wallet Support (New)

嵌入式钱包支持(新增)

V2 integrates with secure wallet providers for enhanced security:
typescript
import { TurnkeyWallet, PrivyWallet } from "solana-agent-kit/wallets";

// Turnkey - fine-grained rules and policies
const turnkeyWallet = new TurnkeyWallet({
  organizationId: process.env.TURNKEY_ORG_ID,
  privateKeyId: process.env.TURNKEY_PRIVATE_KEY_ID,
});

// Privy - human-in-the-loop confirmation
const privyWallet = new PrivyWallet({
  appId: process.env.PRIVY_APP_ID,
  requireConfirmation: true,
});

// Initialize agent with secure wallet
const agent = new SolanaAgentKit(turnkeyWallet, rpcUrl, options)
  .use(TokenPlugin)
  .use(DefiPlugin);
V2集成了安全钱包提供商,提升安全性:
typescript
import { TurnkeyWallet, PrivyWallet } from "solana-agent-kit/wallets";

// Turnkey - 细粒度规则和策略
const turnkeyWallet = new TurnkeyWallet({
  organizationId: process.env.TURNKEY_ORG_ID,
  privateKeyId: process.env.TURNKEY_PRIVATE_KEY_ID,
});

// Privy - 人工确认机制
const privyWallet = new PrivyWallet({
  appId: process.env.PRIVY_APP_ID,
  requireConfirmation: true,
});

// 使用安全钱包初始化Agent
const agent = new SolanaAgentKit(turnkeyWallet, rpcUrl, options)
  .use(TokenPlugin)
  .use(DefiPlugin);

Key V2 Benefits

V2核心优势

FeatureV1V2
Wallet SecurityPrivate key inputEmbedded wallets (Turnkey, Privy)
Tool LoadingAll 100+ toolsPlugin-based, load what you need
LLM ContextLarge, caused hallucinationsMinimal, focused context
Human-in-loopNot supportedNative with Privy
特性V1V2
钱包安全性输入私钥嵌入式钱包(Turnkey、Privy)
工具加载全部100+工具基于插件,仅加载所需
大语言模型上下文庞大,易导致幻觉精简,聚焦核心
人工介入机制不支持原生支持Privy

Notes

说明

  • Solana Agent Kit is actively maintained (1,400+ commits, 800+ forks)
  • V2 introduced plugin architecture (migration guide available)
  • Python version available:
    solana-agent-kit-py
  • MCP server enables Claude Desktop integration
  • 100,000+ downloads, 1.6k+ GitHub stars
  • Apache-2.0 licensed
  • Solana Agent Kit 处于活跃维护状态(1400+次提交,800+个分支)
  • V2引入插件架构(提供迁移指南)
  • 提供Python版本:
    solana-agent-kit-py
  • MCP服务器支持Claude Desktop集成
  • 下载量超10万次,GitHub星标1.6k+
  • 采用Apache-2.0许可证