question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Gas estimation failed: 'execution reverted: VM Exception while processing transaction'

See original GitHub issue

Environment information

  • brownie Version: v1.17.1
  • ganache-cli Version: v6.12.2
  • solc 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:closed
  • Created 2 years ago
  • Comments:29 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostofcoolidgecommented, Jan 28, 2022

Hi All, the same issue here, but I noticed that my entrance fee shows as 2500000, while in the video it shows as 25000000000000000, so maybe there is an issue with the getEntraceFee function Capture ?

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. image

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. fixed getConversionRate function

1reaction
sagara11commented, Dec 3, 2021

@AnneCh image 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 ???

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gas estimation failed: 'execution reverted: VM Exception while ...
The error message turns into: ValueError: Execution reverted during call: 'VM Exception while processing transaction: revert'. This transaction will likely ...
Read more >
Deploying ganache-local w/brownie: VM Exception while ...
ValueError : Gas estimation failed: 'execution reverted: VM Exception while processing transaction: invalid opcode'. This transaction will ...
Read more >
Error: VM Exception while processing transaction: revert
You're either not sending enough gas or are hitting the block gas limit. Estimate your gas requirement with estimateGas() . If it's about...
Read more >
brownie:ValueError: execution reverted: VM Exception while ...
Think this is a bug with the Ganache implementation- performing the calculation (minimumUSD * precision) / price in getEntranceFee() gives you a ...
Read more >
Error: VM Exception while processing transaction: revert.
This error happens when a function call jumps out of bounds (e.g array out of bounds). This is done to punish the caller...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found