Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- contract Bank {
- address owner;
- mapping (address => uint) balances;
- // Constructor
- function Bank(){
- owner = msg.sender;
- }
- // This will take the value of the transaction and add to the senders account.
- function deposit(address customer) returns (bool res) {
- // If the amount they send is 0, return false.
- if (msg.value == 0){
- return false;
- }
- balances[customer] += msg.value;
- return true;
- }
- // Attempt to withdraw the given 'amount' of Ether from the account.
- function withdraw(address customer, uint amount) returns (bool res) {
- // Skip if someone tries to withdraw 0 or if they don't have
- // enough Ether to make the withdrawal.
- if (balances[customer] < amount || amount == 0)
- return false;
- balances[customer] -= amount;
- msg.sender.send(amount);
- return true;
- }
- function remove() {
- if (msg.sender == owner){
- selfdestruct(owner);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement