-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFundMe.sol
44 lines (40 loc) · 1.27 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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import {priceConvertor} from "./GetConvertorLibrary.sol";
error notOwner();
contract FundMe{
address public immutable i_owner;
constructor(){
i_owner=msg.sender;
}
using priceConvertor for uint256;
address[] public funders;
mapping(address=>uint256) public addressToFundAmount;
function fund() public payable {
//require(msg.value.getConver()>0,"You cannot pay less than 1 ether");
if(msg.value.getConver()<5){
revert notOwner();
}
funders.push(msg.sender);
addressToFundAmount[msg.sender]=msg.value;
}
function Withraw() public Onlyowner {
for(uint256 funderIndex; funderIndex<funders.length;funderIndex++){
address funder=funders[funderIndex];
addressToFundAmount[funder]=0;
}
funders=new address[](0);
(bool calSucess,)=payable(msg.sender).call{value: address(this).balance}("");
require(calSucess,"Transaction Failed");
}
modifier Onlyowner{
require(i_owner==msg.sender,"Not the Owner");
_;
}
receive() external payable {
fund();
}
fallback() external payable {
fund();
}
}