-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSETH.sol
77 lines (60 loc) · 2.25 KB
/
SETH.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
pragma solidity ^0.4.16;
contract SETH {
string public name = "S Ether";
string public symbol = "SETH";
uint256 public decimals = 18;
uint256 _supply;
mapping (address => uint256) _balances;
mapping (address => mapping (address => uint256)) _approvals;
event Approval(address indexed src, address indexed guy, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
event Deposit(address indexed dst, uint wad);
event Withdrawal(address indexed src, uint wad);
function SETH() public payable {
_balances[msg.sender] += msg.value;
_supply = add(_supply, msg.value);
Deposit(msg.sender, msg.value);
}
function withdraw(uint wad) public {
require(_balances[msg.sender] >= wad);
_balances[msg.sender] -= wad;
msg.sender.transfer(wad);
_supply = sub(_supply, wad);
Withdrawal(msg.sender, wad);
}
function transferFrom(address src, address dst, uint wad)
public
returns (bool)
{
if (src != msg.sender && _approvals[src][msg.sender] != uint(-1)) {
_approvals[src][msg.sender] = sub(_approvals[src][msg.sender], wad);
}
_balances[src] = sub(_balances[src], wad);
_balances[dst] = add(_balances[dst], wad);
Transfer(src, dst, wad);
return true;
}
function totalSupply() public view returns (uint) {
return _supply;
}
function balanceOf(address src) public view returns (uint) {
return _balances[src];
}
function allowance(address src, address guy) public view returns (uint) {
return _approvals[src][guy];
}
function transfer(address dst, uint wad) public returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
function approve(address guy, uint wad) public returns (bool) {
_approvals[msg.sender][guy] = wad;
Approval(msg.sender, guy, wad);
return true;
}
function add(uint x, uint y) internal returns (uint z) {
require((z = x + y) >= x);
}
function sub(uint x, uint y) internal returns (uint z) {
require((z = x - y) <= x);
}
}