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

2

5

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?

Prayer answered 30/10, 2019 at 19:20 Comment(1)
The error is being thrown by the web3 server - if I didn't make that clear.Prayer
L
14
  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"
    
Loon answered 6/11, 2019 at 7:46 Comment(0)
C
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"
Chiastic answered 16/7, 2020 at 14:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.