Under the hood, what happens in an unbounded loop? let's say I'm trying to send tokens to an infinite amount of addresses and end up with an out of gas error. Will the function which executes the transfers complete transfers successfully until it runs out of gas, or will it 'build-up' and revert all of them at once.

  • 1
    A transaction never "partially succeeds". Either it succeeds completely, or it reverts entirely. There's no "under the hood" here by the way.You're infinite loop will cause the transaction to run out of gas, and everything will be reverted (no transfer will take place). – goodvibration Aug 6 '20 at 19:43
  • @goodvibration It's not exactly true that a transaction "succeeds completely, or it reverts entirely". The default behavior in Solidity is to bubble up reversion, meaning if contract A calls contract B, and contract B reverts, contract A will revert as well - but the calling contract can decide not to revert. Solidity allows you to do this using .call, Solidity Assembly. or try/catch. Though yes, in the original question, the entire tx will revert since they don't mention any of those methods being used – flygoing Aug 6 '20 at 20:05
  • 1
    @flygoing: You're talking implementation details on how to "silently revert" and continue going. The question here, IMO, is about a transaction executed from the outside. – goodvibration Aug 6 '20 at 20:20

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.