Real-time detection of new ERC-20 token launches on EVM chains. Listens to PairCreated events from major DEX factory contracts via WebSocket, fetches token metadata, and prints structured launch reports to stdout the moment a pair is created.
This is an educational template, not a trading bot. There is no buy logic, no wallet integration, no execution. Use it as a starting point to understand how on-chain real-time detection works.
git clone https://github.com/swiftnodes/sniper-bot-template
cd sniper-bot-template
cp .env.example .env # add your SwiftNodes API key
npm install
CHAIN=base npm startOutput looks like:
[2026-05-13T14:23:11.501Z] BaseSwap
New token: $PEPE (Pepe Coin)
Address: https://basescan.org/address/0x1234...
Paired w: WETH (0x4200...0006)
Supply: 1,000,000,000,000 $PEPE
Pair: https://basescan.org/address/0xabcd...
Tx: https://basescan.org/tx/0xdead...
Five chains out of the box, each watching multiple DEX factories:
| Chain | DEX factories watched |
|---|---|
| Ethereum | UniswapV2, SushiswapV2 |
| Base | UniswapV2, BaseSwap, Aerodrome |
| BNB Smart Chain | PancakeV2, BiswapV2 |
| Arbitrum One | Camelot, SushiswapV2 |
| Polygon | QuickSwap, SushiswapV2 |
Add more chains or factories in src/chains.js — it's a single config object.
src/
chains.js ← Per-chain config: WebSocket URL, factory contracts, quote tokens
index.js ← Subscribes to PairCreated logs, fetches token metadata, prints
Single-file design. Roughly 100 lines of actual logic. Read the source — there's nothing magic.
- Connect to a chain's WebSocket RPC endpoint (SwiftNodes'
wss://rpc.swiftnodes.io/ws/{chain}). - Subscribe to
PairCreated(token0, token1, pair, uint256)event logs from each configured factory contract. - When a log arrives, identify the "new" token — the one that isn't a known quote token (WETH, USDC, USDT, etc.).
- Fetch ERC-20 metadata (
name,symbol,decimals,totalSupply) via paralleleth_callreads. - Print a structured report with explorer links.
Total latency from on-chain pair creation to printed report: typically 200ms to 1.5s, depending on network and WebSocket subscription depth.
Visit swiftnodes.io, connect a wallet (no email, no KYC), and grab your API key. Free tier covers most use cases.
cp .env.example .envEdit .env:
SWIFTNODES_API_KEY=sn_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456
CHAIN=basenpm install
npm start # uses CHAIN from .env
CHAIN=bsc npm start # override per-runOr use the convenience scripts:
npm run watch:base
npm run watch:bsc
npm run watch:ethEdit src/chains.js:
export const CHAINS = {
// ... existing chains ...
optimism: {
name: "Optimism",
wsUrl: ws("optimism"),
nativeSymbol: "ETH",
explorerTx: "https://optimistic.etherscan.io/tx/",
explorerAddr: "https://optimistic.etherscan.io/address/",
factories: [
{ name: "Velodrome", address: "0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a" },
],
quoteTokens: {
WETH: "0x4200000000000000000000000000000000000006",
},
},
};SwiftNodes supports 75+ chains — see the full list at swiftnodes.io/docs/supported-chains.
Many "launches" are honeypots or scams. Add filters before printing:
// In index.js, inside onLogs:
if (!meta.symbol || meta.symbol.length > 12) continue; // skip nonsense
if (meta.totalSupply > 10n ** 30n) continue; // skip absurdly-supplied
if (!quoteToken) continue; // skip non-USD-pairedRead additional contract state:
// Check if owner is renounced (set to 0x0)
const owner = await client.readContract({
address: newToken,
abi: [parseAbiItem("function owner() view returns (address)")],
functionName: "owner",
}).catch(() => null);
// Check if there's a hidden transfer fee, max wallet, etc. — these are usually
// only visible by reading the contract source / bytecode, not state.Replace console.log(...) with HTTP POSTs to your bot's webhook URL.
WebSocket subscriptions are essential for real-time event detection. SwiftNodes:
- WebSocket support on every plan including free tier
- 75+ chains — multi-chain bots without juggling 5 different providers
- No-KYC signup — sensible for hobbyist/educational projects
- Health-checked failover — your subscription stays connected even when individual upstream nodes go down
For production sniping with actual capital at risk, you'd want a paid tier (or multiple providers in parallel) for redundancy and lower latency.
Educational use only. Memecoin sniping carries serious risks:
- Most new tokens are scams, honeypots, or rug pulls
- Even legitimate launches can dump 90%+ within minutes
- Front-running bots will routinely beat you to good entries
- Profitable sniping requires actual edge — being fast alone is not enough
- This template intentionally has no buying logic because writing one without proper risk management is a way to lose money quickly
If you do extend this into a real trading bot, study honeypot detection, slippage protection, gas optimization, and execution timing before risking funds.
MIT — fork, modify, ship.
PRs welcome for:
- Additional chains / factory addresses
- Better metadata fetching (LP balance, top holders, etc.)
- Honeypot detection heuristics
- Notification integrations (Telegram, Discord, webhook)