I'm looking to get event logs for a smart contract and I'm using Infura nodes for this. According to the documentation provided here , I tried running
new_block_filter = web3.eth.filter('latest')
I think this should have been
new_block_filter = w3.eth.filter('latest')
where w3 should be something like
w3 = Web3(HTTPProvider("https://mainnet.infura.io/v3/infura-project-id"))
but there's an error in the documentation. Anyways I tried this which I believe is the simplest way to create a filter as well the methods mentioned here .
Both of these result in an error that looks like
Traceback (most recent call last): File "", line 1, in File "/home/username/.local/lib/python3.6/site-packages/web3/eth.py", line 333, in filter [filter_params], File "/home/username/.local/lib/python3.6/site-packages/web3/manager.py", line 112, in request_blocking raise ValueError(response["error"])
ValueError: {'code': -32601, 'message': 'The method eth_newFilter does not exist/is not available'}
Any ideas on how to create and use these filters and further how to get event logs for a smart contract when the topic parameter is known.
The error message means what it says. Infura doesn't support the RPC method eth_newFilter
over HTTPS, which is what your code ends up calling.
I believe the same code should work if you connect via WebSocket instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.