const { ethers } = require('ethers');

Returns true

const { ethers } = require('ethers');

ethers.BigNumber.toNumber is not a function

According to the docs


toNumber() is a function on BigNumber.

Are the docs wrong or is maybe toNumber called wrong?

2 Answers 2


The method isBigNumber is a static method of class ethers.BigNumber.

As you can read here:

The static keyword defines a static method or property for a class. Neither static methods nor static properties can be called on instances of the class. Instead, they're called on the class itself.

The method toNumber, on the other hand, is not a static method of class ethers.BigNumber.

Therefore, it should be called on instances of the class rather than on the class itself.

So in short, you need to change this:


To this:


if the totalBalance is the bignumber or the value format seem like this..

BigNumber {_hex: '0x02', _isBigNumber: true}

you just add toNumber after totalBalance

totalBalance.toNumber() // result = 2

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.