DEV Community

TateLyman
TateLyman

Posted on

I Built a Solana Trading Bot for Telegram — Here's How It Works

I built a full-featured Solana trading bot for Telegram

After studying how bots like BONKbot, Trojan, and Maestro work, I built my own from scratch in Node.js. It does everything the big bots do:

  • Instant token trading — Buy and sell any Solana token via Jupiter aggregator
  • One-tap buying — Paste any contract address, get instant buy buttons
  • Copy trading — Mirror any whale wallet's trades automatically
  • DCA automation — Dollar-cost average into any token on a schedule
  • New token alerts — Get notified when new tokens launch
  • Limit orders, stop-loss, take-profit — Full order management
  • Safety scanner — Check any token for rug pull risks before buying
  • PnL tracking — See your profit/loss on every position
  • Referral system — Share your link, earn 10% of your referrals' trading fees

The tech stack

  • Pure Node.js (no frameworks)
  • Telegram Bot API with inline keyboards
  • Solana web3.js for on-chain transactions
  • Jupiter V6 API for token swaps
  • DexScreener API for new token detection
  • CoinGecko + Jupiter for live pricing

How the swap works

// 1. Get quote from Jupiter
const quote = await fetch(
  `https://quote-api.jup.ag/v6/quote?inputMint=SOL&outputMint=${mint}&amount=${lamports}`
);

// 2. Get swap transaction
const swapTx = await fetch('https://quote-api.jup.ag/v6/swap', {
  quoteResponse: quote,
  userPublicKey: wallet.publicKey
});

// 3. Deserialize, sign, send
const tx = VersionedTransaction.deserialize(Buffer.from(swapTx, 'base64'));
tx.sign([wallet.keypair]);
await connection.sendRawTransaction(tx.serialize());
Enter fullscreen mode Exit fullscreen mode

Copy trading detection

The bot snapshots a target wallet's token holdings every 60 seconds. When a new token appears (buy) or disappears (sell), it replicates the trade:

// Compare current vs previous snapshot
for (const [mint, amount] of Object.entries(currentTokens)) {
  if (!prevSnapshot[mint]) {
    // New token detected — copy buy!
    await handleBuy(chatId, mint, solPerTrade);
  }
}
Enter fullscreen mode Exit fullscreen mode

Try it

@solscanitbot on Telegram — free to use, 1% trading fee (0.9% with referral).

Also check out DevTools.run — 22 free browser-based developer tools including Solana wallet checker and token scanner.


Built by @tatelyman. Tips: NaTTUfDDQ8U1RBqb9q5rz6vJ22cWrrT5UAsXuxnb2Wr (SOL)

Top comments (0)