solana-agent-kit
-
Solana Agent Kit
+
solana-agent-kit
solana-agent-kit
+
Solana Agent Kit
@@ -15,11 +15,11 @@
And more...
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
+Replit template created by Arpit Singh
-
🔧 Core Blockchain Features
+🔧 Core Blockchain Features
Token Operations
@@ -46,7 +46,7 @@
Launch on Pump via PumpPortal
Raydium pool creation (CPMM, CLMM, AMMv4)
Orca Whirlpool integration
-Meteora Dynamic AMM, DLMM Pool, and Alpga Vault
+Meteora Dynamic AMM, DLMM Pool, and Alpha Vault
Openbook market creation
Register and Resolve SNS
Jito Bundles
@@ -57,7 +57,7 @@
Solana Blinks
-Lending by Lulon (Best APR for USDC)
+Lending by Lulo (Best APR for USDC)
Send Arcade Games
JupSOL staking
@@ -69,7 +69,7 @@
-🤖 AI Integration Features
+🤖 AI Integration Features
-📦 Installation npm install solana-agent-kit
+📦 Installation npm install solana-agent-kit
Copy
-Quick Start 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 );
+Quick Start 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 );
Copy
-Usage Examples Deploy a New Token const result = await agent . deployToken ( "my ai token" , // name "uri" , // uri "token" , // symbol 9 , // decimals 1000000 // initial supply ); console . log ( "Token Mint Address:" , result . mint . toString ());
+Usage Examples Deploy a New Token const result = await agent . deployToken ( "my ai token" , // name "uri" , // uri "token" , // symbol 9 , // decimals 1000000 // initial supply ); console . log ( "Token Mint Address:" , result . mint . toString ());
Copy
-Create NFT Collection 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 , }, ], });
+Create NFT Collection 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 , }, ], });
Copy
-Swap Tokens 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 );
+Swap Tokens 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 );
Copy
-Lend Tokens import { PublicKey } from "@solana/web3.js" ; const signature = await agent . lendAssets ( 100 // amount of USDC to lend );
+Lend Tokens import { PublicKey } from "@solana/web3.js" ; const signature = await agent . lendAssets ( 100 // amount of USDC to lend );
Copy
-Stake SOL const signature = await agent . stake ( 1 // amount in SOL to stake );
+Stake SOL const signature = await agent . stake ( 1 // amount in SOL to stake );
Copy
-Send an SPL Token Airdrop via ZK Compression 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 ); })();
+Send an SPL Token Airdrop via ZK Compression 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 ); })();
Copy
-Fetch Price Data from Pyth const price = await agent . pythFetchPrice ( "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43" ); console . log ( "Price in BTC/USD:" , price );
+Fetch Price Data from Pyth const price = await agent . pythFetchPrice ( "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43" ); console . log ( "Price in BTC/USD:" , price );
Copy
-Examples LangGraph Multi-Agent System 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:
+Examples LangGraph Multi-Agent System 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:
Multi-agent architecture using LangGraph's StateGraph
Specialized agents for different tasks:
@@ -140,7 +140,7 @@
Environment-based configuration
Check out the LangGraph example for a complete implementation of an advanced Solana agent system.
-Dependencies The toolkit relies on several key Solana and Metaplex libraries:
+Dependencies The toolkit relies on several key Solana and Metaplex libraries:
@solana/web3.js
@solana/spl-token
@@ -151,12 +151,12 @@
@lightprotocol/stateless.js
@pythnetwork/price-service-client
-Contributing Contributions are welcome! Please feel free to submit a Pull Request.
+
Contributing 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.
-Contributors
+ Contributors
-Star History
-License Apache-2 License
-Security This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.
-
+
Star History
+
License Apache-2 License
+
Security This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.
+
diff --git a/docs/interfaces/CollectionDeployment.html b/docs/interfaces/CollectionDeployment.html
index 29d2d441..1b7ff4f7 100644
--- a/docs/interfaces/CollectionDeployment.html
+++ b/docs/interfaces/CollectionDeployment.html
@@ -1,3 +1,3 @@
-
CollectionDeployment | solana-agent-kit Interface CollectionDeployment IndexProperties collection Address
+
CollectionDeployment | solana-agent-kit Interface CollectionDeployment Propertiescollection Address collection Address : PublicKey
signature signature : Uint8Array < ArrayBufferLike >
+
Propertiescollection Address collectionAddress : PublicKey
signature signature : Uint8Array
diff --git a/docs/interfaces/CollectionOptions.html b/docs/interfaces/CollectionOptions.html
index cb6532a8..055d6dae 100644
--- a/docs/interfaces/CollectionOptions.html
+++ b/docs/interfaces/CollectionOptions.html
@@ -1,5 +1,5 @@
-
CollectionOptions | solana-agent-kit Interface CollectionOptions IndexProperties creators?
+
CollectionOptions | solana-agent-kit Interface CollectionOptions PropertiesOptional
royalty Basis Points royalty Basis Points ?: number
+
PropertiesOptional
royalty Basis Points royaltyBasisPoints ?: number
diff --git a/docs/interfaces/Config.html b/docs/interfaces/Config.html
new file mode 100644
index 00000000..9d46ae74
--- /dev/null
+++ b/docs/interfaces/Config.html
@@ -0,0 +1,4 @@
+
Config | solana-agent-kit PropertiesOptional
JUPITER_ FEE_ BPS JUPITER_FEE_BPS ?: number
Optional
JUPITER_ REFERRAL_ ACCOUNT JUPITER_REFERRAL_ACCOUNT ?: string
Optional
OPENAI_ API_ KEY OPENAI_API_KEY ?: string
diff --git a/docs/interfaces/Creator.html b/docs/interfaces/Creator.html
index 717b3d88..e9bfa4ce 100644
--- a/docs/interfaces/Creator.html
+++ b/docs/interfaces/Creator.html
@@ -1,3 +1,3 @@
-
Creator | solana-agent-kit IndexProperties address
+
Creator | solana-agent-kit Propertiespercentage percentage : number
+
Propertiespercentage percentage : number
diff --git a/docs/interfaces/FetchPriceResponse.html b/docs/interfaces/FetchPriceResponse.html
index cfe4fa20..73e43785 100644
--- a/docs/interfaces/FetchPriceResponse.html
+++ b/docs/interfaces/FetchPriceResponse.html
@@ -1,6 +1,6 @@
-
FetchPriceResponse | solana-agent-kit Interface FetchPriceResponse IndexProperties code?
+
FetchPriceResponse | solana-agent-kit Interface FetchPriceResponse PropertiesOptional
code code ?: string
Optional
message message ?: string
Optional
price InUSDC price InUSDC ?: string
status status : "success" | "error"
Optional
token Id token Id ?: string
+
token Id?
+
PropertiesOptional
code code ?: string
Optional
message message ?: string
Optional
price InUSDC priceInUSDC ?: string
status status : "success" | "error"
Optional
token Id tokenId ?: string
diff --git a/docs/interfaces/GibworkCreateTaskReponse.html b/docs/interfaces/GibworkCreateTaskReponse.html
index 7709d818..520daa93 100644
--- a/docs/interfaces/GibworkCreateTaskReponse.html
+++ b/docs/interfaces/GibworkCreateTaskReponse.html
@@ -1,4 +1,4 @@
-
GibworkCreateTaskReponse | solana-agent-kit Interface GibworkCreateTaskReponse IndexProperties signature?
+
GibworkCreateTaskReponse | solana-agent-kit Interface GibworkCreateTaskReponse PropertiesOptional
signature signature ?: string
status status : "success" | "error"
Optional
task Id task Id ?: string
+
task Id?
+
PropertiesOptional
signature signature ?: string
status status : "success" | "error"
Optional
task Id taskId ?: string
diff --git a/docs/interfaces/JupiterTokenData.html b/docs/interfaces/JupiterTokenData.html
index c1d72cb9..e589814a 100644
--- a/docs/interfaces/JupiterTokenData.html
+++ b/docs/interfaces/JupiterTokenData.html
@@ -1,12 +1,12 @@
-
JupiterTokenData | solana-agent-kit Interface JupiterTokenData IndexProperties address
+
JupiterTokenData | solana-agent-kit Interface JupiterTokenData Propertiesdaily_ volume daily_ volume : number
extensions extensions : { coingeckoId ?: string ; }
freeze_ authority freeze_ authority : null | string
mint_ authority mint_ authority : null | string
permanent_ delegate permanent_ delegate : null | string
+
Propertiesdaily_ volume daily_volume : number
extensions extensions : { coingeckoId ?: string }
freeze_ authority freeze_authority : null | string
mint_ authority mint_authority : null | string
permanent_ delegate permanent_delegate : null | string
diff --git a/docs/interfaces/LuloAccountDetailsResponse.html b/docs/interfaces/LuloAccountDetailsResponse.html
index 776cea4f..9d032878 100644
--- a/docs/interfaces/LuloAccountDetailsResponse.html
+++ b/docs/interfaces/LuloAccountDetailsResponse.html
@@ -1,6 +1,6 @@
-
LuloAccountDetailsResponse | solana-agent-kit Interface LuloAccountDetailsResponse IndexProperties interest Earned
-
realtime Apy
+
LuloAccountDetailsResponse | solana-agent-kit Interface LuloAccountDetailsResponse Propertiesinterest Earned interest Earned : number
realtime Apy realtime Apy : number
settings settings : { allowedProtocols : null | string ; homebase : null | string ; minimumRate : string ; owner : string ; }
total Value total Value : number
+
total Value
+
Propertiesinterest Earned interestEarned : number
realtime Apy realtimeApy : number
settings settings : { allowedProtocols : null | string ; homebase : null | string ; minimumRate : string ; owner : string ; }
total Value totalValue : number
diff --git a/docs/interfaces/MintCollectionNFTResponse.html b/docs/interfaces/MintCollectionNFTResponse.html
index f479f623..db065a22 100644
--- a/docs/interfaces/MintCollectionNFTResponse.html
+++ b/docs/interfaces/MintCollectionNFTResponse.html
@@ -1,3 +1,3 @@
-
MintCollectionNFTResponse | solana-agent-kit Interface MintCollectionNFTResponse interface MintCollectionNFTResponse { metadata : PublicKey ; mint : PublicKey ; } IndexProperties metadata
+
MintCollectionNFTResponse | solana-agent-kit Interface MintCollectionNFTResponse interface MintCollectionNFTResponse { metadata : PublicKey ; mint : PublicKey ; } Propertiesmetadata metadata : PublicKey
+
Propertiesmetadata metadata : PublicKey
diff --git a/docs/interfaces/PumpFunTokenOptions.html b/docs/interfaces/PumpFunTokenOptions.html
index 06173155..eeccce9a 100644
--- a/docs/interfaces/PumpFunTokenOptions.html
+++ b/docs/interfaces/PumpFunTokenOptions.html
@@ -1,7 +1,7 @@
-
PumpFunTokenOptions | solana-agent-kit Interface PumpFunTokenOptions IndexProperties initial LiquiditySOL?
-
priority Fee?
-
slippage Bps?
+
PumpFunTokenOptions | solana-agent-kit Interface PumpFunTokenOptions PropertiesOptional
initial LiquiditySOL initial LiquiditySOL ?: number
Optional
priority Fee priority Fee ?: number
Optional
slippage Bps slippage Bps ?: number
Optional
telegram telegram ?: string
Optional
twitter twitter ?: string
Optional
website website ?: string
+
PropertiesOptional
initial LiquiditySOL initialLiquiditySOL ?: number
Optional
priority Fee priorityFee ?: number
Optional
slippage Bps slippageBps ?: number
Optional
telegram telegram ?: string
Optional
twitter twitter ?: string
Optional
website website ?: string
diff --git a/docs/interfaces/PumpfunLaunchResponse.html b/docs/interfaces/PumpfunLaunchResponse.html
index 0ee50450..93ddbad6 100644
--- a/docs/interfaces/PumpfunLaunchResponse.html
+++ b/docs/interfaces/PumpfunLaunchResponse.html
@@ -1,5 +1,5 @@
-
PumpfunLaunchResponse | solana-agent-kit Interface PumpfunLaunchResponse IndexProperties error?
-
metadata Uri?
+
PumpfunLaunchResponse | solana-agent-kit Interface PumpfunLaunchResponse PropertiesOptional
error error ?: string
Optional
metadata Uri metadata Uri ?: string
signature signature : string
+
PropertiesOptional
error error ?: string
Optional
metadata Uri metadataUri ?: string
signature signature : string
diff --git a/docs/interfaces/PythFetchPriceResponse.html b/docs/interfaces/PythFetchPriceResponse.html
index c1a12881..933f24a2 100644
--- a/docs/interfaces/PythFetchPriceResponse.html
+++ b/docs/interfaces/PythFetchPriceResponse.html
@@ -1,6 +1,6 @@
-
PythFetchPriceResponse | solana-agent-kit Interface PythFetchPriceResponse IndexProperties code?
+
PythFetchPriceResponse | solana-agent-kit Interface PythFetchPriceResponse PropertiesOptional
code code ?: string
Optional
message message ?: string
Optional
price price ?: string
price FeedID price FeedID : string
status status : "success" | "error"
+
PropertiesOptional
code code ?: string
Optional
message message ?: string
Optional
price price ?: string
price FeedID priceFeedID : string
status status : "success" | "error"
diff --git a/docs/modules.html b/docs/modules.html
index fba41cbf..52a12f1a 100644
--- a/docs/modules.html
+++ b/docs/modules.html
@@ -1,14 +1 @@
-
solana-agent-kit
+
solana-agent-kit
diff --git a/package.json b/package.json
index e0413659..3f5de399 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "solana-agent-kit",
- "version": "1.3.1",
+ "version": "1.3.2",
"description": "connect any ai agents to solana protocols",
"main": "dist/index.js",
"types": "dist/index.d.ts",
diff --git a/src/agent/index.ts b/src/agent/index.ts
index f8809946..5d146a11 100644
--- a/src/agent/index.ts
+++ b/src/agent/index.ts
@@ -67,6 +67,7 @@ import { BN } from "@coral-xyz/anchor";
* @property {Connection} connection - Solana RPC connection
* @property {Keypair} wallet - Wallet keypair for signing transactions
* @property {PublicKey} wallet_address - Public key of the wallet
+ * @property {Config} config - Configuration object
*/
export class SolanaAgentKit {
public connection: Connection;
@@ -74,15 +75,31 @@ export class SolanaAgentKit {
public wallet_address: PublicKey;
public config: Config;
+ /**
+ * @deprecated Using openai_api_key directly in constructor is deprecated.
+ * Please use the new constructor with Config object instead:
+ * @example
+ * const agent = new SolanaAgentKit(privateKey, rpcUrl, {
+ * OPENAI_API_KEY: 'your-key'
+ * });
+ */
+ constructor(private_key: string, rpc_url: string, openai_api_key: string | null);
+ constructor(private_key: string, rpc_url: string, config: Config);
constructor(
private_key: string,
- rpc_url = "https://api.mainnet-beta.solana.com",
- config: Config,
+ rpc_url: string,
+ configOrKey: Config | string | null,
) {
- this.connection = new Connection(rpc_url);
+ this.connection = new Connection(rpc_url || "https://api.mainnet-beta.solana.com");
this.wallet = Keypair.fromSecretKey(bs58.decode(private_key));
this.wallet_address = this.wallet.publicKey;
- this.config = config;
+
+ // Handle both old and new patterns
+ if (typeof configOrKey === 'string' || configOrKey === null) {
+ this.config = { OPENAI_API_KEY: configOrKey || '' };
+ } else {
+ this.config = configOrKey;
+ }
}
// Tool methods
diff --git a/test/index.ts b/test/index.ts
index abd50d07..b6e51e70 100644
--- a/test/index.ts
+++ b/test/index.ts
@@ -52,7 +52,7 @@ async function initializeAgent() {
const solanaAgent = new SolanaAgentKit(
process.env.SOLANA_PRIVATE_KEY!,
- process.env.RPC_URL,
+ process.env.RPC_URL!,
{
OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
},
Main class for interacting with Solana blockchain +
- Preparing search index...
- The search index is not available
solana-agent-kitClass SolanaAgentKit
Main class for interacting with Solana blockchain Provides a unified interface for token operations, NFT management, trading and more
SolanaAgentKit
-Index
Constructors
Properties
Index
Constructors
Properties
Methods
Methods
Constructors
constructor
Parameters
Returns SolanaAgentKit
Properties
connection
Solana RPC connection
-openai_ api_ key
wallet
Wallet keypair for signing transactions
-wallet_ address
Public key of the wallet
-Methods
create Gibwork Task
Parameters
Optional
payer: stringReturns Promise<GibworkCreateTaskReponse>
create Orca Single Sided Whirlpool
Parameters
| 0.01
| 0.02
| 0.04
| 0.05
| 0.16
| 0.3
| 0.65
| 1
| 2
Returns Promise<string>
create Tiplink
signature: string;
url: string;
}>
Parameters
Optional
splmintAddress: PublicKeyReturns Promise<{
signature: string;
url: string;
}>
deploy Collection
Parameters
Returns Promise<CollectionDeployment>
deploy Token
mint: PublicKey;
}>
Parameters
Optional
initialSupply: numberReturns Promise<{
mint: PublicKey;
}>
fetch Token Price
Parameters
Returns Promise<string>
get All DomainsTLDs
Returns Promise<String[]>
get All Registered All Domains
Returns Promise<string[]>
get Balance
Parameters
Optional
token_address: PublicKeyReturns Promise<number>
get Balance Other
Parameters
Optional
tokenAddress: PublicKeyReturns Promise<number>
get Main All Domains Domain
Parameters
Returns Promise<null | string>
get Owned All Domains
Parameters
Returns Promise<string[]>
get Owned Domains ForTLD
Parameters
Returns Promise<string[]>
get Primary Domain
Parameters
Returns Promise<string>
get Token Data By Address
Parameters
Returns Promise<undefined | JupiterTokenData>
get Token Data By Ticker
Parameters
Returns Promise<undefined | JupiterTokenData>
getTPS
Returns Promise<number>
launch Pump Fun Token
Parameters
Optional
options: PumpFunTokenOptionsReturns Promise<PumpfunLaunchResponse>
lend Assets
Parameters
Returns Promise<string>
mintNFT
Parameters
creators?: {
address: string;
share: number;
}[];
name: string;
sellerFeeBasisPoints?: number;
uri: string;
}
Optional
creators?: {address: string;
share: number;
}[]
name: string
Optional
selleruri: string
Optional
recipient: PublicKeyReturns Promise<MintCollectionNFTResponse>
openbook Create Market
Parameters
Returns Promise<string[]>
pyth Fetch Price
Parameters
Returns Promise<string>
raydium Create Amm V4
Parameters
Returns Promise<string>
raydium Create Clmm
Parameters
Returns Promise<string>
raydium Create Cpmm
Parameters
Returns Promise<string>
register Domain
Parameters
Optional
spaceKB: numberReturns Promise<string>
request Faucet Funds
Returns Promise<string>
resolve All Domains
Parameters
Returns Promise<undefined | PublicKey>
resolve Sol Domain
Parameters
Returns Promise<PublicKey>
rock Paper Scissors
Parameters
Returns Promise<string>
send Compressed Airdrop
Parameters
Returns Promise<string[]>
stake
Parameters
Returns Promise<string>
trade
Parameters
Optional
inputMint: PublicKeyReturns Promise<string>
transfer
Parameters
Optional
mint: PublicKeyReturns Promise<string>
Settings
On This Page
Constructors
Properties
Methods