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
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