-
Notifications
You must be signed in to change notification settings - Fork 0
/
erc20.sol
111 lines (79 loc) · 3.38 KB
/
erc20.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
pragma solidity ^0.4.18;
contract ERC20 {
function totalSupply() public constant returns (uint supply);
function balanceOf( address who ) public constant returns (uint value);
function allowance( address owner, address spender ) public constant returns (uint _allowance);
function transfer( address to, uint value) public returns (bool ok);
function transferFrom( address from, address to, uint value) public returns (bool ok);
function approve( address spender, uint value ) public returns (bool ok);
function transferByAuction(address bidder, address seller, uint price, uint fee) public returns (bool);
event Transfer( address indexed from, address indexed to, uint value);
event Approval( address indexed owner, address indexed spender, uint value);
}
/// @dev The uint of balance is 0.01 Token
contract CKToken is ERC20 {
address _cfo;
mapping (address => uint256) _balances;
uint256 _supply;
mapping (address => mapping (address => uint256)) _approvals;
address _saleAuction;
address _siringAuction;
function CKToken (uint256 supply) public {
_cfo = msg.sender;
_balances[_cfo] = supply;
_supply = supply;
}
modifier onlyCFO() {
require(msg.sender == _cfo);
_;
}
function setSaleAuctionAddress(address _address) external onlyCFO {
_saleAuction = _address;
}
function setSiringAuctionAddress(address _address) external onlyCFO {
_siringAuction = _address;
}
function totalSupply() public constant returns (uint256) {
return _supply;
}
function balanceOf(address src) public constant returns (uint256) {
return _balances[src];
}
function allowance(address src, address guy) public constant returns (uint256) {
return _approvals[src][guy];
}
function transfer(address dst, uint wad) public returns (bool) {
assert(_balances[msg.sender] >= wad);
_balances[msg.sender] = _balances[msg.sender] - wad;
_balances[dst] = _balances[dst] + wad;
Transfer(msg.sender, dst, wad);
return true;
}
function transferByAuction(address bidder, address seller, uint price, uint fee) public returns (bool) {
assert(msg.sender == _saleAuction || msg.sender == _siringAuction);
assert(_balances[bidder] >= price);
_balances[bidder] = _balances[bidder] - price;
_balances[seller] = _balances[seller] + price - fee;
_balances[_cfo] = _balances[_cfo] + fee;
Transfer(bidder, seller, price - fee);
Transfer(bidder, _cfo, fee);
return true;
}
function transferFrom(address src, address dst, uint wad) public returns (bool) {
assert(_balances[src] >= wad);
assert(_approvals[src][msg.sender] >= wad);
_approvals[src][msg.sender] = _approvals[src][msg.sender] - wad;
_balances[src] = _balances[src] - wad;
_balances[dst] = _balances[dst] + wad;
Transfer(src, dst, wad);
return true;
}
function approve(address guy, uint256 wad) public returns (bool) {
_approvals[msg.sender][guy] = wad;
Approval(msg.sender, guy, wad);
return true;
}
function getCFO() external view returns (address) {
return _cfo;
}
}