-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy path0xf8e386eda857484f5a12e4b5daa9984e06e73705-IND-Indorse.sol
307 lines (257 loc) · 12.3 KB
/
0xf8e386eda857484f5a12e4b5daa9984e06e73705-IND-Indorse.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
pragma solidity ^0.4.11;
// ================= Ownable Contract start =============================
/*
* Ownable
*
* Base contract with an owner.
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
*/
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
// ================= Ownable Contract end ===============================
// ================= Safemath Contract start ============================
/* taking ideas from FirstBlood token */
contract SafeMath {
function safeAdd(uint256 x, uint256 y) internal returns(uint256) {
uint256 z = x + y;
assert((z >= x) && (z >= y));
return z;
}
function safeSubtract(uint256 x, uint256 y) internal returns(uint256) {
assert(x >= y);
uint256 z = x - y;
return z;
}
function safeMult(uint256 x, uint256 y) internal returns(uint256) {
uint256 z = x * y;
assert((x == 0)||(z/x == y));
return z;
}
}
// ================= Safemath Contract end ==============================
// ================= ERC20 Token Contract start =========================
/*
* ERC20 interface
* see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 {
uint public totalSupply;
function balanceOf(address who) constant returns (uint);
function allowance(address owner, address spender) constant returns (uint);
function transfer(address to, uint value) returns (bool ok);
function transferFrom(address from, address to, uint value) returns (bool ok);
function approve(address spender, uint value) returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
// ================= ERC20 Token Contract end ===========================
// ================= Standard Token Contract start ======================
contract StandardToken is ERC20, SafeMath {
/**
* @dev Fix for the ERC20 short address attack.
*/
modifier onlyPayloadSize(uint size) {
require(msg.data.length >= size + 4) ;
_;
}
mapping(address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) returns (bool success){
balances[msg.sender] = safeSubtract(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) returns (bool success) {
var _allowance = allowed[_from][msg.sender];
// Check is not needed because safeSub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
balances[_to] = safeAdd(balances[_to], _value);
balances[_from] = safeSubtract(balances[_from], _value);
allowed[_from][msg.sender] = safeSubtract(_allowance, _value);
Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
function approve(address _spender, uint _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}
// ================= Standard Token Contract end ========================
// ================= Pausable Token Contract start ======================
/**
* @title Pausable
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev modifier to allow actions only when the contract IS paused
*/
modifier whenNotPaused() {
require (!paused);
_;
}
/**
* @dev modifier to allow actions only when the contract IS NOT paused
*/
modifier whenPaused {
require (paused) ;
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused returns (bool) {
paused = true;
Pause();
return true;
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused returns (bool) {
paused = false;
Unpause();
return true;
}
}
// ================= Pausable Token Contract end ========================
// ================= Indorse Token Contract start =======================
contract IndorseToken is SafeMath, StandardToken, Pausable {
// metadata
string public constant name = "Indorse Token";
string public constant symbol = "IND";
uint256 public constant decimals = 18;
string public version = "1.0";
// contracts
address public indSaleDeposit = 0x0053B91E38B207C97CBff06f48a0f7Ab2Dd81449; // deposit address for Indorse Sale contract
address public indSeedDeposit = 0x0083fdFB328fC8D07E2a7933e3013e181F9798Ad; // deposit address for Indorse Seed Contributors
address public indPresaleDeposit = 0x007AB99FBf023Cb41b50AE7D24621729295EdBFA; // deposit address for Indorse Presale Contributors
address public indVestingDeposit = 0x0011349f715cf59F75F0A00185e7B1c36f55C3ab; // deposit address for Indorse Vesting for team and advisors
address public indCommunityDeposit = 0x0097ec8840E682d058b24E6e19E68358d97A6E5C; // deposit address for Indorse Marketing, etc
address public indFutureDeposit = 0x00d1bCbCDE9Ca431f6dd92077dFaE98f94e446e4; // deposit address for Indorse Future token sale
address public indInflationDeposit = 0x00D31206E625F1f30039d1Fa472303E71317870A; // deposit address for Indorse Inflation pool
uint256 public constant indSale = 31603785 * 10**decimals;
uint256 public constant indSeed = 3566341 * 10**decimals;
uint256 public constant indPreSale = 22995270 * 10**decimals;
uint256 public constant indVesting = 28079514 * 10**decimals;
uint256 public constant indCommunity = 10919811 * 10**decimals;
uint256 public constant indFuture = 58832579 * 10**decimals;
uint256 public constant indInflation = 14624747 * 10**decimals;
// constructor
function IndorseToken()
{
balances[indSaleDeposit] = indSale; // Deposit IND share
balances[indSeedDeposit] = indSeed; // Deposit IND share
balances[indPresaleDeposit] = indPreSale; // Deposit IND future share
balances[indVestingDeposit] = indVesting; // Deposit IND future share
balances[indCommunityDeposit] = indCommunity; // Deposit IND future share
balances[indFutureDeposit] = indFuture; // Deposit IND future share
balances[indInflationDeposit] = indInflation; // Deposit for inflation
totalSupply = indSale + indSeed + indPreSale + indVesting + indCommunity + indFuture + indInflation;
Transfer(0x0,indSaleDeposit,indSale);
Transfer(0x0,indSeedDeposit,indSeed);
Transfer(0x0,indPresaleDeposit,indPreSale);
Transfer(0x0,indVestingDeposit,indVesting);
Transfer(0x0,indCommunityDeposit,indCommunity);
Transfer(0x0,indFutureDeposit,indFuture);
Transfer(0x0,indInflationDeposit,indInflation);
}
function transfer(address _to, uint _value) whenNotPaused returns (bool success) {
return super.transfer(_to,_value);
}
function approve(address _spender, uint _value) whenNotPaused returns (bool success) {
return super.approve(_spender,_value);
}
}
// ================= Indorse Token Contract end =======================
// ================= Actual Sale Contract Start ====================
contract IndorseSaleContract is Ownable,SafeMath,Pausable {
IndorseToken ind;
// crowdsale parameters
uint256 public fundingStartTime = 1502193600;
uint256 public fundingEndTime = 1504785600;
uint256 public totalSupply;
address public ethFundDeposit = 0x26967201d4D1e1aA97554838dEfA4fC4d010FF6F; // deposit address for ETH for Indorse Fund
address public indFundDeposit = 0x0053B91E38B207C97CBff06f48a0f7Ab2Dd81449; // deposit address for Indorse reserve
address public indAddress = 0xf8e386EDa857484f5a12e4B5DAa9984E06E73705;
bool public isFinalized; // switched to true in operational state
uint256 public constant decimals = 18; // #dp in Indorse contract
uint256 public tokenCreationCap;
uint256 public constant tokenExchangeRate = 1000; // 1000 IND tokens per 1 ETH
uint256 public constant minContribution = 0.05 ether;
uint256 public constant maxTokens = 1 * (10 ** 6) * 10**decimals;
uint256 public constant MAX_GAS_PRICE = 50000000000 wei; // maximum gas price for contribution transactions
function IndorseSaleContract() {
ind = IndorseToken(indAddress);
tokenCreationCap = ind.balanceOf(indFundDeposit);
isFinalized = false;
}
event MintIND(address from, address to, uint256 val);
event LogRefund(address indexed _to, uint256 _value);
function CreateIND(address to, uint256 val) internal returns (bool success){
MintIND(indFundDeposit,to,val);
return ind.transferFrom(indFundDeposit,to,val);
}
function () payable {
createTokens(msg.sender,msg.value);
}
/// @dev Accepts ether and creates new IND tokens.
function createTokens(address _beneficiary, uint256 _value) internal whenNotPaused {
require (tokenCreationCap > totalSupply); // CAP reached no more please
require (now >= fundingStartTime);
require (now <= fundingEndTime);
require (_value >= minContribution); // To avoid spam transactions on the network
require (!isFinalized);
require (tx.gasprice <= MAX_GAS_PRICE);
uint256 tokens = safeMult(_value, tokenExchangeRate); // check that we're not over totals
uint256 checkedSupply = safeAdd(totalSupply, tokens);
require (ind.balanceOf(msg.sender) + tokens <= maxTokens);
// DA 8/6/2017 to fairly allocate the last few tokens
if (tokenCreationCap < checkedSupply) {
uint256 tokensToAllocate = safeSubtract(tokenCreationCap,totalSupply);
uint256 tokensToRefund = safeSubtract(tokens,tokensToAllocate);
totalSupply = tokenCreationCap;
uint256 etherToRefund = tokensToRefund / tokenExchangeRate;
require(CreateIND(_beneficiary,tokensToAllocate)); // Create IND
msg.sender.transfer(etherToRefund);
LogRefund(msg.sender,etherToRefund);
ethFundDeposit.transfer(this.balance);
return;
}
// DA 8/6/2017 end of fair allocation code
totalSupply = checkedSupply;
require(CreateIND(_beneficiary, tokens)); // logs token creation
ethFundDeposit.transfer(this.balance);
}
/// @dev Ends the funding period and sends the ETH home
function finalize() external onlyOwner {
require (!isFinalized);
// move to operational
isFinalized = true;
ethFundDeposit.transfer(this.balance); // send the eth to Indorse multi-sig
}
}