【问题标题】:How to listen for events in Python with Infura (2019 year end)?如何使用 Infura(2019 年底)在 Python 中监听事件?
【发布时间】:2020-03-12 19:37:01
【问题描述】:

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 使用 Infura websocket(不支持 createFilter)中监听以太坊事件的工作示例吗?

【问题讨论】:

    标签: python websocket ethereum web3


    【解决方案1】:

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

    github上的issue已经更新了--

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-05
      • 2014-12-06
      • 2011-12-20
      • 1970-01-01
      相关资源
      最近更新 更多