Fantom
eth_newPendingTransactionFilter
The eth_newPendingTransactionFilter method creates a filter in the node to notify when new pending transactions are received in the mempool. This allows applications to monitor the transaction mempool without continuously polling, helping you track transactions before they're included in blocks.
Use Cases
- Mempool monitoring and analysis for research
- Front-running detection in trading applications
- Gas price optimization for transaction submission
- Transaction confirmation tracking in wallets
- Market sentiment analysis for trading strategies
- DEX trading monitoring for arbitrage opportunities
- Network congestion monitoring for gas fee estimation
- MEV (Miner Extractable Value) research and exploitation
- Detecting large token transfers before confirmation
- Monitoring smart contract interactions in real-time
Method Details
This method takes no parameters and returns a filter ID that can be used with eth_getFilterChanges to poll for new pending transactions.
Response Example
How Pending Transaction Filters Work
- When you create a pending transaction filter, the Ethereum node assigns it a unique ID
- The node tracks which transactions it has already reported to your filter
- When you poll using
eth_getFilterChanges, it returns transaction hashes for any new pending transactions since your last poll - If no new transactions have been received, it returns an empty array
Return Value Format
When polling with eth_getFilterChanges, this filter returns an array of transaction hashes:
Transaction Data Retrieval
The filter only returns transaction hashes. To get the full transaction data, you must make additional calls using:
eth_getTransactionByHash- Get a transaction's details using its hash
Important Considerations
- High Volume: The Ethereum mempool can be extremely active, producing hundreds of transactions per minute
- Filter Expiration: Filters expire after a period of inactivity (typically around 5 minutes)
- Rate Limits: Due to the high volume, polling too frequently might lead to rate limiting
- Missing Transactions: Very short-lived pending transactions might be missed between polls
- Resource Intensive: This filter can be resource-intensive for both the client and the node
- Not For Production: Many production applications should use WebSocket subscriptions instead
- Transaction Status: Pending transactions might never be mined or may be replaced
- Node Implementation: Some nodes might limit the number of pending transactions they track
- Data Volume: During high activity periods, this filter may return hundreds of transactions per poll
- Transaction Privacy: Some nodes may not reveal all pending transactions in their mempool
Mempool Analysis Applications
Monitoring pending transactions can reveal valuable insights:
- Gas Price Trends: Analyze current market rates for transaction fees
- Network Congestion: Assess current network load
- Token Movements: Detect large token transfers before they're confirmed
- Smart Contract Interactions: Monitor interactions with specific contracts
- Arbitrage Opportunities: Detect price discrepancies between exchanges
- Market Sentiment: Gauge market activity during volatile periods
- Front-running Protection: Monitor for transactions that might front-run yours
Comparison with Other Notification Methods
| Method | Purpose | Results | Best For |
|---|---|---|---|
eth_newPendingTransactionFilter | Notifies about pending transactions | Array of transaction hashes | Mempool monitoring |
eth_newBlockFilter | Notifies about new blocks | Array of block hashes | Block-level monitoring |
eth_newFilter | Notifies about specific log events | Array of log objects | Event-based applications |
WebSocket eth_subscribe | Push notifications (no polling) | Varies by subscription type | Real-time applications |
See also
- eth_getFilterChanges - Retrieve new transaction hashes since last poll
- eth_uninstallFilter - Remove a filter when no longer needed
- eth_getTransactionByHash - Get transaction details by hash
- eth_newFilter - Create a filter for event logs
- eth_newBlockFilter - Create filter for new blocks