current position:Home>Why is there a promise syntax error when it is written like this? It shows that the listener function is undecided. Obviously, a contract instance has been successfully introduced.

Why is there a promise syntax error when it is written like this? It shows that the listener function is undecided. Obviously, a contract instance has been successfully introduced.

2022-02-03 20:51:21 Q & A of Denglian community




Take the answer 1:

web3.js Of API There is a pit , The two versions are not compatible ,API It's different .

Event monitoring .watch yes 0.20 Version of API Interface , The document is here Monitor contract Events

1.0 Then listen to the event interface , Similar to the following :

myContract.events.MyEvent(function(error, event){ console.log(event); })

You can see file

also , The monitoring event should be carried out in the resident background , You can read Use Node.js Background monitoring contract events




copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032051186532.html

Random recommended