mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-13 23:16:55 +00:00
Merging in main.
This commit is contained in:
82
README.md
82
README.md
@@ -5,22 +5,26 @@ A powerful toolkit for interacting with the Solana blockchain, providing easy-to
|
||||
## Features
|
||||
|
||||
- 🪙 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
|
||||
@@ -36,12 +40,13 @@ npm install solana-agent-kit
|
||||
## Quick Start
|
||||
|
||||
```typescript
|
||||
import { SolanaAgentKit, createSolanaTools } from 'solana-agent-kit';
|
||||
import { SolanaAgentKit, createSolanaTools } from "solana-agent-kit";
|
||||
|
||||
// Initialize with private key and optional RPC URL
|
||||
const agent = new SolanaAgentKit(
|
||||
'your-private-key',
|
||||
'https://api.mainnet-beta.solana.com'
|
||||
"your-wallet-private-key-as-base58",
|
||||
"https://api.mainnet-beta.solana.com",
|
||||
"your-openai-api-key"
|
||||
);
|
||||
|
||||
// Create LangChain tools
|
||||
@@ -53,93 +58,93 @@ const tools = createSolanaTools(agent);
|
||||
### Deploy a New Token
|
||||
|
||||
```typescript
|
||||
import { deploy_token } from 'solana-agent-kit';
|
||||
import { deploy_token } from "solana-agent-kit";
|
||||
|
||||
const result = await deploy_token(
|
||||
agent,
|
||||
9, // decimals
|
||||
1000000 // initial supply
|
||||
agent,
|
||||
9, // decimals
|
||||
1000000 // initial supply
|
||||
);
|
||||
|
||||
console.log('Token Mint Address:', result.mint.toString());
|
||||
console.log("Token Mint Address:", result.mint.toString());
|
||||
```
|
||||
|
||||
### Create NFT Collection
|
||||
|
||||
```typescript
|
||||
import { deploy_collection } from 'solana-agent-kit';
|
||||
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
|
||||
}
|
||||
]
|
||||
name: "My NFT Collection",
|
||||
uri: "https://arweave.net/metadata.json",
|
||||
royaltyBasisPoints: 500, // 5%
|
||||
creators: [
|
||||
{
|
||||
address: "creator-wallet-address",
|
||||
percentage: 100,
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Swap Tokens
|
||||
|
||||
```typescript
|
||||
import { trade } from 'solana-agent-kit';
|
||||
import { PublicKey } from '@solana/web3.js';
|
||||
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
|
||||
agent,
|
||||
new PublicKey("target-token-mint"),
|
||||
100, // amount
|
||||
new PublicKey("source-token-mint"),
|
||||
300 // 3% slippage
|
||||
);
|
||||
```
|
||||
|
||||
### Lend Tokens
|
||||
|
||||
```typescript
|
||||
import { lendAsset } from 'solana-agent-kit';
|
||||
import { PublicKey } from '@solana/web3.js';
|
||||
import { lendAsset } from "solana-agent-kit";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
const signature = await lendAsset(
|
||||
agent,
|
||||
100, // amount
|
||||
agent,
|
||||
100 // amount
|
||||
);
|
||||
```
|
||||
|
||||
### Stake SOL
|
||||
|
||||
```typescript
|
||||
import { stakeWithJup } from 'solana-agent-kit';
|
||||
import { stakeWithJup } from "solana-agent-kit";
|
||||
|
||||
const signature = await stakeWithJup(
|
||||
agent,
|
||||
1 // amount in SOL
|
||||
agent,
|
||||
1 // amount in SOL
|
||||
);
|
||||
```
|
||||
|
||||
### Fetch Token Price
|
||||
|
||||
```typescript
|
||||
import { fetchPrice } from 'solana-agent-kit';
|
||||
import { fetchPrice } from "solana-agent-kit";
|
||||
|
||||
const price = await fetchPrice(
|
||||
agent,
|
||||
'JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN' // Token mint address
|
||||
agent,
|
||||
"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" // Token mint address
|
||||
);
|
||||
|
||||
console.log('Price in USDC:', price);
|
||||
console.log("Price in USDC:", price);
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
### Core Functions
|
||||
|
||||
#### `deploy_token(agent, decimals, name, uri, symbol, initialSupply?)`
|
||||
#### `deploy_token(agent, decimals?, name, uri, symbol, initialSupply?)`
|
||||
|
||||
Deploy a new SPL token with optional initial supply.
|
||||
Deploy a new SPL token with optional initial supply. If not specified, decimals default to 9.
|
||||
|
||||
#### `deploy_collection(agent, options)`
|
||||
|
||||
@@ -166,6 +171,7 @@ Check SOL or token balance for the agent's wallet.
|
||||
Lend idle assets to earn interest with Lulo.
|
||||
|
||||
#### `stakeWithJup(agent, amount)`
|
||||
|
||||
Stake SOL with Jupiter to earn rewards.
|
||||
|
||||
## Dependencies
|
||||
|
||||
2900
package-lock.json
generated
Normal file
2900
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user