-
Hey, I'm up to lesson 8: HTML / Javascript Fund Me (Full Stack / Front End), and running into an issue at around the 13 hour 17 minutes mark. When I hit the fund button, MetaMask opens as expected with the correct amount of ETH ready for the transaction, but the transaction fails. Here is the error I'm getting in the hardhat console: eth_call
Contract call: FundMe#<unrecognized-selector>
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
Error: VM Exception while processing transaction: reverted with reason string 'Didn't send enough'
at FundMe.fund (contracts/FundMe.sol:64)
at FundMe.<fallback> (contracts/FundMe.sol:52) Here is my function fund() public payable {
require(
msg.value.getConversionRate(s_priceFeed) >= MINIMUM_USD,
"Didn't send enough"
);
// add funders to address array
s_funders.push(msg.sender);
// record who sent what amount
s_addressToAmountFunded[msg.sender] = msg.value;
} Here is my async function fund() {
const ethAmount = '0.1'
console.log(`Funding with ${ethAmount} ETH...`)
if (typeof window.ethereum !== 'undefined') {
const provider = new ethers.providers.Web3Provider(window.ethereum)
const signer = provider.getSigner()
const contract = new ethers.Contract(contractAddress, abi, signer)
const txResponse = await contract.fund({
value: ethers.utils.parseEther(ethAmount),
})
} else {
fundButton.innerHTML = 'Please install MetaMask'
}
} I thought initially that the amount was somehow wrong and so tried to set I have tried resetting the MetaMask account, still nothing... I've tried looking in the usual places, but I cannot find the answer - please help! |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 28 replies
-
So, the fact that you're seeing:
means that's the issue you're getting! What happens when you try sending 1 ETH instead of 1000? |
Beta Was this translation helpful? Give feedback.
-
Hi @0xTesty and @PatrickAlphaC, I am facing the same issue also. When my: eth_feeHistory
Contract deployment: MockV3Aggregator
Contract address: 0x5fbdb2315678afecb367f032d93f642f64180aa3
Transaction: 0x2f60bd4cba5dffe33cd22380f4891cfadb7f13aad763bb084e8a1c3336b892f9
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
Value: 0 ETH
Gas used: 569635 of 569635
Block #1: 0x3ffc8c946d1e095f96d998c9c1ced344a9bb83b584ab819845ba5d32b3157322
Contract deployment: FundMe
Contract address: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
Transaction: 0x8c145c8496216abc4fb960822a8a95435f66c88027b14728faec84d7571fd0ee
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
Value: 0 ETH
Gas used: 1013955 of 1013955
Block #2: 0x8d255fbec19ab5893a8367e1e85e16663732d3c4dfd1ec90b4f542b60b67d85d
eth_blockNumber
eth_feeHistory
eth_blockNumber
net_version
eth_getBalance (2)
eth_getBlockByNumber
eth_getBalance
eth_blockNumber
eth_estimateGas
eth_getCode
eth_accounts
eth_call
Contract call: FundMe#<unrecognized-selector>
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
Error: VM Exception while processing transaction: reverted with reason string 'Didn't send enough'
at FundMe.fund (contracts/FundMe.sol:59)
at FundMe.<fallback> (contracts/FundMe.sol:53)
at HardhatNode.runCall (F:\eth\patrickC\hardhat-fund-me\node_modules\hardhat\src\internal\hardhat-network\provider\node.ts:616:20)
at EthModule._callAction (F:\eth\patrickC\hardhat-fund-me\node_modules\hardhat\src\internal\hardhat-network\provider\modules\eth.ts:354:9)
at HardhatNetworkProvider._sendWithLogging (F:\eth\patrickC\hardhat-fund-me\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:139:22)
at HardhatNetworkProvider.request (F:\eth\patrickC\hardhat-fund-me\node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:116:18)
at JsonRpcHandler._handleRequest (F:\eth\patrickC\hardhat-fund-me\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:188:20)
at JsonRpcHandler._handleSingleRequest (F:\eth\patrickC\hardhat-fund-me\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:167:17)
at Server.JsonRpcHandler.handleHttp (F:\eth\patrickC\hardhat-fund-me\node_modules\hardhat\src\internal\hardhat-network\jsonrpc\handler.ts:52:21) I think it's depositing the funds via the fallback function. But, when I call the withdraw function, it shows the same When I set From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
Value: 0 ETH
Gas used: 1010955 of 1010955
Block #2: 0xcd3eb3dd9fc29b9cbd48159977d7c90651cafefcb392fc8cde810bf0d9ec07ce
eth_getBalance (2)
eth_getBlockByNumber
eth_blockNumber
eth_feeHistory
eth_blockNumber
net_version
eth_getBalance (2)
eth_getBlockByNumber
eth_getBalance
eth_blockNumber
eth_estimateGas
eth_getCode
eth_accounts
eth_call
Contract call: <UnrecognizedContract>
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
eth_call
Contract call: <UnrecognizedContract>
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
eth_feeHistory
eth_call
Contract call: <UnrecognizedContract>
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
eth_call
Contract call: <UnrecognizedContract>
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
eth_call
Contract call: <UnrecognizedContract>
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
eth_blockNumber
eth_feeHistory
eth_getTransactionCount
eth_blockNumber
eth_sendRawTransaction
Contract call: <UnrecognizedContract>
Transaction: 0xb449e78316855c29e35592fec57b453d1fa7cdf9f02736d1cca30363fe4f5f6f
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
Value: 1 ETH
Gas used: 104237 of 104237
Block #3: 0xe2a2bd6fac906b44808a5fd228ec2e1750b09ccd811699ca17cf58dd9d36b33a
eth_feeHistory (2)
eth_getTransactionReceipt
eth_feeHistory It deposits the funds through the fund function call. And the withdraw function is also working.
|
Beta Was this translation helpful? Give feedback.
-
I'm getting the same issues. It seems to me that msg.value is being passed in as zero (I put some console.logging in FundMe.sol). Does anyone know why that would be the case? |
Beta Was this translation helpful? Give feedback.
-
Had the same error but managed to solve it. Wasnt actually anything to do with the code. After that you import an account using the private key from hardhat. When you run fund it will call the contract and give Once I connected on account 2 the error went away. Suprised that you can call the contract without being connected.. |
Beta Was this translation helpful? Give feedback.
-
Kinda the same issue but I keep getting an eth_call error saying no fallback function I'm stuck with transaction reverted... can someone help?
|
Beta Was this translation helpful? Give feedback.
-
Hi all, I'm enjoying Patrick's course along with you all! BTW great course, Patrick, thanks!! 👍 I've hit this issue as well, and I believe I've figured out what is going on. But I'm learning like many of you, so although I'm not 100% sure that this is the best solution, hopefully this reply makes sense and is helpful. I started by I added dummy implementations for each the above methods to
If there is enough interest, I could submit a PR to Patrick's html-fund-me-fcc repo. Hope this helps! 😄 |
Beta Was this translation helpful? Give feedback.
-
Hi team, I made Minimum amount 0, it helped. But in metamask above the amount 0.5ETH i updated name to be "FUND", before there was questionmark which caused unrecongnized contract error. Here is screenshot after small update. May be it will help. |
Beta Was this translation helpful? Give feedback.
-
What eventually helped me is the following three:
|
Beta Was this translation helpful? Give feedback.
-
Hey I think this error is happening due to some glitch in the hardhat node environment. When I got this error, I tried everything, I stripped the function to bare bones, I also tried the above method, but nothing worked for me. I would also like to mention at this point that the smart contract I was working with is a different one, that does not have any payable functions. What fixed the problem for me was switching to a ganache for local testing. I reverted the contract to its original state and it worked flawlessly, without any errors. |
Beta Was this translation helpful? Give feedback.
Hi all, I'm enjoying Patrick's course along with you all! BTW great course, Patrick, thanks!! 👍
I've hit this issue as well, and I believe I've figured out what is going on. But I'm learning like many of you, so although I'm not 100% sure that this is the best solution, hopefully this reply makes sense and is helpful.
I started by
console.log
'ing some solidity special global vars from thefallback()
function. The piece that pointed me to the above functions wasmsg.sig
, which had various values whenfallback()
was called:0x01ffc9a7
,0x313ce567
, and0x95d89b41
. Googling "function signature 0x01ffc9a7" led me to the Ethereum Signature Database, for example this page for 0x01ffc9a7.support…