-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFundMe.sol
More file actions
38 lines (28 loc) · 922 Bytes
/
FundMe.sol
File metadata and controls
38 lines (28 loc) · 922 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
//import "./PriceConverter.sol";
contract FundMe{
address[] public funders;
mapping(address => uint256) public addresstoAmountFunded;
address public owner;
constructor(){
owner = msg.sender;
}
error MustBeOwner();
error Transactionfailed();
modifier onlyOwner(){
require(msg.sender == owner, MustBeOwner());
_;
}
function fund() public payable{
funders.push(msg.sender);
addresstoAmountFunded[msg.sender] += msg.value;
}
function withdraw(uint256 amount) public onlyOwner{
addresstoAmountFunded[msg.sender] -= amount;
(bool success, ) = msg.sender.call{value: amount}("");
require(success, Transactionfailed());
}
receive() external payable { fund(); }
fallback() external payable { fund(); }
}