I'm trying to to subctract in type script big numbers, but getting error...
const supply1 = 100000;
const _amount = 100;
const supply = ethers.utils.parseEther(`${supply1}`);
const diff = supply - _amount;
The ethers.utils.parseEther
function returns a BigNumber.
To make arithmetic operations on it you must explicitely call the operation implementation, in your case that would be the .sub
method which expects a BigNumberish parameter.
So you'd want to change :
const diff = supply - _amount;
to :
const diff = supply.sub(_amount);
Just keep in mind that diff
will be of type BigNumber, if you need to convert it to another type such as number or string, you can refer to the appropriate part of the documentation.