According to what I know, If you invoke function F on Contract C, you pay the gas fees related to F's operations and if for some reason something goes wrong, all state changes performed by F until that point are revoked. F works in an atomic way and the human being account that invoked F pays for the gas fees (even if operations are rolled-back).

The doubt I have comes from a situation in which F invokes some other function F1 on Contract C1, which can invoke some other function F2 on Contract C2 and so on.... human -> (C) F -> (C1) F1 -> (C2) F2 -> ...

First of all, it is my understanding that the original account would only pay for the gas fees of operations performed by F, then it would by C who pays gas fees for operations performed by F1, C1 would pay for operations on F2 on so on....

But what if Fn fails? would all state modifications performed by F up to Fn-1 be rolled-back? would the original account as well as contracts from C up to Cn-1 waste their gas fees?

1 Answer 1


The user pays gas for (C) F -> (C1) F1 -> (C2) F2 -> ...

Those execute in the context of a single atomic transaction. It might help to consider that it is usually not possible to run F without knowing what F1 returned.

Generally, if F2 fails, then the error will bubble up to C and transaction T. If T reverts then they all revert. It will turn up as a failed transaction and a failed transaction can't change anything.

An exception to that complete failure can be built in to a contract. C1 can call C2 in a way that does not automatically revert if C2 reverts and instead press on, usually branching on success/failure of C2. You can sometimes see that on Etherscan when it notes that "part of the transaction failed" even though the overall transaction succeeded.

Hope it helps

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.