If a function is using the gasleft() function and is called by another smart contract, does it return the total gas left for the transaction or just the gas left passed to the function via the message call?


If an external contract calls the function of another contract without specifying a gas value, the gasLeft() is the remaining gas. However, if the external contract call specifies the gas to use (e.g. contract.functionToCall{gas: 3000}()) then the gas is only the amount (here 3000) passed to the function call

  • That's not correct. It's the remaining gas.
    – Ismael
    Sep 17 '21 at 3:33
  • @kOnIdk Welcome to the Ethereum Stack Exchange! Your answer was auto-flagged as low-quality. I will clean it up and it will help you too since you were downvoted. Feel free to check ethereum.stackexchange.com/help/how-to-answer
    – eth
    Sep 24 '21 at 1:14

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.