When I use Javascript VM in Remix I'm able to run functions and return outputs, but when I switch over to testrpc, the code runs properly but there's no decoded output.

I only ever run into this problem when I need to return a bool or the now variable. Is there any way explanation as to why this happens?


So as you know Remix runs Ethereum-vm underneath so sometimes it's a bit different from testRPC. Try testing with https://ethfiddle.com as well to double check output.

Anyways, back to your question. Did you add constant to the function declaration? Otherwise you'll just get a txHash unless you've implemented events.

  contract SimpleReturn {
    bool value = false;

    function get() public constant returns (bool) {
      return value;

^ the above function returns a bool perfectly fine.

see it running: https://ethfiddle.com/wzk5p9qLdw

  • So I actually just tested the returning now with and without constant and having constant returns output. However, for another function I'm trying to return I have payable and I don't think I'm allowed to have both payable and constant right? – JorahFriendzone Nov 16 '17 at 8:09
  • thats correct, if you declare the function as payable, it will return a txhash and also cost gas. link: ethfiddle.com/0pxC4R-F_1 – llz Nov 16 '17 at 8:21
  • What if I want a payable function to also return a true? – JorahFriendzone Nov 16 '17 at 8:37
  • you need to use events: solidity.readthedocs.io/en/develop/contracts.html#events – llz Nov 16 '17 at 12:03

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.