An open-source toolkit for connecting AI agents to Solana protocols. Now, any agent, using any model can autonomously perform 60+ Solana actions:
Anyone - whether an SF-based AI researcher or a crypto-native builder - can bring their AI agents trained with any model and seamlessly integrate with Solana.
Replit template created by Arpit Singh
Token Operations
NFTs on 3.Land
NFT Management via Metaplex
DeFi Integration
Solana Blinks
Non-Financial Actions
Market Data Integration
LangChain Integration
Vercel AI SDK Integration
Autonomous Modes
AI Tools
You can view the full documentation of the kit at docs.sendai.fun
npm install solana-agent-kit
import { SolanaAgentKit, createSolanaTools } from "solana-agent-kit";
// Initialize with private key and optional RPC URL
const agent = new SolanaAgentKit(
"your-wallet-private-key-as-base58",
"https://api.mainnet-beta.solana.com",
"your-openai-api-key"
);
// Create LangChain tools
const tools = createSolanaTools(agent);
const result = await agent.deployToken(
"my ai token", // name
"uri", // uri
"token", // symbol
9, // decimals
{
mintAuthority: null, // by default, deployer account
freezeAuthority: null, // by default, deployer account
updateAuthority: undefined, // by default, deployer account
isMutable: false // by default, true
},
1000000 // initial supply
);
console.log("Token Mint Address:", result.mint.toString());
const chains = await agent.getWormholeSupportedChains();
console.log("Supported Chains:", chains);
const result = await agent.createWrappedToken({
destinationChain: "BaseSepolia", // Target chain
tokenAddress: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", // Original token address
network: "Testnet", // Network type (Testnet or Mainnet)
});
console.log("Wrapped Token Result:", result);
Note: When using Wormhole for cross-chain operations:
const transfer = await agent.cctpTransfer({
destinationChain: "Base Sepolia", // Target chain
transferAmount: "1", // Amount to transfer
network: "Testnet", // Network type (Testnet or Mainnet)
});
console.log("Transfer result:", transfer);
const transfer = await agent.tokenTransfer({
destinationChain: "Base Sepolia", // Target chain
tokenAddress: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", // Original token address or leave it empty to treansfer Native SOL
network: "Testnet", // Network type (Testnet or Mainnet)
});
const isDevnet = false; // (Optional) if not present TX takes place in Mainnet
const priorityFeeParam = 1000000; // (Optional) if not present the default priority fee will be 50000
const collectionOpts: CreateCollectionOptions = {
collectionName: "",
collectionSymbol: "",
collectionDescription: "",
mainImageUrl: ""
};
const result = await agent.create3LandCollection(
collectionOpts,
isDevnet, // (Optional) if not present TX takes place in Mainnet
priorityFeeParam, //(Optional)
);
When creating an NFT using 3Land's tool, it automatically goes for sale on 3.land website
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
const withPool = true; // (Optional) only present if NFT will be created with a Liquidity Pool for a specific SPL token
const priorityFeeParam = 1000000; // (Optional) if not present the default priority fee will be 50000
const collectionAccount = ""; //hash for the collection
const createItemOptions: CreateSingleOptions = {
itemName: "",
sellerFee: 500, //5%
itemAmount: 100, //total items to be created
itemSymbol: "",
itemDescription: "",
traits: [
{ trait_type: "", value: "" },
],
price: 0, //100000000 == 0.1 sol, can be set to 0 for a free mint
splHash: "", //present if listing is on a specific SPL token, if not present sale will be on $SOL, must be present if "withPool" is true
poolName: "", // Only present if "withPool" is true
mainImageUrl: "",
};
const result = await agent.create3LandNft(
collectionAccount,
createItemOptions,
isDevnet, // (Optional) if not present TX takes place in Mainnet
withPool
priorityFeeParam, //(Optional)
);
const collection = await agent.deployCollection({
name: "My NFT Collection",
uri: "https://arweave.net/metadata.json",
royaltyBasisPoints: 500, // 5%
creators: [
{
address: "creator-wallet-address",
percentage: 100,
},
],
});
import { PublicKey } from "@solana/web3.js";
const signature = await agent.trade(
new PublicKey("target-token-mint"),
100, // amount
new PublicKey("source-token-mint"),
300 // 3% slippage
);
import { PublicKey } from "@solana/web3.js";
const signature = await agent.lendAssets(
100 // amount of USDC to lend
);
const signature = await agent.stake(
1 // amount in SOL to stake
);
const signature = await agent.restake(
1 // amount in SOL to stake
);
import { PublicKey } from "@solana/web3.js";
(async () => {
console.log(
"~Airdrop cost estimate:",
getAirdropCostEstimate(
1000, // recipients
30_000 // priority fee in lamports
)
);
const signature = await agent.sendCompressedAirdrop(
new PublicKey("JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"), // mint
42, // amount per recipient
[
new PublicKey("1nc1nerator11111111111111111111111111111111"),
// ... add more recipients
],
30_000 // priority fee in lamports
);
})();
const priceFeedID = await agent.getPythPriceFeedID("SOL");
const price = await agent.getPythPrice(priceFeedID);
console.log("Price of SOL/USD:", price);
import { PublicKey } from "@solana/web3.js";
const signature = await agent.openPerpTradeLong({
price: 300, // $300 SOL Max price
collateralAmount: 10, // 10 jitoSOL in
collateralMint: new PublicKey("J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn"), // jitoSOL
leverage: 50000, // x5
tradeMint: new PublicKey("J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn"), // jitoSOL
slippage: 0.3, // 0.3%
});
import { PublicKey } from "@solana/web3.js";
const signature = await agent.closePerpTradeLong({
price: 200, // $200 SOL price
tradeMint: new PublicKey("J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn"), // jitoSOL
});
const { signature } = await agent.closeEmptyTokenAccounts();
Create a drift account with an initial token deposit.
const result = await agent.createDriftUserAccount()
Create a drift vault.
const signature = await agent.createDriftVault({
name: "my-drift-vault",
marketName: "USDC-SPOT",
redeemPeriod: 1, // in days
maxTokens: 100000, // in token units e.g 100000 USDC
minDepositAmount: 5, // in token units e.g 5 USDC
managementFee: 1, // 1%
profitShare: 10, // 10%
hurdleRate: 5, // 5%
permissioned: false, // public vault or whitelist
})
Deposit tokens into a drift vault.
const signature = await agent.depositIntoDriftVault(100, "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
Deposit tokens into your drift account.
const {txSig} = await agent.depositToDriftUserAccount(100, "USDC")
Derive a drift vault address.
const vaultPublicKey = await agent.deriveDriftVaultAddress("my-drift-vault")
Check if agent has a drift account.
const {hasAccount, account} = await agent.doesUserHaveDriftAccount()
Get drift account information.
const accountInfo = await agent.driftUserAccountInfo()
Request withdrawal from drift vault.
const signature = await agent.requestWithdrawalFromDriftVault(100, "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
Open a perpetual trade using a drift vault that is delegated to you.
const signature = await agent.tradeUsingDelegatedDriftVault({
vault: "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU",
amount: 500,
symbol: "SOL",
action: "long",
type: "limit",
price: 180 // Please long limit order at $180/SOL
})
Open a perpetual trade using your drift account.
const signature = await agent.tradeUsingDriftPerpAccount({
amount: 500,
symbol: "SOL",
action: "long",
type: "limit",
price: 180 // Please long limit order at $180/SOL
})
Update drift vault parameters.
const signature = await agent.updateDriftVault({
name: "my-drift-vault",
marketName: "USDC-SPOT",
redeemPeriod: 1, // in days
maxTokens: 100000, // in token units e.g 100000 USDC
minDepositAmount: 5, // in token units e.g 5 USDC
managementFee: 1, // 1%
profitShare: 10, // 10%
hurdleRate: 5, // 5%
permissioned: false, // public vault or whitelist
})
Withdraw tokens from your drift account.
const {txSig} = await agent.withdrawFromDriftAccount(100, "USDC")
Borrow tokens from drift.
const {txSig} = await agent.withdrawFromDriftAccount(1, "SOL", true)
Repay a loan from drift.
const {txSig} = await agent.depositToDriftUserAccount(1, "SOL", true)
Withdraw tokens from a drift vault after the redemption period has elapsed.
const signature = await agent.withdrawFromDriftVault( "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
Update the address a drift vault is delegated to.
const signature = await agent.updateDriftVaultDelegate("41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU", "new-address")
Get the current position values and total value of assets in a Voltr vault.
const values = await agent.voltrGetPositionValues("7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K")
Deposit assets into a specific strategy within a Voltr vault.
const signature = await agent.voltrDepositStrategy(
new BN("1000000000"), // amount in base units (e.g., 1 USDC = 1000000)
"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K", // vault
"9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk" // strategy
)
Withdraw assets from a specific strategy within a Voltr vault.
const signature = await agent.voltrWithdrawStrategy(
new BN("1000000000"), // amount in base units (e.g., 1 USDC = 1000000)
"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K", // vault
"9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk" // strategy
)
const asset = await agent.getAsset("41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
Get the price for a given token and timeframe from Allora's API
const sol5mPrice = await agent.getPriceInference("SOL", "5m");
console.log("5m price inference of SOL/USD:", sol5mPrice);
const topics = await agent.getAllTopics();
console.log("Allora topics:", topics);
const inference = await agent.getInferenceByTopicId(42);
console.log("Allora inference for topic 42:", inference);
Simulate a given Switchboard feed. Find or create feeds here.
const value = await agent.simulateSwitchboardFeed(
"9wcBMATS8bGLQ2UcRuYjsRAD7TPqB1CMhqfueBx78Uj2", // TRUMP/USD
"http://crossbar.switchboard.xyz");;
console.log("Simulation resulted in the following value:", value);
### Cross-Chain Swap
```typescript
import { PublicKey } from "@solana/web3.js";
const signature = await agent.swap(
amount: "10",
fromChain: "bsc",
fromToken: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
toChain: "solana",
toToken: "0x0000000000000000000000000000000000000000",
dstAddr: "0xc2d3024d64f27d85e05c40056674Fd18772dd922",
);
The Solana Agent Kit supports cross-chain token transfers using deBridge's DLN protocol. Here's how to use it:
const chains = await agent.getDebridgeSupportedChains();
console.log("Available chains:", chains);
// Example output: { chains: [{ chainId: "1", chainName: "Ethereum" }, { chainId: "7565164", chainName: "Solana" }] }
const tokens = await agent.getDebridgeTokensInfo("1", "USDC"); // Search for USDC on Ethereum
console.log("Available tokens:", tokens);
// Shows tokens matching 'USDC' on the specified chain
const orderInput = {
srcChainId: "7565164", // Solana
srcChainTokenIn: "11111111111111111111111111111111", // Native SOL
srcChainTokenInAmount: "1000000000", // 1 SOL (9 decimals)
dstChainId: "1", // Ethereum
dstChainTokenOut: "0x0000000000000000000000000000000000000000", // ETH
dstChainTokenOutRecipient: "0x23C279e58ddF1018C3B9D0C224534fA2a83fb1d2" // ETH recipient
};
const order = await agent.createDebridgeOrder(orderInput);
console.log("Order created:", order);
// Contains transaction data and estimated amounts
const signature = await agent.executeDebridgeOrder(order.tx.data);
console.log("Bridge transaction sent:", signature);
const status = await agent.checkDebridgeTransactionStatus(signature);
console.log("Bridge status:", status);
// Shows current status: Created, Fulfilled, etc.
Note: When bridging between chains:
const priceData = await agent.getTokenPriceData([
"So11111111111111111111111111111111111111112", // SOL
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" // USDC
]);
console.log("Token prices:", priceData);
const trendingTokens = await agent.getTrendingTokens();
console.log("Trending tokens:", trendingTokens);
const latestPools = await agent.getLatestPools();
console.log("Latest pools:", latestPools);
const tokenInfo = await agent.getTokenInfo("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
console.log("Token info:", tokenInfo);
const topGainers = await agent.getTopGainers("24h", "all");
console.log("Top gainers:", topGainers);
const trendingPools = await agent.getTrendingPools("24h");
console.log("Trending pools:", trendingPools);
The toolkit provides comprehensive integration with OKX DEX for Solana. Here's how to use the DEX API tools:
const tokens = await agent.getTokens();
console.log("Supported tokens:", tokens);
// Returns list of tokens available on OKX DEX
const quote = await agent.getQuote(
"So11111111111111111111111111111111111111112", // fromTokenAddress (SOL)
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // toTokenAddress (USDC)
"1000000000", // amount in base units
"0.5" // slippage (optional, default 0.5%)
);
console.log("Swap quote:", quote);
// Returns quote data with price, fees, and slippage, token symbol, decimals
const swapResult = await agent.executeSwap({
fromTokenAddress: "So11111111111111111111111111111111111111112", // SOL
toTokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
amount: "1000000000", // amount in base units
autoSlippage: true, // optional, use auto slippage
slippage: "0.1", // optional, custom slippage (0.1%)
maxAutoSlippageBps: "100" // optional, max auto slippage in basis points
userAddress: "signer-public-key" // optional, user wallet address
});
console.log("Swap executed:", swapResult);
Note: To use OKX DEX integration, you need to set up the following environment variables: Get OKX API keys from the [OKX Developer Portal] (https://www.okx.com/web3/build/dev-portal)
OKX_API_KEY
OKX_SECRET_KEY
OKX_API_PASSPHRASE
OKX_PROJECT_ID
RPC_URL
SOLANA_PRIVATE_KEY
SOLANA_WALLET_ADDRESS
The repository includes an advanced example of building a multi-agent system using LangGraph and Solana Agent Kit. Located in examples/agent-kit-langgraph
, this example demonstrates:
Check out the LangGraph example for a complete implementation of an advanced Solana agent system.
The toolkit relies on several key Solana and Metaplex libraries:
Contributions are welcome! Please feel free to submit a Pull Request. Refer to CONTRIBUTING.md for detailed guidelines on how to contribute to this project.
Apache-2 License
If you wanna give back any tokens or donations to the OSS community -- The Public Solana Agent Kit Treasury Address:
Solana Network : EKHTbXpsm6YDgJzMkFxNU1LNXeWcUW7Ezf8mjUNQQ4Pa
This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.