1

My below code is working fine

Web3 = Require('web3');
const walletAddress = '0x8690F1feff62008A396B31c2C3f380bD0Ca6d8b8';
const web3 = new Web3(new Web3.providers.HttpProvider(testnet));
var balance = web3.eth.getBalance(walletAddress); //Will give value in.
balance = web3.toDecimal(balance);

But when I run:

web3.utils.fromWei(balance,'ether')

It throws an error:

"TypeError: Cannot read property 'fromWei' of undefined"

I am using Web3 0.19.1 and node 10.15.1.

1

With web3.js v0.x, use web3.fromWei.

With web3.js v1.x, use web3.utils.fromWei.

  • Hi,Thats working fine..Thnx for the quick reply – Sekaran Ramalingam Feb 26 at 15:04
  • @SekaranRamalingam: You're welcome! – goodvibration Feb 26 at 15:14

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.