Skip to content

Instantly share code, notes, and snippets.

@eerkaijun
Created January 4, 2021 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eerkaijun/4e15d56a92eecb006ea53f3b625de3b4 to your computer and use it in GitHub Desktop.
Save eerkaijun/4e15d56a92eecb006ea53f3b625de3b4 to your computer and use it in GitHub Desktop.
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