I am looking for a subscribe function in web3py like the one implemented in web3js:
web3.eth.subscribe('newBlockHeaders' [, callback]);
As there currently is no implementation of it in web3py, has anyone an idea on a possible implementation or some resources on it?
Best Answer
web3.py doesn't have a native implementation of watchers like web3.js. your only option is to connect to the exposed websocket like follows:
Note that the
subscription_response
will have a subscription id that you can use to cancel the subscription. you can find all jsonRPC methods form the docs