如何通过Infura(2019年末)在Python中收听事件?

时间:2019-11-17 04:35:02

标签: python websocket ethereum web3

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

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

1 个答案:

答案 0 :(得分:0)

感谢web3.py指出Infura websocket 确实支持createFilter,对此我已经通过测试进行了确认。

github上的问题已更新-

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