尝试在私人以太坊区块链上订阅事件时,我会收到以下错误消息:
无法读取未定义的属性
Web3的设置:
const Web3 = require("web3");
this.web3 = new Web3(Web3.givenProvider || "ws://localhost:8545");
作品:
this.factoryContract.getPastEvents(
"allEvents",
{
fromBlock: 0,
toBlock: "latest"
},
(err, events) => {
console.log(events);
}
);
引发错误:
this.factoryContract.events
.allEvents(
{
fromBlock: 0
},
(error, event) => {
console.log(event);
}
)
.on("data", event => {
console.log(event);
});
this.factoryContract.events
.TaskCreated(
{
fromBlock: 0
},
(error, event) => {
console.log(event);
}
);
有什么想法如何解决该/错误是什么?
节点版本:10.14.2
Web3:1.0.0
此问题是当前Web3 1.0.0.51版本的问题,应该在下一个版本中修复。https://github.com/ethereum/web3.js/releases