-
After adding the hardhat localhost to metamask and importing account from hardhat, setting eth_amount="0.1", when I run the 'fund' function in the browser I get this error on my console. Error: VM Exception while processing transaction: reverted with reason string 'You need to spend more ETH!' where as I don't see any error for Patrick on his console. I tried with different etc_amount values, but still getting the same error. Any pointers on what am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 14 comments 32 replies
-
@M1708 This error means you are not sending enough ethers (including gas cost). Is it a test or something else? Show the code and particularly the code snippet where this error is coming. |
Beta Was this translation helpful? Give feedback.
-
same problem :( |
Beta Was this translation helpful? Give feedback.
-
Going through the same problem! console.log("ETH sent: ", msg.value);
if(msg.value.getConversionRate(priceFeed) < MINIMUM_USD) revert FundMe__NotEnoughETH(); I get the value of "ETH sent: 0" no matter what number of ETH I send to the Another thing I noticed was; Even if I changed my account (say Acc-B) and did transfer funds from Acc-B the ETH would be deducted from it but the deployer contract does the execution of the code. There's a screenshot of the transaction below: The transaction was done by 0x.....79C8 account but the transaction details show it was done by the deployer account (0x......2266). Can't figure out the problem in this code. Any help would be greatly appreciated! @PatrickAlphaC |
Beta Was this translation helpful? Give feedback.
-
I don't know what I did but it is working for me now. fund()/fallback/receive functions from FundMe.sol
index.js
|
Beta Was this translation helpful? Give feedback.
-
Hi! You might still see a bunch of failed transactions in the node console. But ignore it all, if you scroll through it you will find the successful transaction somewhere there it's just being overwhelmed by random failed transactions that you did not even initiate. Weird. Good luck to y'all! Hope this solves your problem. :) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I meet the same problem, mybe hardhat node network have some problem, try Ganache. |
Beta Was this translation helpful? Give feedback.
-
Hello~ I observed that this error happens once the funding button is pressed, even without pressing the transaction confirm button on MetaMask. That is to say, I have not yet confirmed my transaction, the condition of require has been triggered. This is interesting. So I temporarily removed the require of the Fund function. There are no more error messages in the console of yarn hardhat node. |
Beta Was this translation helpful? Give feedback.
-
Hi guys, I have a method to transfer money, but when it gets called "msg.value" is always 0, and Metamask doesn't popup for tx confirmation:
|
Beta Was this translation helpful? Give feedback.
-
I figured it out, so the thing is in the condition all the values are in 'Wei' even the minimum USD amount is hard coded into the contract as wei. But when you go to metamask it parses the value in 'ETH' not in 'Wei'. So basically on your backend hardhat node the value is 5000 wei that it detects but on your frontend metamask the value is in ETH. If you change the MinimumUSD in FundMe.sol to 50 instead of 50*10**18 it'll work. |
Beta Was this translation helpful? Give feedback.
-
this is worked for me really wellconst fund = async() => {
const ethAmount = "2"
if(typeof window.ethereum !== undefined) {
try {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const FundMe = new ethers.Contract(contractAddress, abi, signer)
await FundMe.fund({value: ethers.utils.parseEther(ethAmount)})
} catch (error) {
console.log(error)
}
}
}
fundBtn.addEventListener("click", fund); and change this line on FundMe.sol uint256 public constant MINIMUM_USD = 1; |
Beta Was this translation helpful? Give feedback.
-
The error still persists. i tried everything. script.js(Lesson 8)
fundMe.sol
Error:
As @kiraliwhite rightly pointed out, error happens once the funding button is pressed, even without pressing the transaction confirm button on MetaMask. Do I ignore the error and continue? Ive spent quite some time debugging this, but to my dismay, I haven't really got the solution. The transactions however are taking place |
Beta Was this translation helpful? Give feedback.
-
Hi everyone i started learning blockchain recently and i face the same error in nather project so |
Beta Was this translation helpful? Give feedback.
-
I am also having the same issue can some solve this . |
Beta Was this translation helpful? Give feedback.
Hi!
I don't exactly know why this is happening. But the transaction has passed. The thing you have to do is to increase the overall gas fee/price/limit of the transaction from metamask. Your transaction will have successfully passed.
You might still see a bunch of failed transactions in the node console. But ignore it all, if you scroll through it you will find the successful transaction somewhere there it's just being overwhelmed by random failed transactions that you did not even initiate. Weird.
Good luck to y'all! Hope this solves your problem. :)