5

I try to compile the following (in Solidity) ...

contract InfoFeed {
    function info() payable returns (uint ret) { return 42; }
}

contract Consumer {
  uint attribut = 0;
  InfoFeed feed;
  function setFeed(address addr) { feed = InfoFeed(addr); }
  function callFeed() { attribut = feed.info.value(10).gas(800); }  
}

but what I get is an error message (in MIST's deploy contract):

Type function () returns (uint256) is not implicitly convertible to expected type uint256.
  function callFeed() { attribut = feed.info.value(10).gas(800); }  
                                   ^--------------------------^

how can uint256 not be convertible to uint256, and what to do about it, please?

1 Answer 1

8

Try adding a pair of brackets after gas(800):

feed.info.value(10).gas(800)

becomes

feed.info.value(10).gas(800)()

What the error message is trying to tell you is that you're telling it to assign a function - one which returns (uint256) to be specific - to a uint called attribut, when what you need to do is call that function, and assign the result of calling it to the uint called attribut.

1
  • 1
    saved my life !
    – afu802
    Aug 27, 2017 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.