I'm using web3js version 0.20.6.

When I try the getBalance function it returns a string and it works. But the documentation here says it should return a promise. But the documentation here says it returns a string. Is this a change between the versions?

In the world of async calls using promise, the chain of method calls needs to get converted into promise based then and catch. Is it okay to have so many layers of promise going from parent to child to its child method?


1 Answer 1


Yes, getBalance returns a promise. The spec you're referencing is old but appropriate for the version of web3js you're using. You might accidentally be using web3js 1.0.0. I'd try this:

.then(function (balance) {
}).catch(function(e) {
  • Is the best practice to have all of the method calls above this to return promise too?
    – Sundar
    Commented Jul 19, 2018 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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