0

This question already has an answer here:

It seems that I do not have access to certain tools in web3js that allow me to subscribe to events.

When I tried to use contractInstance.once('allEvents', callback) after instantiating a contract, I get the following:

TypeError: contractInstance.once is not a function`

This is confusing to me because web3.version.api returns '0.20.7'. And according to the web3.js documentation, I should be able to access once.

Although I cannot use once, I can watch events using the following code:

contractInstance.nameOfEvent((error, result) => {console.log(result)})

Any suggestions on how I can access once?

marked as duplicate by Richard Horrocks, shane, alberto, Ismael, Achala Dissanayake Aug 6 at 19:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The documentation you've pointed to is for version 1.2.0. You're running version 0.20.7. – Richard Horrocks Aug 1 at 15:36

Browse other questions tagged or ask your own question.