contract.watch

Use watch to listen for events emitted by a smart contract method. You can define functions to be executed when certain events are caught.

Usage

contract['event_name']().watch(callback)

Parameters

No need to pass parameters.

Returns

No return value.

Example

const contract = visionWeb
  .contract()
  .at('46f151d2b560d0f0a983cdbfc85fff392bb8874258');
contract['Transfer']().watch((err, event) => {
  if (err) {
    return console.error('Error with "method" event:', err);
  }
  if (event) {
    console.log('event:' + JSON.stringify(event));
    // do something
  }
});