Solana Trading Bots: The Complete Setup Guide for 2026
Solana's sub-second finality and ultra-low fees make it the best chain for high-frequency trading bots. Learn how to build and deploy a Solana trading bot using Jupiter, Raydium, and the Solana Web3.js SDK.
Builder of AI agents, crypto trading bots, and open-source automation tools. Sharing practical guides on how to build, deploy, and profit from AI and DeFi technology.
Why Solana for Trading Bots?
Ethereum is expensive. Gas fees during peak hours can eat all your bot's profits. Solana changes the math entirely:
- 400ms block times โ one of the fastest finalities in crypto
- $0.0001 per transaction โ bots can execute thousands of trades affordably
- High throughput โ 65,000+ TPS theoretical capacity
- Deep liquidity โ Jupiter aggregates 20+ DEXs for best price routing
For trading bots, Solana's speed advantage over Ethereum is roughly 15x on block confirmation times. For arbitrage and sniping strategies, that's the difference between catching the trade and missing it.
Prerequisites
# Install Solana CLI tools
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
# Install dependencies
npm install @solana/web3.js @jup-ag/api @project-serum/anchor
You'll also need:
- A Solana wallet with SOL for fees
- An RPC node (Helius, QuickNode Solana, or public endpoint)
- Basic TypeScript/JavaScript knowledge
Setting Up Your Wallet and Connection
import { Connection, Keypair, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js'
import * as bs58 from 'bs58'
// Connect to Solana mainnet
const connection = new Connection(
process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com',
'confirmed'
)
// Load wallet from private key
const privateKey = bs58.decode(process.env.WALLET_PRIVATE_KEY!)
const wallet = Keypair.fromSecretKey(privateKey)
console.log('Wallet address:', wallet.publicKey.toBase58())
// Check SOL balance
const balance = await connection.getBalance(wallet.publicKey)
console.log('Balance:', balance / LAMPORTS_PER_SOL, 'SOL')
Building a Jupiter Swap Bot
Jupiter is the best DEX aggregator on Solana โ it routes your trades through the best available liquidity across Raydium, Orca, Serum, and more.
import { createJupiterApiClient } from '@jup-ag/api'
const jupiterApi = createJupiterApiClient()
async function swapTokens(
inputMint: string, // Token you're selling (e.g., USDC)
outputMint: string, // Token you're buying (e.g., SOL)
amount: number, // Amount in lamports/smallest unit
slippageBps: number = 50 // 0.5% slippage
) {
// Get best quote
const quote = await jupiterApi.quoteGet({
inputMint,
outputMint,
amount,
slippageBps,
})
console.log(`Best route: ${quote.routePlan.map(r => r.swapInfo.label).join(' โ ')}`)
console.log(`Expected output: ${quote.outAmount}`)
// Get swap transaction
const swapResult = await jupiterApi.swapPost({
swapRequest: {
quoteResponse: quote,
userPublicKey: wallet.publicKey.toBase58(),
wrapAndUnwrapSol: true,
}
})
// Deserialize and sign transaction
const swapTransactionBuf = Buffer.from(swapResult.swapTransaction, 'base64')
const transaction = VersionedTransaction.deserialize(swapTransactionBuf)
transaction.sign([wallet])
// Send transaction
const txid = await connection.sendRawTransaction(transaction.serialize())
await connection.confirmTransaction(txid)
console.log(`Swap confirmed: https://solscan.io/tx/${txid}`)
return txid
}
Token Sniping Bot on Solana
New Solana token launches on Raydium happen every minute. A sniping bot detects new pool creation and buys in the first blocks.
import { PublicKey } from '@solana/web3.js'
const RAYDIUM_LIQUIDITY_POOL_V4 = new PublicKey('675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8')
// Monitor new Raydium pool creations
connection.onLogs(RAYDIUM_LIQUIDITY_POOL_V4, async (logs) => {
if (logs.logs.some(log => log.includes('initialize2'))) {
console.log('New pool detected!')
// Parse pool info from transaction
const tx = await connection.getTransaction(logs.signature, {
commitment: 'confirmed',
maxSupportedTransactionVersion: 0
})
if (tx) {
const poolInfo = parseRaydiumPoolInit(tx)
await evaluateAndSnipe(poolInfo)
}
}
})
Arbitrage Between Raydium and Orca
const ORCA_USDC_SOL_POOL = '...' // USDC/SOL Orca pool address
const RAYDIUM_USDC_SOL_POOL = '...' // USDC/SOL Raydium pool address
async function checkSolanaArb() {
const [orcaPrice, raydiumPrice] = await Promise.all([
getOrcaPrice(ORCA_USDC_SOL_POOL),
getRaydiumPrice(RAYDIUM_USDC_SOL_POOL),
])
const spread = Math.abs(orcaPrice - raydiumPrice) / Math.min(orcaPrice, raydiumPrice)
if (spread > 0.003) { // 0.3% minimum spread after fees
const buyDex = orcaPrice < raydiumPrice ? 'orca' : 'raydium'
const sellDex = buyDex === 'orca' ? 'raydium' : 'orca'
console.log(`Arb opportunity: Buy on ${buyDex}, sell on ${sellDex}`)
console.log(`Spread: ${(spread * 100).toFixed(3)}%`)
await executeArb(buyDex, sellDex, TRADE_AMOUNT)
}
}
// Run every 500ms
setInterval(checkSolanaArb, 500)
Managing Solana Compute Units
Solana transactions have a compute unit (CU) limit. Complex swaps can fail if you don't set it high enough.
import { ComputeBudgetProgram, TransactionInstruction } from '@solana/web3.js'
// Add compute budget instruction to your transaction
const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({
units: 300_000 // Higher for complex routes
})
const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 10_000 // Tip to validators for faster inclusion
})
Important Risks
- Rug pulls: Many new Solana tokens are scams. Sniping bots frequently buy into rug pulls. Always check liquidity lock and team wallets.
- RPC rate limits: Free RPC endpoints throttle bot traffic. Get a paid endpoint.
- Slippage on thin pools: High slippage can eliminate profits. Test with small amounts first.
- MEV on Solana: Jito Labs runs an MEV relay on Solana. Expect sandwich bots on large swaps.
Recommended Tools
- Helius RPC: Best dedicated Solana node provider
- Birdeye: Token analytics and price feeds
- DexScreener: Real-time pool monitoring
- SolanaFM: Transaction explorer with decoded instructions
Solana's speed and cost make it the premier chain for trading bots in 2026. Start small, test thoroughly, and scale when you're consistently profitable.