Ethereum mempool analyzer — detect whale transfers, gas price spikes, and MEV sandwich attacks in real-time from public blockchain data.
Zero API keys required. Uses public Ethereum RPC endpoints with automatic failover.
pip install mempool-analyzerOr clone and run directly:
git clone https://github.com/technicalanalysis00005-cell/mempool-analyzer.git
cd mempool-analyzer
python -m mempool_analyzer --blocks 5mempool-analyzermempool-analyzer --whale 10 --blocks 20mempool-analyzer --block 19000000mempool-analyzer --json | jq '.whale_transfers'mempool-analyzer --watch --whale 50mempool-analyzer --rpc https://mainnet.infura.io/v3/YOUR_KEY============================================================
MEMPOOL ANALYZER — ETHEREUM
============================================================
Scanned at 2024-12-15 14:30:22 UTC
▸ Network Overview
──────────────────────────────────────────────────
Block: #19,456,789
Base Fee: 28.5 gwei
Gas Price: 31.2 gwei
Pending Txs: N/A (node doesn't expose txpool)
Blocks Scanned: 10
Avg Block Time: 12.1s
Avg Txs/Block: 142
Avg Gas Used: 52.3%
▸ Whale Transfers (2 detected)
500.0 ETH 0x1234...5678 → 0xabcd...ef01 block #19456785
tx: 0xdef456... | gas: 35.0 gwei
150.0 ETH 0x9876...5432 → 0x1111...2222 block #19456783
tx: 0xabc123... | gas: 28.0 gwei
▸ Gas Spikes
No abnormal gas prices detected
▸ MEV Sandwich Detection
No sandwich patterns detected in scanned blocks
Scans all transactions in recent blocks for ETH transfers above the configured threshold. Reports sender, receiver, value, and gas price.
Compares each block's maximum gas price against the rolling average. Flags blocks where max gas exceeds average * spike_multiplier. Default multiplier is 2.0x.
Heuristic pattern matching:
- Groups transactions by block
- Filters for known DEX router interactions (Uniswap V2/V3, SushiSwap, 1inch, 0x)
- Looks for 3-transaction patterns where the same address appears before and after a different address's swap
- Known routers: Uniswap V2, V3, SushiSwap, 1inch V4/V5, 0x Exchange
- Zero dependencies — pure Python 3.8+ stdlib
- Public RPCs — no API key needed (Cloudflare, Ankr, LlamaNodes, 1RPC, dRPC)
- Automatic failover — tries multiple endpoints on failure
- Colored output — auto-disables when piped
- JSON output — for piping into
jqor other tools - Watch mode — continuous monitoring with ~12s refresh
- Configurable thresholds — whale amount, gas spike multiplier, block count
from mempool_analyzer.rpc import EthereumRPC
from mempool_analyzer.detector import MempoolAnalyzer
rpc = EthereumRPC() # Uses public endpoints
analyzer = MempoolAnalyzer(rpc, whale_threshold_eth=50)
snapshot = analyzer.scan_recent_blocks(count=15)
for whale in snapshot.whale_transfers:
print(f"{whale.value_eth} ETH: {whale.from_addr} -> {whale.to_addr}")
for spike in snapshot.gas_spikes:
print(f"Block #{spike.block}: max {spike.max_gas_price_gwei} gwei")| Flag | Short | Default | Description |
|---|---|---|---|
--rpc |
-r |
auto | Ethereum RPC endpoint URL |
--blocks |
-b |
10 | Number of recent blocks to scan |
--whale |
-w |
100.0 | Whale threshold in ETH |
--spike-mult |
-s |
2.0 | Gas spike multiplier vs average |
--block |
-B |
- | Analyze specific block number |
--json |
-j |
false | JSON output |
--watch |
-W |
false | Continuous monitoring |
--no-color |
- | false | Disable colored output |
MIT