1

When I flag a simple function with the type internal, remix throws an infinite gas estimate warning. Without this type, everything is fine. Please, do you know why?

function half(uint a) { uint b = a/2; //... }-> Gas estimate for "half(uint256)": "230"

function half(uint a) internal { uint b = a/2; //... } -> Gas estimate for "half(uint256)": "infinite"

2
  • "Because of this I can't deploy my contract." Compiler warnings generally don't prevent you from deploying your contract. Can you explain why you can't deploy?
    – user19510
    Feb 7 '18 at 19:43
  • my bad, in the deployer I wrote I was checking gas first
    – Tholoz
    Feb 9 '18 at 19:57
2

Is there anything else going on in the function because I didn't have this issue in remix.

pragma solidity ^0.4.19;

contract StackEthereumTholoz {

    function start(uint _int) public pure returns (uint) {
        return half(_int);
    }

    function half(uint _a) internal pure returns (uint) {
        uint b = _a/2;  
        return b;
    }

}

Gas: 72


[Update 1]

So, based on your code (and minimal example code), when an internal contract is actually not used, Remix cannot actually calculate the gas cost. It will automatically set it as infinite as a default.

2
  • Hi ! Here is my minimum example: pragma solidity ^0.4.19; contract Infinite { function half(uint a) internal{ uint b = a/2; } } Even when I add pure it keeps throwing Infinite gas estimate
    – Tholoz
    Feb 7 '18 at 15:25
  • @Tholoz Answer updated to explain why you get infinite with that minimum example.
    – ReyHaynes
    Feb 7 '18 at 17:09

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.