-
Notifications
You must be signed in to change notification settings - Fork 1
/
12_Savings.sol
50 lines (40 loc) · 1.07 KB
/
12_Savings.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
40
41
42
43
44
45
46
47
48
49
50
/**
*
* Savings
*
* Este contrato sirve para crear una cuenta de ahorros en la que solo el propietario puede
* consultar el balance, añadir o retirar fondos.
*
**/
pragma solidity ^0.4.0;
contract Savings {
address owner;
event UpdateStatus(string _msg);
event UserStatus(string _msg, address user, uint amount);
function Savings() {
owner = msg.sender;
}
modifier onlyOwner() {
if (owner != msg.sender) {
revert();
} else {
_;
}
}
function kill() onlyOwner {
suicide(owner);
}
function depositFunds(uint amount) payable {
if (owner.send(amount)) {
UserStatus('User has deposit some money!', msg.sender, msg.value);
}
}
function withdrawFunds(uint amount) onlyOwner {
if (owner.send(amount)) {
UpdateStatus('User withdraw some money!');
}
}
function getFunds() onlyOwner constant returns(uint) {
return this.balance;
}
}