4

I have an innocent looking contracts that work painlessly in Remix. Test contract can easily call Another if I use JavaScript VM in Remix.

I also have ganache-cli running on port 7454. If I connect Remix to ganache-cli, each of these contracts work well individually. But I cant call Another from Test. Remix console says transact to Test.send errored: VM Exception while processing transaction: revert

My contracts look like:

pragma solidity 0.4.25;

contract Another {
    uint public balance;
    function sendToAnother() public {
        balance += 10;
    }
}

contract Test {
    function send(address another) public {
        Another(another).sendToAnother();
    }
}

One suspicion I have is - am I picking up the address of the Another contract correctly? I am copying it from Remix's Deployed Contracts tab.

Edit: Odd enough, it works well on Ropsten Test Network! Could it have to do something with running out of gas. Unlikely, since remix shows around 100 Ether on the account.

Submitted a Bug to Ganache trufflesuite/ganache-core

enter image description here

enter image description here

  • I'd suggest to try with a different version of ganache, perhaps it is a regression. I've several issues with odd regresions intruced between versions. – Ismael Dec 4 '18 at 3:42
  • Any ideas on how to find archived versions of Ganache? – Amarsh Dec 4 '18 at 4:43
  • You can use npm to install old versions, for example to install v6.1.8 use npm install -g ganache-cli@6.1.8. To see available versions consult npmjs.com/package/ganache-cli, in the versions tab. – Ismael Dec 4 '18 at 5:42
  • @Amarsh I can confirm this doesn't work with Ganache too. Remix works fine. Submit bug to Ganache team github.com/trufflesuite/ganache/issues – Zulhilmi Zainudin Dec 4 '18 at 9:57
  • thanks @ZulhilmiZainudin . The bug is reprted at github.com/trufflesuite/ganache-core/issues/242 – Amarsh Dec 4 '18 at 10:58
0

This looks like a bug to me.

I was able to find a solution, but this only works if you call sendToAnother() from Another first, and then call it from Test.

pragma solidity 0.4.25;

contract Another {
    uint public balance;
    function sendToAnother() public returns (bool success) {
        balance += 10;
        return true;
    }
}

contract Test {
    function send(address another) public {
        Another(another).sendToAnother();
    }
}

Even though this solution works, I'm not 100% clear as to why it worked for the Javascript VM and not for Ganache. It looks like while using Remix, Ganache is searching for a return first, thus the immediate revert being thrown. My guess is it's a bug, but would love to hear some more ideas/theories if anyone has them.

  • Doesnt seem to work :( I am attaching a screenshot with the original post. Thanks for the effort – Amarsh Dec 4 '18 at 0:07
  • I went back to do some more testing. This only works when you call sendToAnother() from Another first, and then call it from Test. Looks like a bug to me - Updating my answer. – Devon Yarbrough Dec 4 '18 at 16:41
  • Filed at github.com/trufflesuite/ganache-core/issues/242 ... perhaps others are facing similar issues – Amarsh Dec 5 '18 at 4:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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