0

I am unable to get the balance of an eth address using web3.eth.getBalance, it returns error like "no suitable peers available". I connected the eth mainnet in light node.

My source code:

web3.eth.getBalance(to_address, function (err, ethbalance) {
   var balance = ethbalance;
   if (err) {
      res.json({status: false,message: err.message});
   }
   else{
      res.json({status: true,message: balance});
   }
});

Please suggest me solutions to rectify this issue.

1

Doesn't seem to be an issue on your code, but rather about your setup in which you don't have peers to connect in your configuration files.

You may try to update your peer nodes.

1
  • Thank you for your answer, i will try – Manickam Feb 6 at 9:54

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.