I am trying to understand the difference among following cases while printing the event: At web3.js
listenToEvent: function(){ Contract.deployed().then(function(instance){ instance.HelloWorld().watch(function(error, event){ document.getElementById("demo").innerHTML += JSON.stringify(event); console.log(event); //1. It is not working console.log(event.args); // 2. It is giving all arguments console.log(event.args.name); // 3. It is not working }); }); },
- console.log(event); //1. It is not working
- console.log(event.args); // 2. It is giving all arguments
- console.log(event.args.name); // 3. It is not working; here name is the first argument in the event.
My question is If the object can't be print then why it is working for 2nd condition and if it is working then why it is failing for 3rd.
To access the arguments we can use this: console.log(JSON.stringify(event.args.name));
While printing the event console.log(JSON.stringify(event)); It gives the transaction details too, how to get that?
Appreciate any help in advance.