0

When I return a Big Number in the Truffle Console, the format of my results is something like:

truffle(development)> tokenInstance.balanceOf(accounts[2])
<BN: 64>

However, in one of the video tutorials that I'm using, the output that the video shows is something like:

truffle(development)> tokenInstance.balanceOf(accounts[2])
BigNumber { s: 1, e: 2, c: [ 100 ] }

Are there any config options in truffle so that my output can look like the latter? (And I'm not worried about converting my results to base 10: I know that I can do that with a callback and toNumber().)

  • Try const bigNumber = new BigNumber(bn.toString()). – goodvibration Jan 30 at 14:48
  • @goodvibration I was hoping that the output would be formatted directly right after a call without any extra coding (otherwise I can do a callback as described in my question). I'll edit my question to make this a bit clearer. – Eric Jan 30 at 14:56
1

The format changed in Truffle v5 since it is base on web3 v1 which uses bn.js. To have the format used previously you have to install Truffle v4 which is based on web3 v0.20 which uses bignumber.js.

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.