Search code examples
ethereumweb3pygo-ethereumganache

How to fix "the method txpool_inspect does not exist/is not available"


I'm having trouble getting the python function web3.geth.txpool.inspect() to work.

I've tried using a geth server from the command line, from the ethereum/client-go container, and from the trufflesuite/ganache-cli:v6.7.0 container.

In every case, I get a txpool_inspect method missing error. The code I'm running is very simple, using Python 3.7.5 or 3.8:

from web3 import Web3
thing = Web3("http://localhost:42424")
thing.geth.txpool.inspect()

I'm using web3py==5.2.2 .

For Geth I tried: --dev --mine --rpc --rpcaddr 0.0.0.0 --rpcport 42424 --verbosity 4 I tried a variety of other start up options as well, nothing seems to get me past the subject identified error that txpool_inspect doesn't exist or is missing.

I'd like to get this working for test/dev environments first before trying it on a real blockchain.

Suggestions?


Solution

    1. Initiate Web3 with HTTPProvider:

      from web3 import Web3, HTTPProvider
      thing = Web3(HTTPProvider("http://localhost:42424"))
      thing.geth.txpool.inspect()
      
    2. Run your node with rpcapi flag, for example:

      --http.api "eth,net,web3,txpool"