get_mempool_pending
Detect pending transactions for a token on Base to identify potential front-running opportunities in arbitrage scenarios.
Instructions
Check pending transactions for a token (front-run detection). Note: Base L2 has minimal public mempool exposure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_address | Yes | Token contract address on Base |
Implementation Reference
- src/index.ts:1327-1442 (handler)The tool 'get_mempool_pending' is registered and implemented in src/index.ts, which checks for pending transactions (or recent blocks as a proxy) for a given token address.
server.tool( "get_mempool_pending", "Check pending transactions for a token (front-run detection). Note: Base L2 has minimal public mempool exposure.", { token_address: z.string().describe("Token contract address on Base"), }, async ({ token_address }) => { try { const symbol = await getSymbol(token_address); // Base is an L2 with a sequencer - pending txs are not publicly visible // like on Ethereum mainnet. We can still check the pending block. let pendingTxs: Array<{ hash: string; from: string; to: string | null; value: string; involvesToken: boolean; }> = []; try { const pendingBlock = await provider.getBlock("pending", true); if (pendingBlock && pendingBlock.prefetchedTransactions) { const tokenLower = token_address.toLowerCase(); for (const tx of pendingBlock.prefetchedTransactions) { // Check if tx interacts with the token or known routers const isTokenDirect = tx.to?.toLowerCase() === tokenLower; const isRouter = tx.to?.toLowerCase() === UNIV2_ROUTER.toLowerCase() || tx.to?.toLowerCase() === UNIV3_QUOTER.toLowerCase() || tx.to?.toLowerCase() === AERO_ROUTER.toLowerCase(); // Check if tx data contains the token address (without 0x prefix) const dataContainsToken = tx.data && tx.data .toLowerCase() .includes(tokenLower.slice(2)); if (isTokenDirect || (isRouter && dataContainsToken)) { pendingTxs.push({ hash: tx.hash, from: tx.from, to: tx.to, value: ethers.formatEther(tx.value), involvesToken: true, }); } } } } catch { // Many Base RPC endpoints don't support pending block } // Also check recent confirmed blocks for rapid-fire activity (1-2 blocks) const currentBlock = await provider.getBlockNumber(); const recentActivity: Array<{ block: number; txCount: number; tokenTransfers: number; }> = []; for (let i = 0; i < 3; i++) { try { const block = await provider.getBlock(currentBlock - i, true); if (!block || !block.prefetchedTransactions) continue; let tokenTransfers = 0; const tokenLower = token_address.toLowerCase(); for (const tx of block.prefetchedTransactions) { if ( tx.to?.toLowerCase() === tokenLower || (tx.data && tx.data.toLowerCase().includes(tokenLower.slice(2))) ) { tokenTransfers++; } } recentActivity.push({ block: block.number, txCount: block.prefetchedTransactions.length, tokenTransfers, }); } catch { // Block fetch failed } } return { content: [ { type: "text" as const, text: JSON.stringify( { token: token_address, symbol, pendingTransactions: pendingTxs.length, pendingTxs, recentBlocks: recentActivity, note: "Base is an L2 with a centralized sequencer. The public mempool is minimal. Pending tx visibility is limited compared to Ethereum mainnet. Recent block activity is shown as a proxy for current trading intensity.", }, null, 2 ), }, ], }; } catch (e) { return { content: [ { type: "text" as const,