From the web3 documentation: https://web3js.readthedocs.io/en/1.0/web3-eth-subscribe.html I use this code sample:

var subscription = web3.eth.subscribe('logs', {
    address: '0x123456..',
    topics: ['0x12345...'] }, function(error, result){
    if (!error)
        console.log(log);
});

and I got this error:

TypeError: web3.eth.subscribe is not a function

is "subscribe" deprecated ? Is there a replacement for it ?

up vote 3 down vote accepted

The documentation you are referring to says -

This documentation is work in progress and web3.js 1.0 is not yet released! You can find the current documentation for web3 0.x.x at github.com/ethereum/wiki/wiki/JavaScript-API.

That is the reason you are getting this error, you can follow this link for web3 js latest documentation.

Hope this helps.

also address must be a contract address and not an account https://github.com/ethereum/web3.js/issues/1752#issuecomment-404385542

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.