Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. contract Bank {
  2.  
  3. address owner;
  4.  
  5. mapping (address => uint) balances;
  6.  
  7. // Constructor
  8. function Bank(){
  9. owner = msg.sender;
  10. }
  11.  
  12. // This will take the value of the transaction and add to the senders account.
  13. function deposit(address customer) returns (bool res) {
  14. // If the amount they send is 0, return false.
  15. if (msg.value == 0){
  16. return false;
  17. }
  18. balances[customer] += msg.value;
  19. return true;
  20. }
  21.  
  22. // Attempt to withdraw the given 'amount' of Ether from the account.
  23. function withdraw(address customer, uint amount) returns (bool res) {
  24. // Skip if someone tries to withdraw 0 or if they don't have
  25. // enough Ether to make the withdrawal.
  26. if (balances[customer] < amount || amount == 0)
  27. return false;
  28. balances[customer] -= amount;
  29. msg.sender.send(amount);
  30. return true;
  31. }
  32.  
  33. function remove() {
  34. if (msg.sender == owner){
  35. selfdestruct(owner);
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement