ChainsSolana
Solana Wallet
Creating and configuring SolanaAgentWallet.
Creating a Wallet
import { SolanaAgentWallet, createKeypairProvider } from '@agentic-wallet/solana';
const wallet = new SolanaAgentWallet({
rpcUrl: 'https://api.mainnet-beta.solana.com',
provider: createKeypairProvider(process.env.SOLANA_PRIVATE_KEY!),
});Configuration
new SolanaAgentWallet({
rpcUrl: string, // Required - RPC endpoint
provider: SolanaWalletProvider, // Required - signer
commitment?: 'processed' | 'confirmed' | 'finalized', // Default: 'confirmed'
explorerCluster?: 'mainnet-beta' | 'devnet' | 'testnet', // Default: inferred from rpcUrl
koraConfig?: { // Optional - gasless transactions
rpcUrl: string,
apiKey?: string,
hmacSecret?: string,
},
})Provider Options
The provider can be any of:
- Keypair - Hot wallet from private key
- Privy - Embedded wallet
- Reown - WalletConnect
- Phantom - Browser extension
- Solflare - Browser extension
- Custom - Any signer implementing the interface
See Wallet Providers for detailed integration guides.
Basic Usage
// Check balance (SOL)
const balance = await wallet.balance();
// { address: '...', balance: 1.5, lamports: '1500000000' }
// Check balance (SPL token)
const tokenBalance = await wallet.balance({ mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' });
// { address: '...', balance: 100, decimals: 6, rawAmount: '100000000', mint: '...' }
// Transfer SOL
const result = await wallet.transfer({
to: 'RecipientAddress...',
amount: '0.5', // 0.5 SOL
});
// { signature: '...', explorerUrl: '...', from: '...', to: '...', amount: '0.5' }
// Transfer SPL token
const result = await wallet.transfer({
to: 'RecipientAddress...',
amount: '10',
mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
});
// { signature: '...', to: '...', amount: '10', mint: '...', rawAmount: '...' }
// Request airdrop (devnet only)
await wallet.requestAirdrop({ amount: '1' });
// { signature: '...', explorerUrl: '...', address: '...', amount: '1' }Plugin Registration
Add protocol integrations:
import { pumpfunPlugin, jupiterPlugin, raydiumPlugin } from '@agentic-wallet/solana/plugin';
const wallet = new SolanaAgentWallet({ ... })
.use(pumpfunPlugin())
.use(jupiterPlugin())
.use(raydiumPlugin());After registering plugins, methods are available on wallet.methods:
// Pump.fun
await wallet.methods.pumpfunCreateToken({ name: 'My Token', symbol: 'TKN', uri: '...' });
await wallet.methods.pumpfunBuy({ mint: '...', solAmount: '100000000' });
// Jupiter
await wallet.methods.jupiterSwap({ inputMint: 'SOL', outputMint: 'USDC', amount: '1' });Getting Tools for AI Agents
// Get all tools (built-in + plugin)
const tools = wallet.getTools();
// Filter tools
const onlyTrading = tools.filter(t =>
t.name.startsWith('jupiter_') || t.name.startsWith('pumpfun_')
);Properties
wallet.address- The wallet's base58 address (string)wallet.connection- The Solana Connection instancewallet.provider- The wallet providerwallet.explorerCluster- 'mainnet-beta' | 'devnet' | 'testnet'