im having issues #6681
femiopebiyi
started this conversation in
General
Replies: 2 comments
-
Mate, could you please format the question well and mention what is the issue so that the community can help you solve it |
Beta Was this translation helpful? Give feedback.
0 replies
-
pragma solidity ^0.8.0;
contract FundMe {
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
uint256 public minimumUsd = 50 * 10 ** 18; // Example minimum value in Wei
constructor() {
owner = msg.sender;
}
function fund() public payable {
// Set minimum fund amount
require(getConversionRate(msg.value) >= minimumUsd, "Didn't send enough!");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
}
function getConversionRate(uint256 ethAmount) public view returns (uint256) {
// Mock conversion rate, replace with real conversion logic
uint256 ethPrice = 2000 * 10 ** 18; // Example ETH price in USD (scaled)
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 10 ** 18;
return ethAmountInUsd;
}
modifier onlyOwner() {
require(msg.sender == owner, "You are not the owner!");
_;
}
function withdraw() public onlyOwner {
for (uint256 i = 0; i < funders.length; i++) {
address funder = funders[i];
addressToAmountFunded[funder] = 0;
}
// Reset the array
funders = new address ;
// Transfer balance to the owner
payable(owner).transfer(address(this).balance);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions