This seems like a trivial question, but I can't find an answer.
When you try to send a transaction with MetaMask, it calculates the amount of gas needed.
Most of the time if there's an error in your function (an unsatisfied
revert
test for example), it will notice it when calculating gas price and set it to 0. If you try to send the transaction anyway, you'll get the error. So it can predict some of the errors.But sometimes, MetaMask calculates and finds an incorrect amount of gas. Most of the times if I set it higher manually I can send the transaction.
That means that it's an error that couldn't be foreseen, and the actual gas needed is higher than expected. How does that happen? Shouldn't MetaMask be able to see what is about to happen?
Why is there a difference between errors Metamask can predict and the others?