ValueError: Gas estimation failed: 'execution reverted: VM Exception while processing transaction'
See original GitHub issueEnvironment information
brownie
Version: v1.17.1ganache-cli
Version: v6.12.2solc
Version: @0.6.0- Python Version: 3.9.9
- OS: windows
I’ve been following and writing along Patrick Collin’s incredibly packed lesson on Youtube on Blockchain and Solidity. I’m at the stage where I want to run a script called fund_and_withdraw on my local Ganache account through creating mocks.
I have correctly added the ganache-local network to the networks list of Brownie, as when I run my deploy.py script, it works perfectly.
Yet, when I try to run the fund_and_withdraw.py script, the fund function seemed to be running, but not the withdraw part. As I have found someone who had the same issue, my problem evolved since I followed the advice from this post 422 from @GratefulDave.
Like him, the error message was ValueError: Execution reverted during call: 'execution reverted: VM Exception while processing transaction: invalid opcode'. This transaction will likely revert. If you wish to broadcast, include 'allow_revert:True' as a transaction parameter.
Attempt to fix it through changing the network ID on Ganache
I followed one of the advice, which was to change my network ID on my local Ganache server, after deleting ganache-local from the list of Brownie’s networks. I did so, and re-added ganache-local networks with updated host and chainid.
Then the error was different, as this time, the entry fee couldn’t even be taken, and this error message came:
Current error message
INFO: Could not find files for the given pattern(s).
Brownie v1.17.1 - Python development framework for Ethereum
BrownieFundMeProject is the active project.
Running 'scripts\fund_and_withdraw.py::main'...
0
The current entry fee is 0
Funding
File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\_cli\run.py", line 50, in main
return_value, frame = run(
File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\project\scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File ".\scripts\fund_and_withdraw.py", line 22, in main
fund()
File ".\scripts\fund_and_withdraw.py", line 12, in fund
fund_me.fund({"from": account, "value": entrance_fee})
File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\contract.py", line 1625, in __call__
return self.transact(*args)
File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\contract.py", line 1498, in transact
return tx["from"].transfer(
File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\account.py", line 652, in transfer
receipt, exc = self._make_transaction(
File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\network\account.py", line 735, in _make_transaction
raise VirtualMachineError(e) from None
File "C:\Users\chret\AppData\Local\Programs\Python\Python39\lib\site-packages\brownie\exceptions.py", line 125, in __init__
raise ValueError(str(exc)) from None
ValueError: Gas estimation failed: 'execution reverted: VM Exception while processing transaction: revert You need to spend more ETH!'. This transaction will likely
revert. If you wish to broadcast, you must set the gas limit manually.
I do have enough ETH to process those transactions, so the error message is very confusing to me.
What else I’ve tried
Since this message appeared, I’ve tried removing my entire code, from all documents (deploy.py, helpful_scripts.py, fund_and_withdraw.py, FundMe.sol, brownie-config.yaml) and pasted Patrick’s codes.
The same error message came through.
Here is a link to my repo with the relevant documents.
Any help is appreciated!
Have a good day ahead (excuses in advance in the formatting of this post isn’t great, I’m still new around here but I’ll learn fast!)
Anne
Issue Analytics
- State:
- Created 2 years ago
- Comments:29 (1 by maintainers)
So this is actually the issue. When I manually changed it to 25*10**18, it started working. This function in the FundMe.sol is what is causing the issue. Somewhere, the trailing zeros in the solidity contract and/or Fund_and_withdrawy.py script are not matching.
EDIT:
So yeah I found the issue. In the video, the instructor tells us post-production to change the STARTING_PRICE value from 2^18 to 2^8 BUT the conversion function in the solidity contract is still converting to 18 places. So when you try to call the Fund() function, it fails because of the require() statement. If your problem is the same as mine, which I’m confident it is, this is NOT a ganache or brownie issue. The instructor needs to be aware that he never told us to update all decimal checks and it’s causing confusion.
@AnneCh
just realize that if i push directly number 2500000 it works perfectly fine so the problem is fund_me.getEntranceFee() return nothing, so i supposed that fund_me is not yet being called ???