1

I am using ethers and writing tests and I don't quite understand the ethers.BigNumber.from('some number') method. Could someone please explain how it works, the documentation is not very helpful to me.
For example: console.log(ethers.BigNumber.from('30') < ethers.BigNumber.from('120'));

returns "false"

Why is BigNumber from 30 greater than BigNumber from 120?

1 Answer 1

2

I exactly ran into the same problem. You should use the built.in methods in bignumber:

let a = ethers.BigNumber.from('30');
let b = ethers.BigNumber.from('120');
 a.lt(b) // returns true  as 30 is lower than (lt) 120

Here you use lt (lower than), you can use:

  • eq: equal
  • gte: greater or equal
  • gt: greater
  • lte: lower or equal
  • lt: lower

Hope it helps

1
  • oh thank you very much! Feb 18, 2023 at 17:21

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.