Logging a value from a contract with ethers.js, gets me this:

tokenBalance: v
  _hex: "0x033b2b2062ddfc98de7fffff"
  _ethersType: "BigNumber

Is this an instance of bn.js, bignumber.js or a custom implementation?

2 Answers 2


The ethers.js library uses BN.js internally for its maths, but the BigNumber class that is exposed serializes all values as immutable strings, and uses Object.defineProperty to ensure the resulting object is completely immutable. So, what you are seeing is neither BN.js nor bignumber.js. A custom implementation would probably be the best way to describe it, but that is being far too generous.

As a side note, the reason for using BN.js is that it is part of elliptic, which is a required dependency, so rather than including a second Big Number library, it simply reuses the Big Number library that is required to be present anyways. :)


@RicMoo is the author of ethers.js and answered above.

(Editing this answer rather than deleting it and adding a comment about @RicMoo.)

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.