Created
January 4, 2021 23:21
-
-
Save eerkaijun/4e15d56a92eecb006ea53f3b625de3b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.4.22 <0.7.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; | |
msg.sender.transfer(b); | |
emit Withdrawal(msg.sender); | |
} | |
function getBalance() public view returns (uint256) { | |
return balance[msg.sender]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment