Go-ethereum: web3.fromWei doesn't work with this version. Changing to older version fixed it

Created on 3 Aug 2017  路  4Comments  路  Source: ethereum/go-ethereum

System information

Geth version: geth version
OS & Version: ubuntu 16.04

Expected behaviour

ether amount

Actual behaviour

TypeError: web3.fromWei is not a function

Steps to reproduce the behaviour

1- install web3: npm i web3
2- let Web3 = require('web3')
3- let web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
4- let ether = parseInt(web3.fromWei(eth.getBalance(eth.accounts[0]), 'ether'))

Most helpful comment

@Zied-Guesmi its changed as below.
http://web3js.readthedocs.io/en/1.0/web3-utils.html#fromwei
web3.utils.fromWei(eth.getBalance(eth.accounts[0]), 'ether');

All 4 comments

Please open a bug report on the web3 repo. https://github.com/ethereum/web3.js/

@Zied-Guesmi its changed as below.
http://web3js.readthedocs.io/en/1.0/web3-utils.html#fromwei
web3.utils.fromWei(eth.getBalance(eth.accounts[0]), 'ether');

@maulikvora thanks a lot !!

@maulikvora Thanks for the updated documentation, it looks like the github repo docs are out of date : https://github.com/ethereum/wiki/wiki/JavaScript-API#web3fromwei

Was this page helpful?
0 / 5 - 0 ratings

Related issues

362228416 picture 362228416  路  3Comments

JMaxU picture JMaxU  路  3Comments

freshonline picture freshonline  路  3Comments

VenusHu picture VenusHu  路  3Comments

keitaj picture keitaj  路  3Comments