0

When I compile this in Remix (0.4.21+commit.dfe3193c.Emscripten.clang):

  uint256 public rewardAmount = 40;

  function adjustReward (uint256 reward) onlyOwner public {
    rewardAmount = reward; 
  }

I'm getting this error:

Gas requirement of function Quarters.adjustReward(uint256) high: infinite. If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)

Any ideas why this simple function is triggering this warning and how to fix it/avoid the warning?

1

I think the gas requirement is infinite as you're falling foul of the onlyOwner modifier - if you haven't set the contract owner correctly (or are sending the transaction from a different account to the current owner) then the modifier is what's causing the transaction to fail. There isn't much else in that code you've posted which could be causing the issue!

  • Yes, I think that's it! Ownable is defined as: modifier onlyOwner { require(msg.sender == owner); _; } It's in a different file. That isn't a loop, but I bet that the compiler can't tell how the requirement will actually be done. Is there a better way to do this that doesn't create a gas error? – Michael Weiksner Apr 12 '18 at 22:33
  • FYI the transaction works; I'm trying to get rid of a compiler warning. – Michael Weiksner Apr 12 '18 at 22:37

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.