Back to All

Invalid Argument on parseUnits

I am trying to increase the gas price to cancel a transaction but keep getting this error:

[Unhandled promise rejection: Error: invalid decimal value (argument="value", value="7.944234428460001e-8", code=INVALID_ARGUMENT, version=bignumber/5.7.0)]

Here is my code:

let gasPrice = await ethers.utils.formatUnits(oldTransaction.maxFeePerGas, 18);
// 0.000000072220312986
const newGasPrice = gasPrice * 1.1;
// 7.944234428460001e-8
const cancelFees = await Utils.parseUnits(newGasPrice.toString(), 'ether');

Why is 7.944234428460001e-8.toString() not a valid argument?

ReadMe