流星服务器端调用以太坊节点

时间:2018-01-31 09:28:07

标签: meteor ethereum

我尝试通过web3 lib与以太坊节点进行交互。 (meteor add ethereum:web3)

流星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’});

在最后一行得到错误

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

退出代码:1

问题是什么?

0 个答案:

没有答案