-
Notifications
You must be signed in to change notification settings - Fork 64
Lesson 6: ValueError: execution reverted: VM Exception while processing transaction: revert #10
Comments
I'm not sure I follow. Can you verify that the price is returning wrong? What happens when you hop into the brownie console? |
i am getting same problem I have tried everything but it get resolved @PatrickAlphaC |
I got this error when I had forgotten to remove the hardcoded price feeds in the getPrice() and getVersion() functions.
|
Hi,I met the same error,the MockV3Aggregator deployed successfully, but the getEntrancePrice is 0 getPrice() isn't returning a number you want from the mock, somewhere in the vicinity of 2B. Think this is a bug with the Ganache implementation- performing the calculation (minimumUSD * precision) / price in getEntranceFee() gives you a number less than 1- and, since Solidity can't handle floats, Solidity simply sees it as a 0, and the whole thing errors out. deploy.py
FundMe.sol
|
the error disappear magicly (may be come back later),right now the error info is :list out of index actually i faced the same error in another project Or it's some thing else cause this error? |
Hey, I ran into the same problem last night. ExplanationFirst, your transaction gets reverted. So, your transaction is reverted because 'getConversionRate(msg.value) >= minimumUSD' is evaluated to False Let's say we deployed a mock pricefeed which returns 91e18 (91 000 000 000 000 000 000) And (50e18 * 1e18) / 91e18 = 549 450 549 450 549 450,54945054945055 BUT we are working with integers, and integer division is rounded towards zero in Solidity. Back to our 'require': which is inferior to 50e18, hence why the 'require' reverts the transaction. Why it doesnt happen in the videoThe mock pricefeed it set with a value of 2000e18 so: No rounding to be made, so convenient :) How to fixHonestly, I think we cannot do much about rounding. So I thought about a quick fix: Instead of getEntranceFee() returning the value rounded towards 0, we could make it return the value rounded up by simply adding +1 after the division :) now we get and which is now SUPERIOR to 50e18, the 'require' is no longer reverting the transaction TL;DR
|
Thank you so much for this!!! Loved your explainer too!! |
I am getting this error when attempting to run
brownie run scripts/fund_and_withdraw.py --network ganache-local
based on this response on ethereum.stackexchange it seems like the issue is with the price returned by the MockV3Aggregator making the getPrice() function return a value less than 1. StackExchange link
Is there a way to alter either the getPrice() function to include an "if < 0 return 1" or the MockV3Aggregator code?
The text was updated successfully, but these errors were encountered: