Watching events

One more important thing to take care of in your frontend is handling events. Your DApp should be able to listen for fired events by applying the function watch() to the expected event to detect changes, or get() to read a specific log. The following code shows an example of event watching:

var CanceledEvent = auction.CanceledEvent();
CanceledEvent.watch(function(error, result) {
if (!error) {
$("#eventslog").html(result.args.message + ' at ' + result.args.time);
}
});

Each time a new bid is received by the contract, the callback function will display the log.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset