2

I am using the Javascript VM on remix.ethereum.org to learn Smart Contract basics.

I am following the tutorial here: https://www.youtube.com/watch?v=oTS9uxU6cAM&list=PLO5VPQH6OWdULDcret0S0EYQ7YcKzrigz&index=4

The tutorial demonstrates what happens when there is not enough Gas. At 05:29 the Gas Limit in Remix is set to 30000 and the transaction is shown to fail.

If I set the Gas Limit to 30000 it still executes successfully.

Here is my code (same as is in the tutorial):

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.4.16 <= 0.8.6;

contract Gas {
    function testGasRefund() public view returns (uint) {
        return tx.gasprice;
    }
    
    uint public i = 0;
    
    function forever() public {
        while(true) {
            i += 1;
        }
    }
}

When I deploy the contract - the Gas shows as 80000000, the debug output shows:

status  true Transaction mined and execution succeed
 transaction hash   0xbc5cf5a7d535b2a4f6b6c84ae5adc00a46e9ef6403ebbc19f0266c573d529b21
 from   0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB
 to Gas.(constructor)
 gas    80000000 gas
 transaction cost   80000000 gas
 execution cost 148581 gas
 hash   0xbc5cf5a7d535b2a4f6b6c84ae5adc00a46e9ef6403ebbc19f0266c573d529b21
 input  0x608...40033
 decoded input
 decoded output
 logs   []
 value  0 wei

1 Answer 1

0

It looks like remix gas limit doesn't apply to deployment and only to the function executions.

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.