Hot answers tagged

1

getBalance is asynchronous, so you can't assign a variable in the callback and expect that variable to be set in synchronous code after that. You can move any code that requires the balance into the callback of getBalance, e.g.: web3.eth.getBalance(address, (err, bal) => { if (err) { // Do something with the error return console.error(err); } ...


Only top voted, non community-wiki answers of a minimum length are eligible