web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Events are not working in 0.20.x (requestsmanager is undefined)

Open AleG94 opened this issue 8 years ago • 3 comments

This simple code is not working in 0.20.7 and also in 0.20.4 (only 2 that I tested).

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("change to infura api"));
var contract = new web3.eth.contract(abi).at(address);
var events = contract.allEvents();

This gives:

C:\Users\user\Desktop\test\node_modules\web3\lib\web3\method.js:141
            return method.requestManager.sendAsync(payload, function (err, result) {
                                         ^

TypeError: Cannot read property 'sendAsync' of undefined
    at Object.send [as newFilter] (C:\Users\alege\Desktop\dio\node_modules\web3\lib\web3\method.js:141:42)
    at new Filter (C:\Users\alege\Desktop\dio\node_modules\web3\lib\web3\filter.js:156:25)
    at AllSolidityEvents.execute (C:\Users\alege\Desktop\dio\node_modules\web3\lib\web3\allevents.js:79:12)
    at Object.<anonymous> (C:\Users\alege\Desktop\dio\index.js:14:23)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)`

AleG94 avatar Oct 11 '18 17:10 AleG94

As mentioned here : https://github.com/ethereum/wiki/wiki/JavaScript-API#parameters-34 It seems you need to define some filter parameters too.

Aniket-Engg avatar Nov 20 '18 08:11 Aniket-Engg

Please check if Infura actually supports this request type. As far as I know Infura doesn't support all filter related functions via http.

digitaldonkey avatar Dec 01 '18 17:12 digitaldonkey

Version 0.20.x got his last maintenance release with v0.20.7. Please update your code to the latest 1.0 version of Web3.js. Further details about the current project state are explained in the release announcement of version 1.0.0-beta.38.

nivida avatar Mar 25 '19 19:03 nivida