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

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.

  • great, but how do you estimateGas? – Andy Hin Jun 8 '18 at 3:39

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.