In the past, web3 events published numeric events like so:

BigNumber { s: 1, e: 17, c: [ 1000 ] } }

Now with web3.js 1.0, big numbers come down as objects like this:

 <BN: de0b6b3a7640000>

The problem here is that if we're collecting events for troubleshooting later, this would be indecipherable. The only solution I can think of is having some code in the event consumer convert the number before storing the event somewhere like so:

web3.utils.fromWei(new web3.utils.BN(receipt.logs[0].args.amount))

Does anyone else have any other ideas?


You have access to yourBigNumber.toString(10), .toString(16) and .toNumber(), no?

Look at this cheatsheet https://github.com/MikeMcl/bignumber.js

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.