I've read the following:

The catch about gas estimation is that the node will try out your tx with different gas values, and return the lowest one for which your tx doesn't fail. But it only looks at your tx, not at any of the internal call it makes. This means that if the contract code you're calling has a try/catch that causes it not to revert if an internal call does, you can get a gas estimation that would be enough for the caller contract, but not for the callee.

Question 1) so, If I have contractA and contractB, does this mean that even If I don't have try/catch block at all in contractA and the contratA calls contractB, estimateGas will still return the gas estimation for only contractA and won't include the gas estimation for contractB's function ?

Question 2) Could you better explain if possible the snippet I copied above ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.