0

Just out of curiosity. Let's say I want to run a contracts function that costs 300k gas and I supply only 150k. It will fail but how. The function will stop during 'work' or whole function won't execute.

Cheers!

1

The function will start running, but once the contract runs out of gas, execution will terminate and revert. So all state will revert to previous, as if nothing had happened. Apart from using up the 150k gas.

0

When you execute transaction the amount of gasLimit * gasPrice is first deducted from your account. When function execution is done the remaining ether (if execution took less gas then gasLimit) is refunded to your account.

So the function won't execute.

From ethereum white paper:

The process for the state transition function in this case is as follows:

  1. Check that the transaction is valid and well formed.

  2. Check that the transaction sender has at least 2000 * 0.001 = 2 ether. If they do, then subtract 2 ether from the sender's account.

    ...

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.