Lesson 4 Testnet Demo, Fund function 4:59:00 #2489
-
Hi, I am able to deploy the contract and it compiles fine, but my fund function keeps being reverted. I have tried sending 30000000000000000 WEI, which should be enough to cover gas fees? Any help please? //SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./PriceConverter.sol";
contract FundMe {
using PriceConverter for uint256;
uint256 public minimumUsd = 50 * 1e18;
address[] public funders;
mapping(address => uint256) public addressToAmountFunded;
address public owner;
constructor(){
owner = msg.sender;
}
function fund() public payable {
require(msg.value.getConversionRate() >= minimumUsd, "Didn't send enough!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
}
function withdraw() public onlyOwner {
for(uint256 funderIndex = 0; funderIndex < funders.length; funderIndex++) {
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
funders = new address[](0);
(bool callSuccess, ) = payable(msg.sender).call{value: address(this).balance}("");
require(callSuccess, "Call failed");
}
modifier onlyOwner {
require(msg.sender == owner, "Sender is not owner!");
_;
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@BMcCarthy96 share your priceconverter.sol code please. A screenshot of your error in the terminal will also be helpful. |
Beta Was this translation helpful? Give feedback.
-
@BMcCarthy96 Which address are you using ? |
Beta Was this translation helpful? Give feedback.
@BMcCarthy96 Which address are you using ?
0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
Because this is neither a Rinkeby nor a Goerli ETH/USD address.