如何使用 Infura(2019 年底)收听 Python 中的事件?

How to listen for events in Python with Infura (2019 year end)?

web3py 5.3.0 最新文档给出了 eventFilter 的例子 --

https://web3py.readthedocs.io/en/latest/contracts.html#event-log-object

transfer_filter = my_token_contract.eventFilter('Transfer', 
    {'filter': {'_from': '0xDc3A9Db694BCdd55EBaE4A89B22aC6D12b3F0c24'}})

导致错误--

*** AttributeError: 'Contract' object has no attribute 'ContractEvents'

虽然我在 github 上向 web3.py 提出了这个问题 --

https://github.com/ethereum/web3.py/issues/1508

有人可以分享在 Python 中使用不支持 createFilter 的 Infura websocket 监听以太坊事件的工作示例吗?

感谢 web3.py 的 kclowes 指出 Infura websocket 确实支持 createFilter,我已经通过测试确认了这一点。

github 上的问题已更新 --

https://github.com/ethereum/web3.py/issues/1508