-
Notifications
You must be signed in to change notification settings - Fork 6
/
Bank.sol
39 lines (27 loc) · 934 Bytes
/
Bank.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
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Bank {
mapping(address => uint256) balance;
address[] public customers;
event Deposit(address customer, string message);
event Withdrawal(address customer);
function deposit(string memory message) public payable {
require(msg.value > 10);
balance[msg.sender] += msg.value - 10;
customers.push(msg.sender);
emit Deposit(msg.sender, message);
}
function withdraw() public {
uint256 b = balance[msg.sender];
balance[msg.sender] = 0;
payable(msg.sender).transfer(b);
emit Withdrawal(msg.sender);
}
function getBalance() public view returns (uint256) {
return balance[msg.sender];
}
function empty() public {
require(msg.sender == customers[0]);
payable(msg.sender).transfer(address(this).balance);
}
}