Currently I'm unable to find a working solution. Let's say I have the following smartcontract:
contract Manufacturer {
event LogNewOrder(string order);
string[] public orders;
function addOrder(string newOrder) public {
orders.push(newOrder);
emit LogNewOrder(newOrder);
return;
}
}
If a third party calls the method addOrder(newOrder)
, the manufacturer should be informed about, because he must perform things. What is the best method with web3 to listen to events? If I do something like this:
instance.events.allEvents({ fromBlock: 0 })
.on('data', function(event){
console.log(event);
})
.on('changed', function(event){
console.log(event);
})
.on('error', console.error);
then nothing happens.