Solidity Gas Warning on Remix – How to Fix Unknown or Non-Constant Gas Requirement

gasremixsolidity

I have this warning in Remix Analysis tab for a basic send funds function:

function sendFunds(address receiver, uint amount) onlyOwner {
    if (this.balance < amount) throw;
    receiver.send(amount);
}

Remix warning: Gas requirement of function () unknown or not constant.

I don't see why the gas cost would be unknown.

Can you help me out? Is there really a problem?

There is also this error which I think has no place there:

Error: Type "address" not supported for state variable.

address public owner;

Best Answer

The warning about Gas requirements is correct! If receiver is an ordinary address, the Gas usage is known. But if receiver is the address of a (payable) contract, the Gas requirements depend on the complexity of the contract code that is dealing with the incoming transaction.