trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 676 forks source link

Remix + Ganache - Cannot call one contract from another #242

Closed anandamarsh closed 5 years ago

anandamarsh commented 5 years ago

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();
        }
    }

Expected Behavior

The contract works as is in JavaScript VM and Ropsten (with Metamask) as expected. Also, individual contacts work with ganache-cli. Just calling one contract from another doesnt seem to work.

Current Behavior

transact to Test.send errored: VM Exception while processing transaction: revert

Possible Solution

NA

Steps to Reproduce (for bugs)

  1. Put he given contract in Remix Editor
  2. Run ganache-ui. It starts on port 7545
  3. Run the SmartContract after setting the Environment to Web3 Provider
  4. Deploy the Another Contract first
  5. Deploy the Test Contract next
  6. Call the method send() with address of Another contract

Your Environment

davidmurdoch commented 5 years ago

Thanks @anandamarsh for this detailed issue. It looks like this is related to https://github.com/trufflesuite/ganache/issues/788, so I'm just linking these together now.

anandamarsh commented 5 years ago

Thanks David. If this is happening with everyone (unable to call one contract from another), then it’s a serious impediment, and should be given a higher priority. If this is a version incompatibility type issue, we can perhaps leave it on a medium priority. For myself, I am currently manoeuvring by routing these inter-contract calls through my Dapp for development purposes.

fbalwy commented 5 years ago

I am facing the same problem :(

anandamarsh commented 5 years ago

Yeah I just turned away from Ganache. Used Roosten test network directly.

On Tue, 19 Feb 2019 at 5:17 am, fbalwy notifications@github.com wrote:

I am facing the same problem :(

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/trufflesuite/ganache-core/issues/242#issuecomment-464833738, or mute the thread https://github.com/notifications/unsubscribe-auth/AJzPf9rTz1z0UCwn33K9TE_ySU-vujQ2ks5vOu5GgaJpZM4Y_rzk .

davidmurdoch commented 5 years ago

@fbalwy, @anandamarsh this is caused by an out of gas error within the call to the nested contract (which bubbles up to the initial contract call and gets treated as a revert) and we are very close to releasing a beta with a fix for it. PR is here: https://github.com/trufflesuite/ganache-core/pull/292

fbalwy commented 5 years ago

It's been 25 days since labeling this issue as priority-high. Any news about releasing a beta with a fix for this issue?

davidmurdoch commented 5 years ago

@fbalwy I'll finally be releasing the beta on Monday!

nicholasjpaterno commented 5 years ago

This should now be fixed in the latest beta tagged releases of ganache-cli and ganache-core.

This fix involved pretty significant code changes; check out the release notes for details.

We'd love it if you'd test this beta out to make sure things are good to go before we release to stable.

If you using ganache-cli, run:

npm install -g ganache-cli@beta

If you are using ganache-core, run:

npm install ganache-core@beta

Let us know if you discover any bugs with this new beta release! Thanks!