Problem with server side call to Ethereum node


#1

I try to interact with Ethereum node via web3 lib. (meteor add ethereum:web3)

Meteor 1.5.4.1

lib.js

if (typeof web3 === ‘undefined’){
web3 = new Web3(new Web3.providers.HttpProvider(‘http://127.0.0.1:21045’));
}

main.js

web3.eth.defaultContractEvent = “0x*************************************”;
contract_event = web3.eth.contract(abi_event).at(web3.eth.defaultContractEvent);
var events = contract_event.allEvents({fromBlock: 0, toBlock: ‘latest’});


get error at last line

C:\Users***\AppData\Local.meteor\packages\meteor-tool\1.5.2_2\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:280
throw(ex);
^

TypeError: XHR2 is not a function
at [object Object].HttpProvider.prepareRequest (packages\ethereum_web3.js:4315:15)
at [object Object].HttpProvider.sendAsync (packages\ethereum_web3.js:4364:22)
at [object Object].RequestManager.sendAsync (packages\ethereum_web3.js:6369:19)
at Object.send [as newFilter] (packages\ethereum_web3.js:5080:42)
at new Filter (packages\ethereum_web3.js:3568:25)
at [object Object].AllSolidityEvents.execute (packages\ethereum_web3.js:2716:12)

at server/main.js:135:30

at Function.time (C:\***\.meteor\local\build\programs\server\profile.js:309:28)
at C:\***\.meteor\local\build\programs\server\boot.js:348:13
at C:\***\.meteor\local\build\programs\server\boot.js:389:5

Exited with code: 1

what is the problem?


#2

This might be similar to a problem I was having. I think your issue might be specific to the version of web3 that you are using. Feel free to take a look at my SO question: Missing Web3 Meteor Server