This is driving me NUTS. I am running through this handy dandy Solidity course


Where I am at timestamp 5:45:11, where I write a script to interact with the FundMe contract and it works fine on Rinkeby to call the "getEntranceFee()" function or any function I want to call, but it does not work on ganache-local. I get this error:

Running 'scripts/fund_and_withdraw.py::main'...
  File "<console>", line 1, in <module>
  File "brownie/project/scripts.py", line 69, in run
    return func(*args, **kwargs)
  File "./scripts/fund_and_withdraw.py", line 16, in main
  File "./scripts/fund_and_withdraw.py", line 9, in fund
    entrance_fee = fund_me.getEntranceFee()
  File "brownie/network/multicall.py", line 115, in _proxy_call
    result = ContractCall.__call__(*args, **kwargs)  # type: ignore
  File "brownie/network/contract.py", line 1729, in __call__
    return self.call(*args, block_identifier=block_identifier)
  File "brownie/network/contract.py", line 1533, in call
    raise VirtualMachineError(e) from None
VirtualMachineError: revert

I've noticed that I have had issues for some time of having scripts that deploy and run contracts just fine on the testnets. But when I run a script that deploys and interacts with contracts on my local ganache chain, it compiles and deploys soundly but any interaction with it doesn't work. How would I debug this issue? I am at a total loss here. Did I do something wrong in setting up the ganache chain? I thought it was plug and play.

  • Can you provide a reproducible source code? Probably not many people have time to watch a long video just to get the source.
    – Ismael
    Sep 28 '21 at 23:54

I figured out the answer to this error. Turns out I was deploying using a specific MockV3Aggregator Address and then I had another script to interact with the contract, but used a different MockV3Aggregator address, hence giving me that error. Specifically in my deploy.py function,

    account = get_account()
    # pass the price feed address to our fundme contract's constructor
    # if we are on Rinkeby Network, use said address
    if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        price_feed_address = config["networks"][network.show_active()][
        price_feed_address = MockV3Aggregator[-1].address  # gets the latest address

    fund_me = FundMe.deploy(
        "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e", # this should be price_feed_address
        {"from": account},
    print(f"Contract deployed to {fund_me.address}")

That address should have been the price_feed_address variable that I didn't use. Whoops.

Thank you all for reading through this thread of me bungle through a straightforward issue.

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.