Is it possible somehow to create a loop that solidity will recognize as having an upper bound of iterations for gas estimations?

Something like a loop variant in Eiffel (https://www.eiffel.org/doc/eiffel/ET-_Instructions#Loop_invariants_and_variants).

Currently I get infinite gas estimate whenever I have a for loop in my code.


No, Solidity doesn't have such a thing built in. Is there a reason you care about the warning? You can just ignore it.

| improve this answer | |
  • It'd be useful to get an actual gas estimate in such cases – user1282931 Aug 21 '18 at 14:00
  • For what purpose? I've never found the compiler-generated gas estimates to be useful; I just use estimates from real transactions instead. – user19510 Aug 21 '18 at 14:01

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.