4

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?

TylerH
  • 20,799
  • 66
  • 75
  • 101
rotten
  • 1,580
  • 19
  • 25

2 Answers2

11
  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"
    
TylerH
  • 20,799
  • 66
  • 75
  • 101
StillFantasy
  • 1,677
  • 9
  • 21
3

@StillFantasy's answer is correct. I'm just updating to current geth's version

as --rpcapi is deprecated use --http.api flag.

Like:

--http.api "eth,net,web3,txpool"
TylerH
  • 20,799
  • 66
  • 75
  • 101
Abu Hanifa
  • 2,857
  • 2
  • 22
  • 38