Sound familiar? That's why I built my first Solana sniper bot last year. Now it's sniping launches before most humans even refresh. This guide? It's me walking you through running one - from zero to live trades. We'll use a Telegram bot setup 'cause it's dead simple and mobile friendly. No PhD required.
Okay, first things first. A Solana bot like this watches for new tokens (usually on Raydium or Pump.fun), buys fast with your settings, and can even auto sell on take profit or stop loss. Fees? Expect ~0.000005 SOL per tx on Solana, plus priority fees like 0.0001-0.01 SOL to jump the queue. Jito tips? Another 0.005 SOL bump for MEV protection. Why does this matter? Slow tx = you lose to faster bots.
Grab Phantom or Solflare. Fund it with 0.5-2 SOL for testing. Export your private? Yeah, but never share it. In my experience, use a burner wallet first - main one for when you're confident.
Now, create a new Solana keypair if you're paranoid. Run this in terminal:
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"solana keygen new --outfile ~/my wallet.json. Note the seed phrase.solana balance --keypair ~/my wallet.jsonThe thing is, bots sign tx with this. Mess up? Funds gone. Test on devnet first: solana airdrop 2 --url devnet.
Priority fee = your bribe for faster inclusion. Set it to 0.00025 SOL micro lamports usually. Too low? Stuck in mempool. I once lost 5k 'cause of 0 fee during a launch frenzy.
Telegram's perfect for this. Mobile control, notifications, no VPS hassle yet.
Done? Test by messaging your bot /start. Should reply. If not, token wrong.
I usually go Node 'cause Solana libs are mature. VS Code open? Let's roll.
mkdir solana bot && cd solana bot && npm init -ynpm i typescript ts node @solana/web3.js @solana/spl token bs58 dotenv node telegram bot api axios mongoose fs.env:BOTTOKEN=yourbotfather_tokenPRIVATEKEY=yourbase58privatekeyRPC_URL=https://api.mainnet beta.solana.com // Upgrade to Helius or Quicknode laterPotential issue: Free RPC throttles. Solution? Get a paid one like Chainstack Trader Node (~$50/mo for low latency). Why? Bots need <50ms response or you eat sandwich fees.
Here's the beating heart from my setup. index.ts file. It handles /start, snipe config, swaps via Jupiter (easiest aggregator).
import TelegramBot from 'node telegram bot api';
import { Connection, Keypair, PublicKey, Transaction } from '@solana/web3.js';
import bs58 from 'bs58';
import dotenv from 'dotenv';
dotenv.config(); const token = process.env.BOT_TOKEN!;
const bot = new TelegramBot(token, { polling: true }); const rpc = process.env.RPC_URL!;
const connection = new Connection(rpc, 'confirmed'); const privateKey = bs58.decode(process.env.PRIVATE_KEY!);
const wallet = Keypair.fromSecretKey(privateKey); let userConfigs = new Map(); // ChatId -> config bot.onText(/\/start/, (msg) => { const chatId = msg.chat.id; const config = { slippage: 50, // % amount: 0.1, // SOL priorityFee: 0.00025, jitoTip: 0.005, tp: null, // Take profit % sl: null // Stop loss % }; userConfigs.set(chatId, config); bot.sendMessage(chatId, Yo! Wallet: ${wallet.publicKey.toString()}\nUse /snipe <tokenaddress> to buy!, { replymarkup: { inlinekeyboard: [[{text: 'Settings', callbackdata: 'settings'}]] } });
}); bot.onText(/\/snipe (.+)/, async (msg, match) => { const chatId = msg.chat.id; const tokenAddr = match; const config = userConfigs.get(chatId) || {amount: 0.1, slippage: 50}; try { // Jupiter swap quote & tx const quoteUrl = https://quote api.jup.ag/v6/quote?inputMint=So11111111111111111111111111111111111111112&outputMint=${tokenAddr}&amount=${Math.floor(config.amount 1e9)}&slippageBps=${config.slippage 100}; const quote = await (await fetch(quoteUrl)).json(); const swapUrl = https://quote api.jup.ag/v6/swap; const swapRes = await fetch(swapUrl, { method: 'POST', headers: {'Content Type': 'application/json'}, body: JSON.stringify({ quoteResponse: quote, userPublicKey: wallet.publicKey.toString(), wrapAndUnwrapSol: true }) }); const { swapTransaction } = await swapRes.json(); // Deserialize, sign, send const tx = Transaction.from(Buffer.from(swapTransaction, 'base64')); tx.sign(wallet); const sig = await connection.sendRawTransaction(tx.serialize()); await connection.confirmTransaction(sig); bot.sendMessage(chatId, Snipe'd! Tx: ${sig}); } catch (e) { bot.sendMessage(chatId, Swap failed: ${e.message}); }
}); bot.on('callback_query', async (query) => { const chatId = query.message!.chat.id; if (query.data === 'settings') { bot.sendMessage(chatId, 'Set amount? Reply with SOL like 0.5'); // Add handlers for config updates.. } bot.answerCallbackQuery(query.id);
}); console.log('Bot running..');
Save as index.ts. Run: npx ts node index.ts. Boom, live. Test /snipe a real token like USDC.
Wait, errors? "Invalid keypair"? Check base58 encode. "RPC timeout"? Better endpoint. In my experience, add retries:
for (let i=0; i<3; i++) { try { / send tx / break; } catch { await new Promise(r=>setTimeout(r, 1000)); }
} Slippage at 50%? Fine for memes, risky for stables. Amount 0.1 SOL starts small. TP 2x, SL 20%? Set via buttons.
| Setting | Good For | My Default | Risks |
|---|---|---|---|
| Slippage | Volatile launches | 30-70% | Too high = sandwich |
| Priority Fee | Contested pools | 0.0005 SOL | Overpay = losses |
| Jito Tip | MEV bundles | 0.005 SOL | Skip = front run |
| Amount | Position size | 0.05-0.5 SOL | All in = wrecked |
Why Jito? Bundles your buy sell atomic, no sandwich. Integrate via their API - add to tx instructions.
Manual /snipe sucks for launches. Add a listener for new Raydium pools.
Hook Geyser gRPC or Yellowstone (Helius). But start simple: Poll Dexscreener API every 5s for new pairs.
// Poll new tokens
setInterval(async () => { const newTokens = await fetch('https://api.dexscreener.com/latest/dex/pairs/solana').then(r=>r.json()); newTokens.pairs.slice(0,5).forEach(async (pair: any) => { if (pair.age < 60) { // <1min old // Auto snipe if configured bot.telegram.sendMessage(YOUR_CHAT, /snipe ${pair.baseToken.address}); } });
}, 5000); Issue: Rate limits. Fix: Paid API keys. Sound familiar? Yeah, free tiers die quick.
Local run? Fine for tests. Live? Heroku free tier or Render ($7/mo).
heroku create my sol bot, git push heroku main.worker: npx ts node index.tsAWS EC2? Beefier, ~$50/mo t3.medium. Ubuntu 22.04, pm2 for process mgmt: npm i -g pm2; pm2 start "npx ts node index.ts" --name sniper.
Hardware note: Bot itself? Any laptop. But RPC node? 16-core CPU, 256GB RAM, NVMe if self hosting. Don't - use providers.
Tx fails? Simulate first: connection.simulateTransaction(tx). Logs everything.
Common crap:
Honestly, log to MongoDB for positions. Track PNL: Entry 0.1 SOL, exit 0.3 SOL = 200% win.
Add /refer @friend for 1% fee kickback. Track users in DB.
Auto TP/SL: After buy, monitor price via Birdeye API. If 2x, sell half.
// Pseudo
setInterval(checkPositions, 10000);
async function checkPositions() { // Fetch balances, compare to entry, swap if hit
} Multi wallet? Array of keypairs, rotate on fails.
In my experience, start with 0.05 SOL snipes. Scale after 10 wins. Bots wrecked me first time - over slippage ate 50%. Now? Consistent 5-20x flips weekly.
Private in .env? Gitignore it. VPS? Firewall ports, 2FA.
Restrict bot: Only your chatId. Check msg.from.id === YOUR_ID.