reactjs - web3 订阅事件触发两次
问题描述
我有一个使用 web3 的简单事件订阅:
contract.events.EventName().on('data', async event => {console.log(event)})
但由于某种原因,该事件使用 web3 触发了两次(换句话说,在此示例中该事件被记录了两次),即使该事件仅在区块链上触发一次。
这也发生在 getPastEvents 上:
contract.getPastEvents("Event").then(events => console.log(events))
contract.getPastEvents("Event").then(console.log('a'))
奇怪的是,第一次发射了两次,第二次只发射了一次
解决方案
推荐阅读
- excel - 如何更改超链接的名称?
- android - 迁移到应用中心后无法发布静默应用更新,带我去微软页面注册
- sql - 在SQL中的字符串中的两个字符之间选择一个字符串
- linux - 如何从 /bin 的随机选择中调用带有程序名称的 whatis 命令?
- tensorflow - 保存和恢复自定义模型 tensorflow
- javascript - 如何将两个数组的值传递给 Javascript 函数中的标识符?
- java - 如何每隔 s 秒调用一次方法
- python - 如何使用 Python 中的 Arduino 和 Tkinter 根据给定时间输入一个时间表,其中将在其中打开和关闭
- python - Jupyter 安装错误:命令错误退出状态为 1
- tensorflow - 我应该对 3D 灰度图像使用 2D 还是 3D 卷积?