Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Trouble using web3.getBalance() and similar functions #171

Closed
AusIV opened this issue Jul 30, 2017 · 1 comment
Closed

Trouble using web3.getBalance() and similar functions #171

AusIV opened this issue Jul 30, 2017 · 1 comment

Comments

@AusIV
Copy link
Contributor

AusIV commented Jul 30, 2017

Apologies for posting this as an issue, as I suspect it's my own misunderstanding rather than anything actually wrong with provider-engine.

If I do:

var engine = ZeroClientProvider({
  getAccounts: function(){},
  rpcUrl: 'https://mainnet.infura.io/',
})
var web3 = new Web3(engine)
web3.eth.getBalance(someAddress, function(err, resp){
  console.log(err);
  console.log(resp);
});

I would expect it to either log an error from getBalance, or log the balance at someAddress. Instead, I get an error:

Web3ProviderEngine does not support synchronous requests.
  at Web3ProviderEngine.send (index.js:71)
  at RequestManager.send (index.js:74)
  at sendRequest (index.js:519)
  at Eth.send [as getBalance] (index.js:534)

I get similar results for anything that would have to go to the RPC server for a result. My understanding was that if I specified a callback function as the last argument to web3.eth.getBalance() it would run the request asynchronously and make a callback. This works if I use the straight HttpProvider for web3.

Where am I going wrong?

@AusIV
Copy link
Contributor Author

AusIV commented Jul 31, 2017

It looks like my problem was that I had accidentally installed the web3 1.0.0-beta.13 version, and it looks like there are some breaking changes in 1.0.0. This may be something provider-engine will need to fix eventually to be compatible with 1.0.0, but that's another issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant