-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy path0xc12d099be31567add4e4e4d0d45691c3f58f5663-AUC-Auctus.sol
194 lines (156 loc) · 6.03 KB
/
0xc12d099be31567add4e4e4d0d45691c3f58f5663-AUC-Auctus.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
pragma solidity ^0.4.21;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(a <= c);
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(a >= b);
return a - b;
}
}
contract EthereumStandards {
/* Implements ERC 20 standard */
uint256 public totalSupply;
function balanceOf(address who) public constant returns (uint256);
function allowance(address owner, address spender) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
function transferFrom(address from, address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
/* Added support for the ERC 223 */
function transfer(address to, uint256 value, bytes data) public returns (bool);
function transfer(address to, uint256 value, bytes data, string custom_fallback) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value, bytes indexed data);
}
contract ContractReceiver {
function tokenFallback(address from, uint256 value, bytes data) public;
}
contract AuctusToken is EthereumStandards {
using SafeMath for uint256;
string constant public name = "Auctus Token";
string constant public symbol = "AUC";
uint8 constant public decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowed;
address public contractOwner;
address public tokenSaleContract;
address public preSaleDistributionContract;
bool public tokenSaleIsFinished;
event Burn(address indexed from, uint256 value);
modifier onlyOwner() {
require(contractOwner == msg.sender);
_;
}
function AuctusToken() public {
contractOwner = msg.sender;
tokenSaleContract = address(0);
tokenSaleIsFinished = false;
}
function balanceOf(address who) public constant returns (uint256) {
return balances[who];
}
function allowance(address owner, address spender) public constant returns (uint256) {
return allowed[owner][spender];
}
function approve(address spender, uint256 value) public returns (bool) {
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function increaseApproval(address spender, uint256 value) public returns (bool) {
allowed[msg.sender][spender] = allowed[msg.sender][spender].add(value);
emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
return true;
}
function decreaseApproval(address spender, uint256 value) public returns (bool) {
uint256 currentValue = allowed[msg.sender][spender];
if (value > currentValue) {
allowed[msg.sender][spender] = 0;
} else {
allowed[msg.sender][spender] = currentValue.sub(value);
}
emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
return true;
}
function transferFrom(address from, address to, uint256 value) public returns (bool) {
allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
internalTransfer(from, to, value);
emit Transfer(from, to, value);
return true;
}
function transfer(address to, uint256 value) public returns (bool) {
internalTransfer(msg.sender, to, value);
emit Transfer(msg.sender, to, value);
return true;
}
function transfer(address to, uint256 value, bytes data) public returns (bool) {
internalTransfer(msg.sender, to, value);
if (isContract(to)) {
callTokenFallback(to, msg.sender, value, data);
}
emit Transfer(msg.sender, to, value, data);
return true;
}
function transfer(address to, uint256 value, bytes data, string custom_fallback) public returns (bool) {
internalTransfer(msg.sender, to, value);
if (isContract(to)) {
assert(to.call.value(0)(bytes4(keccak256(custom_fallback)), msg.sender, value, data));
}
emit Transfer(msg.sender, to, value, data);
return true;
}
function burn(uint256 value) public returns (bool) {
internalBurn(msg.sender, value);
return true;
}
function burnFrom(address from, uint256 value) public returns (bool) {
allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
internalBurn(from, value);
return true;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
contractOwner = newOwner;
}
function setTokenSale(address tokenSale, address preSaleDistribution, uint256 maximumSupply) onlyOwner public {
require(tokenSaleContract == address(0));
preSaleDistributionContract = preSaleDistribution;
tokenSaleContract = tokenSale;
totalSupply = maximumSupply;
balances[tokenSale] = maximumSupply;
bytes memory empty;
callTokenFallback(tokenSale, 0x0, maximumSupply, empty);
emit Transfer(0x0, tokenSale, maximumSupply);
}
function setTokenSaleFinished() public {
require(msg.sender == tokenSaleContract);
tokenSaleIsFinished = true;
}
function isContract(address _address) private constant returns (bool) {
uint256 length;
assembly {
length := extcodesize(_address)
}
return (length > 0);
}
function internalTransfer(address from, address to, uint256 value) private {
require(canTransfer(from));
balances[from] = balances[from].sub(value);
balances[to] = balances[to].add(value);
}
function internalBurn(address from, uint256 value) private {
balances[from] = balances[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Burn(from, value);
}
function callTokenFallback(address to, address from, uint256 value, bytes data) private {
ContractReceiver(to).tokenFallback(from, value, data);
}
function canTransfer(address from) private view returns (bool) {
return (tokenSaleIsFinished || from == tokenSaleContract || from == preSaleDistributionContract);
}
}