-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathether-store.sol
33 lines (29 loc) · 920 Bytes
/
ether-store.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
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
contract FeeCollector{
// create the variables we need
address public owner;
uint256 public balance;
// we initially equate the contract owner as owner
constructor (){
owner = msg.sender;
}
// this special function make ether transfer
receive() payable external {
balance += msg.value;
}
// and this performs the transfer of the amount entered to the entered address
function withDraw(uint _amount, address payable _destAddress) checkBalance(_amount) onlyOwner public{
_destAddress.transfer(_amount);
balance -= _amount;
}
// requirements
modifier onlyOwner{
require(msg.sender == owner, "You can't withdraw, you're not owner!");
_;
}
modifier checkBalance(uint _amount){
require(_amount <= balance, "Insufficient funds");
_;
}
}