I am executing commands from a tutorial at:

JustDev Tutorial on Medium

I am executing the command:

> truffle(ganache)> balanceInEth = address =>
> web3.fromWei(getBalance(address).toString())

I am getting the message:

[Function: balanceInEth] truffle(ganache)> balanceInEth(victim.address) evalmachine.:0 balanceInEth = address => web3.fromWei(getBalance(address).toString()) ^

TypeError: web3.fromWei is not a function at balanceInEth (evalmachine.:0:32) at evalmachine.:0:1 at sigintHandlersWrap (vm.js:98:15) at ContextifyScript.Script.runInContext (vm.js:56:12) at runScript (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:465120:21)

Somebody please guide me.


  • 3
    You're probably on web3.js v1. Try web3.utils.fromWei. Jun 18, 2020 at 16:18

1 Answer 1


As @goodvibration mentioned, you must be using web3.js v1 So you should use web3.utils.fromWei method instead But you also need to use the await prefix before getBalance, because getBalance return a promise which fromWei doesn't understand So my sugestion end up being like this

truffle(ganache)> web3.eth.getAccounts(function(err, acc) { accounts = acc });
truffle(ganache)> const boo = async () => { return web3.utils.fromWei(await web3.eth.getBalance(accounts[0]), 'ether'); }
truffle(ganache)> boo()
  • Hi @Luis Ricardo Sanchez, if I am using your commands I am getting error in the transaction: >victim.deposit.sendTransaction(options) truffle(development)> victim.deposit.sendTransaction(options) Thrown: { Error: Returned error: from not found; is required at evalmachine.<anonymous>:0:16 at sigintHandlersWrap (vm.js:288:15) at Script.runInContext (vm.js:130:14) at runScript (/home/zulfi/.nvm/versions/node/v10.22.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:227:1) at Console.interpret (/home/zulfi/.nvm/versions/node/v10.22.0/li....Zulfi.
    – zak100
    Dec 30, 2020 at 5:56

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.