-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfundMe.sol
50 lines (34 loc) · 1.19 KB
/
fundMe.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {priceConverter} from "./conversionRate.sol";
contract fundme{
using priceConverter for uint256;
uint public MINIMUM_USD = 5e18;
address [] public funders;
mapping ( address funder => uint256 amtFunded) public addressToAmountFunded;
address public owner;
constructor (){
owner = msg.sender;
}
function fund() public payable {
require (msg.value.getCoversionRate() >= MINIMUM_USD, "Not enough Eth");
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
}
// address : 0x694AA1769357215DE4FAC081bf1f309aDC325306
// abi
function withdraw() public onlyOwner {
for (uint funderIndex = 0; funderIndex < funders.length; funderIndex ++)
{
address funder = funders [funderIndex];
addressToAmountFunded [funder];
}
funders = new address[](0);
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
require(success, "Call failed");
}
modifier onlyOwner (){
require (msg.sender == owner, "must be a owner");
_;
}
}