0

I want to connet my meteor localhost to ropsten testnet. Therefore i have a lib.js with the connecting commands:

//var Web3 = require('web3'); if (typeof web3 !== 'undefined') { web3 = new Web3(web3.currentProvider); } else { // set the provider you want from Web3.providers web3 = new Web3(new Web3.providers.HttpProvider("http://ropsten.infura.io/..."));
if(!web3.isConnected()) console.log("not connected"); else console.log("connected"); }

A time out msg appears. I read about the var Web3 = require('web3'); But when i add this line i also get a error msg for missing modules. How can i get this run?

0

You need to install Web3, and add the

var Web3 = require('web3');

4
  • it solved the problem, but now i get web3.isConnected is not a function. I got the 1.0.0 beta version of web3
    – TimRicta
    Sep 26 '17 at 11:20
  • Please remove your private infura key from your last comment. Also, try if( false === web3.isConnected()) Sep 26 '17 at 13:20
  • also i added console.log(web3.currentprovider) after new web3 and i get <code>HttpProvider {host: "ropsten.infura.io/...";, timeout: 0, connected: false} connected : false host : "ropsten.infura.io/..."; timeout : 0 proto : Object</code>
    – TimRicta
    Sep 27 '17 at 8:00
  • so looks like ropsten won't let you connect ? Sep 29 '17 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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