I am trying to connect web3 to a testnet running locally. I am using the following code

    var web3 = new Web3(Web3.givenProvider || "ws://localhost:8546");

    var account = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e';
    web3.eth.getBalance(account, (err, bal) => {balance = bal});

But I get the folowing error in the browser window:

    web3.min.js:1 Uncaught TypeError: this.provider.sendAsync is not a function
        at n.sendAsync (web3.min.js:1)
        at l.t [as getBalance] (web3.min.js:1)
        at index.html:41

Any ideas on what I am doing wrong?


I have fixed this by downgrading to web3 v 0.2.6

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.