'I'm trying to deploy this code but always getting a: raise VirtualMachineError(e) from None VirtualMachineError: revert; or a index error
from brownie import FundMe
from scripts.helpful_scripts import get_account
def fund():
fund_me = FundMe[-1]
account = get_account()
entrance_fee = fund_me.getEntranceFee()
def main():
fund()
Solution 1:[1]
Maybe it is because you have not deployed any FundMe contract, so the FundMe[-1] gave that error. You should try this:
# check whether you have deployed a contract a not
if FundMe:
contract = FundMe[-1]
else:
contract = deploy_contract(account)
Solution 2:[2]
I was having an issue with this and the thing that worked for me was deleting the "1337" folder under "deployments" and then redeploying the updated FundMe (with the getEntranceFee function added). I'm not sure why I had to do that since it should be using the most recently deployed contract. But I kept getting this error until I did that. Maybe deleting that folder caused the map.json to recompile, which I thought it was supposed to be doing every time anyways but maybe not.
He very briefly mentioned at one point that you might have to delete the build folder.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Binh |
| Solution 2 |
