Hardhat 0.8.0 gives no revert reason for overflow

I’ve noticed that ever since i upgraded to 0.8.0 and i’m using SafeMath (which seems to no longer be necessary), when i am running tests using Hardhat i get a weird error, “Reverted and hardhat couldn’t infer the reason”.

I am wondering when we can expect this to be fixed.


1 Like

Can you post your contract?

You are meaning Solidity 0.8.0 version right? Hardhat’s current version is 2.2.

I had a similar error, I think it might be because of an issue with how you are using uint256 with the .sub() function.

You will need to update your SafeMath library to use the correct Solidity compiler. (yes there is a difference between SafeMath for 0.8.0 and older versions).

In your situation, if you just updated to 0.8.0 I would take a step back and reassess what is needed in your project. Perhaps refresh and update all your other npm packages too and remove ones you are no longer using in your project. Keep in mind this might take a bit of time as it can lead to compatibility issues.

1 Like