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

5
  • 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
    Commented Dec 4, 2018 at 3:42
  • Any ideas on how to find archived versions of Ganache?
    – Amarsh
    Commented Dec 4, 2018 at 4:43
  • You can use npm to install old versions, for example to install v6.1.8 use npm install -g [email protected]. To see available versions consult npmjs.com/package/ganache-cli, in the versions tab.
    – Ismael
    Commented Dec 4, 2018 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 Commented Dec 4, 2018 at 9:57
  • thanks @ZulhilmiZainudin . The bug is reprted at github.com/trufflesuite/ganache-core/issues/242
    – Amarsh
    Commented Dec 4, 2018 at 10:58

1 Answer 1

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.

3
  • Doesnt seem to work :( I am attaching a screenshot with the original post. Thanks for the effort
    – Amarsh
    Commented Dec 4, 2018 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. Commented Dec 4, 2018 at 16:41
  • Filed at github.com/trufflesuite/ganache-core/issues/242 ... perhaps others are facing similar issues
    – Amarsh
    Commented Dec 5, 2018 at 4:34

Your Answer

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

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