Build a Custom Mempool Monitoring Bot for Ethereum and L2
In the Ethereum public mempool, eth_subscribe("newPendingTransactions") reveals only a small fraction of transactions. Private transactions from Flashbots and MEV Blocker remain invisible. For a DeFi protocol dependent on liquidations or gas analytics, this is a blind spot. A custom mempool bot with access to the txpool API gives the full picture: it sees 90–100% of pending transactions, including those sent via private channels. We design such bots turnkey — from node selection to deployment with a metrics dashboard.
Own Node vs. Public RPC
Public RPC via eth_subscribe("newPendingTransactions") shows only broadcast transactions — private ones (Flashbots, MEV Blocker) are not visible. Running your own Geth node with txpool API provides a complete snapshot: txpool_content displays all pending and queued transactions passing through your node. For latency-critical tasks, colocation with major validators (Equinix, Amsterdam) reduces latency to 10–50 ms versus 200 ms on public RPC — that is a 4x improvement. Our colocation setup reduces latency by 4x compared to public RPC.
| Access Level | Transaction Visibility | Typical Latency | Complexity |
|---|---|---|---|
| Public RPC | 30–60% (broadcast only) | 150–400 ms | Low |
| Own node (txpool) | 90–100% (p2p) | 50–150 ms | Medium |
| Colocation + peering | 100% (including Flashbots if partnered) | 10–50 ms | High |
An own node sees 3x more transactions than public RPC. For a bot monitoring liquidations, this is the difference between a profitable trade and a missed opportunity.
How to Decode Transactions in Real Time?
A raw transaction is bytes. To understand what it does, decode the calldata via ABI. For well-known protocols (Uniswap, Aave, Curve), we use preloaded interfaces. For unknown ones, we query 4byte.directory: send the selector (first 4 bytes) and get the function signature. Typical decoding code for Uniswap V3 exactInputSingle:
const uniV3Iface = new Interface(UNISWAP_V3_ABI); function decodeUniswapTx(tx: ethers.TransactionResponse): DecodedSwap | null { if (!tx.data || tx.data === '0x') return null; const selector = tx.data.slice(0, 10); if (selector === '0x414bf389') { const decoded = uniV3Iface.decodeFunctionData('exactInputSingle', tx.data); return { tokenIn: decoded.params.tokenIn, tokenOut: decoded.params.tokenOut, amountIn: decoded.params.amountIn }; } return null; } Which Scenarios Bring the Most Profit?
Different tasks require different levels of mempool access. Compare them by latency and complexity:
| Scenario | Required Access Level | Expected Latency | Gas Savings |
|---|---|---|---|
| Liquidation bot (Aave) | Own node + txpool | <100 ms | 20–30% on priority |
| Sandwich detection | Public RPC or own node | <500 ms | — (protection) |
| Gas price forecasting | Own node + snapshots | <50 ms (periodic) | 10–15% average |
Liquidation bot. Monitor positions on Aave/Compound; catch Chainlink price update transactions in the mempool. Decode the new price, simulate liquidation via local eth_call. If found, send a liquidation with increased maxFeePerGas to beat the oracle. Average gas savings: 30% due to priority queue. Typical gas savings: $50–$100 per liquidation compared to standard gas.
Sandwich detection. Parse pending transactions for DEX swaps. If two transactions target the same pool—first with high gas (frontrun), second victim—the system alerts the operator or automatically blocks the protocol. Implemented via a map of pending hash to swap details.
Gas price forecasting. Take a txpool_content snapshot, analyze maxFeePerGas distribution. Compute p50, p75, p95 — this predicts the next base fee within 15% accuracy. Used to send non-urgent transactions at optimal gas prices.
What's Included?
- Architecture: design of a high-load system (Redis Streams + Worker Pool + Execution Engine).
- Development: decoding modules, filters (by address, signature, gas), alerting system.
- Deployment: configure own node (Geth/Reth) with optimal peering, latency monitoring.
- Documentation: API description, run instructions, metrics dashboard.
- Support: 14 days post-launch for adjustments.
Detailed Work Plan:
- Analysis (2 days): discuss the task — liquidations, analytics, anti-sandwich, MEV. Define SLA for latency, transaction volume.
- Design (3 days): choose stack (Geth/Reth, Foundry, ethers.js, Redis), draw queue architecture.
- Implementation (5–15 days): write decoding modules, filters, execution engine. End-to-end testing on shadow node.
- Test (3 days): simulate load of 300+ tx/s, measure latency, catch regressions.
- Deployment (2 days): node setup, monitoring, documentation.
Our engineers have 6+ years in blockchain development. We have completed 27+ projects on MEV, mempool analysis, and decentralized protocols. We guarantee transparency: all code undergoes internal audit and formal verification (Slither, Mythril).
Process and Timelines
Final timeline: from 2 to 8 weeks depending on complexity. Cost is determined individually after a task audit. Own node setup costs around $500/month for a colocated server. Request a consultation — we assess the scope of work for free.
Sources
- Ethereum Mempool — official documentation.
- Flashbots MEV-Boost — MEV-Boost specification.
Get a detailed proposal for your scenario — contact us.







