2

There is a gasleft() to check how much gas left for my smart contract execution in solidity. But how is it possible to check how much gas left in block? I am having quite a big solidity function, and depending on how much gas can fit the block, next steps may differ.

1 Answer 1

0

You can control the gasleft() with a loop doing something like :

    do {
    // Your stuff
    } while(gasleft() > whateverYouNeed)

(Where whateverYouNeed would be the amount of gas required to run one iteration of the loop + what comes after ( maybe *1.5, just in case)

Based on this answer: https://ethereum.stackexchange.com/a/134981/69965

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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