A powerful toolkit for interacting with the Solana blockchain, providing easy-to-use functions for token operations, NFT management, and trading. Now integrated with LangChain for enhanced functionality.
-
🪙 Token Operations
- Deploy new SPL tokens
- Transfer SOL and SPL tokens
- Check token balances
- Stake SOL
-
🖼️ NFT Management
- Deploy NFT collections
- Mint NFTs to collections
- Manage metadata and royalties
-
💱 Trading
- Integrated Jupiter Exchange support
- Token swaps with customizable slippage
- Direct routing options
-
🏦 Yield Farming
- Lend idle assets to earn interest with Lulo
-
🔗 LangChain Integration
- Utilize LangChain tools for enhanced blockchain interactions
- Access a suite of tools for balance checks, transfers, token deployments, and more
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);
import { deploy_token } from "solana-agent-kit";
const result = await deploy_token(
agent,
9, // decimals
1000000 // initial supply
);
console.log("Token Mint Address:", result.mint.toString());
import { deploy_collection } from "solana-agent-kit";
const collection = await deploy_collection(agent, {
name: "My NFT Collection",
uri: "https://arweave.net/metadata.json",
royaltyBasisPoints: 500, // 5%
creators: [
{
address: "creator-wallet-address",
percentage: 100,
},
],
});
import { trade } from "solana-agent-kit";
import { PublicKey } from "@solana/web3.js";
const signature = await trade(
agent,
new PublicKey("target-token-mint"),
100, // amount
new PublicKey("source-token-mint"),
300 // 3% slippage
);
import { lendAsset } from "solana-agent-kit";
import { PublicKey } from "@solana/web3.js";
const signature = await lendAsset(
agent,
100 // amount
);
import { stakeWithJup } from "solana-agent-kit";
const signature = await stakeWithJup(
agent,
1 // amount in SOL
);
import { fetchPrice } from "solana-agent-kit";
const price = await fetchPrice(
agent,
"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" // Token mint address
);
console.log("Price in USDC:", price);
Deploy a new SPL token with optional initial supply. If not specified, decimals default to 9.
Create a new NFT collection with customizable metadata and royalties.
Mint a new NFT as part of an existing collection.
Transfer SOL or SPL tokens to a recipient.
Swap tokens using Jupiter Exchange integration.
Check SOL or token balance for the agent's wallet.
Lend idle assets to earn interest with Lulo.
Stake SOL with Jupiter to earn rewards.
The toolkit relies on several key Solana and Metaplex libraries:
-
@solana/web3.js
-
@solana/spl-token
-
@metaplex-foundation/mpl-token-metadata
-
@metaplex-foundation/mpl-core
-
@metaplex-foundation/umi
Contributions are welcome! Please feel free to submit a Pull Request.
ISC License
This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.