txpool
The txpool namespace provides methods for inspecting and managing the transaction pool (mempool) in Erigon. These methods allow you to view pending and queued transactions, providing insight into the current state of unconfirmed transactions. In Erigon, the txpool namespace is implemented through the TxPoolAPI interface and TxPoolAPIImpl struct.
The TxPool namespace must be explicitly enabled using the --http.api flag when starting the RPC Daemon. These methods are particularly useful for monitoring transaction pool status and debugging transaction submission issues.
Transaction Pool Architecture
- Erigon's transaction pool is organized into three sub-pools: pending (executable), baseFee (insufficient base fee), and queued (nonce gaps)
- The
txpool_content,txpool_contentFromandtxpool_statusmethods expose only thependingandqueuedcategories, as defined by theethereum/execution-apisspecification. Transactions in the internal baseFee sub-pool are nonce-ready and otherwise valid, but are not executable at the current base fee: they wait for the fee condition to change. They are reported as pending, matching Geth - Blob transactions (type 3) are not reported by
txpool_contentandtxpool_contentFrom, matching Geth and Nethermind. They are still counted bytxpool_status - The pool can run either integrated within the main Erigon process or as a separate service for scalability
- Transaction pool methods communicate via gRPC with the TxPool service when running in external mode
Implementation Details
- The
TxPoolAPIImpluses aproto_txpool.TxpoolClientto communicate with the transaction pool service - All transactions are decoded from RLP format and converted to
ethapi.RPCTransactionobjects for JSON-RPC responses - The implementation handles transaction categorization based on the
TxnTypefield from the pool service
External vs Internal Mode
- Internal Mode: Transaction pool runs within the main Erigon process (default configuration)
- External Mode: Transaction pool runs as a separate service, requiring explicit configuration with
--txpool.api.addr. External mode requires an external Sentry service and provides better resource isolation
Usage in Development and Testing
- These methods are commonly used for monitoring transaction submission and pool state
- The
txpool_statusmethod provides quick insight into pool health and congestion - Transaction pool content methods help debug why transactions may not be getting mined
Configuration and Limits
- Transaction pool limits can be configured via flags like
--txpool.globalslots,--txpool.globalbasefeeslots, and--txpool.globalqueue - The pool supports various transaction types including blob transactions with separate limits
- Pool configuration is managed through the
txpoolcfg.Configstructure
Availability
- The
txpoolnamespace is available when included in the--http.apiflag - Methods are marked as "remote" in the documentation, indicating they communicate with external services
- All
txpoolmethods are available on both HTTP and WebSocket connections
txpool_content
Returns the content of the transaction pool, organized by sender address and categorized into pending and queued transactions. Blob transactions are not returned.
Parameters
None
Example
curl -s --data '{"jsonrpc":"2.0","method":"txpool_content","params":[],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
Returns
| Type | Description |
|---|---|
| Object | Transaction pool content organized by sub-pool type |
| pending | Object |
| queued | Object |
txpool_contentFrom
Returns the content of the transaction pool for a specific sender address, categorized into pending and queued transactions. The same rules as txpool_content apply.
Parameters
| Parameter | Type | Description |
|---|---|---|
| address | DATA, 20 BYTES | The sender address to query transactions for |
Example
curl -s --data '{"jsonrpc":"2.0","method":"txpool_contentFrom","params":["0xb60e8dd61c5d32be8058bb8eb970870f07233155"],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
Returns
| Type | Description |
|---|---|
| Object | Transaction pool content for the specified address |
| pending | Object |
| queued | Object |
txpool_status
Returns the current status of the transaction pool, with the count of pending and queued transactions.
Parameters
None
Example
curl -s --data '{"jsonrpc":"2.0","method":"txpool_status","params":[],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
Returns
| Type | Description |
|---|---|
| Object | Transaction pool status counts |
| pending | QUANTITY |
| queued | QUANTITY |