3

If I use this simple payout contract in remix, it gives me a warning that the gas costs is infinite. Is this an intended behaviour?

contract Payout
{
    function payout() public {
        msg.sender.transfer(2);
    }
}

Context of this question: trying to debug my application and gas costs could be possible problem source.

1 Answer 1

1

When the Solidity compiler says that the gas requirement of a function is infinite, it is not necessarily the case that that function cannot be executed. It just means that the compiler was not able to determine a maximum amount of gas needed.

I am not sure why it wasn't able to do so. As far as I can tell, it always produces this warning when you use .transfer(...). It might be because calls to .transfer(...) can potentially fail and revert() the transaction.

You can usually safely ignore this warning, though it is a good idea to do what you did and find the line that is causing the warning.

1
  • great, but how do you estimateGas?
    – Andy Hin
    Commented Jun 8, 2018 at 3:39

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.