@@ -14,6 +14,7 @@ contract Owner {
14
14
}
15
15
16
16
function changeOwner (address _newOwnerAddr ) public onlyOwner {
17
+ require (_newOwnerAddr != address (0 ));
17
18
owner = _newOwnerAddr;
18
19
}
19
20
}
@@ -71,59 +72,56 @@ contract GreenX is Owner {
71
72
string public constant name = "GREENX " ;
72
73
string public constant symbol = "GEX " ;
73
74
uint public constant decimals = 18 ;
74
- uint256 constant public totalSupply = 375000000 * 10 ** 18 ; // 375 mil tokens will be created
75
+ uint256 constant public totalSupply = 375000000 * 10 ** 18 ; // 375 mil tokens will be supplied
75
76
76
- mapping (address => uint256 ) balances;
77
+ mapping (address => uint256 ) internal balances;
77
78
mapping (address => mapping (address => uint256 )) internal allowed;
78
79
79
80
address public portalAddress;
80
81
address public adminAddress;
81
- address public wallet ;
82
+ address public walletAddress ;
82
83
address public founderAddress;
83
84
address public teamAddress;
84
85
85
86
mapping (address => bool ) public privateList;
86
87
mapping (address => bool ) public whiteList;
87
88
mapping (address => uint256 ) public totalInvestedAmountOf;
88
89
89
- uint saleState;
90
- uint public icoStartTime;
91
- uint public icoEndTime;
92
- bool public inActive;
93
- bool public isSelling;
94
- bool public isTransferable;
95
-
96
- uint constant NOT_SALE = 0 ; // not in sales
97
- uint constant IN_PRIVATE_SALE = 1 ; // in private sales
98
- uint constant IN_PRESALE = 2 ; // in presales
99
- uint constant END_PRESALE = 3 ; // end presales
100
- uint constant IN_1ST_ICO = 4 ; // in ICO 1st round
101
- uint constant IN_2ND_ICO = 5 ; // in ICO 2nd round
102
- uint constant IN_3RD_ICO = 6 ; // in ICO 3rd round
103
- uint constant END_SALE = 7 ; // end sales
104
-
105
- uint founderAllocatedTime = 1 ;
106
- uint teamAllocatedTime = 1 ;
107
90
uint constant lockPeriod1 = 180 days ; // 1st locked period for tokens allocation of founder and team
108
91
uint constant lockPeriod2 = 1 years; // 2nd locked period for tokens allocation of founder and team
109
92
uint constant lockPeriod3 = 2 years; // locked period for remaining sale tokens after ending ICO
93
+ uint constant NOT_SALE = 0 ; // Not in sales
94
+ uint constant IN_PRIVATE_SALE = 1 ; // In private sales
95
+ uint constant IN_PRESALE = 2 ; // In presales
96
+ uint constant END_PRESALE = 3 ; // End presales
97
+ uint constant IN_1ST_ICO = 4 ; // In ICO 1st round
98
+ uint constant IN_2ND_ICO = 5 ; // In ICO 2nd round
99
+ uint constant IN_3RD_ICO = 6 ; // In ICO 3rd round
100
+ uint constant END_SALE = 7 ; // End sales
110
101
111
102
uint256 public constant salesAllocation = 187500000 * 10 ** 18 ; // 187.5 mil tokens allocated for sales
112
103
uint256 public constant bonusAllocation = 37500000 * 10 ** 18 ; // 37.5 mil tokens allocated for token sale bonuses
113
104
uint256 public constant reservedAllocation = 90000000 * 10 ** 18 ; // 90 mil tokens allocated for reserved, bounty campaigns, ICO partners, and bonus fund
114
105
uint256 public constant founderAllocation = 37500000 * 10 ** 18 ; // 37.5 mil tokens allocated for founders
115
106
uint256 public constant teamAllocation = 22500000 * 10 ** 18 ; // 22.5 mil tokens allocated for team
116
- uint256 public constant minInvestedCap = 2500 * 10 ** 18 ; // If this softcap will not be reached till end time, investors can refund ether
117
- uint256 public constant minInvestedAmount = 0.1 * 10 ** 18 ; // Mininum ether contribution per transaction
118
-
107
+ uint256 public constant minInvestedCap = 2500 * 10 ** 18 ; // 2500 ether for softcap
108
+ uint256 public constant minInvestedAmount = 0.1 * 10 ** 18 ; // 0.1 ether for mininum ether contribution per transaction
109
+
110
+ uint saleState;
111
+ uint256 totalInvestedAmount;
112
+ uint public icoStartTime;
113
+ uint public icoEndTime;
114
+ bool public inActive;
115
+ bool public isSelling;
116
+ bool public isTransferable;
117
+ uint public founderAllocatedTime = 1 ;
118
+ uint public teamAllocatedTime = 1 ;
119
119
uint256 public privateSalePrice;
120
120
uint256 public preSalePrice;
121
121
uint256 public icoStandardPrice;
122
122
uint256 public ico1stPrice;
123
123
uint256 public ico2ndPrice;
124
-
125
- uint256 totalInvestedAmount;
126
- uint256 public totalRemainingTokensForSales; // Total tokens remain for sales
124
+ uint256 public totalRemainingTokensForSales; // Total tokens remaining for sales
127
125
uint256 public totalReservedAndBonusTokenAllocation; // Total tokens allocated for reserved and bonuses
128
126
uint256 public totalLoadedRefund; // Total ether will be loaded to contract for refund
129
127
uint256 public totalRefundedAmount; // Total ether refunded to investors
@@ -141,10 +139,10 @@ contract GreenX is Owner {
141
139
142
140
event SetPrivateSalePrice (uint256 price ); // Set private sale price
143
141
event SetPreSalePrice (uint256 price ); // Set presale price
144
- event SetICOPrice (uint256 price ); // Set ICO sale prices
142
+ event SetICOPrice (uint256 price ); // Set ICO standard price
145
143
146
144
event IssueTokens (address investorAddress , uint256 amount , uint256 tokenAmount , uint state ); // Issue tokens to investor
147
- event RevokeTokens (address investorAddress , uint256 amount , uint256 tokenAmount , uint256 txFee ); // Revoke tokens after ending ICO for uncompleted KYC investors
145
+ event RevokeTokens (address investorAddress , uint256 amount , uint256 tokenAmount , uint256 txFee ); // Revoke tokens after ending ICO for incompleted KYC investors
148
146
event AllocateTokensForFounder (address founderAddress , uint256 founderAllocatedTime , uint256 tokenAmount ); // Allocate tokens to founders' address
149
147
event AllocateTokensForTeam (address teamAddress , uint256 teamAllocatedTime , uint256 tokenAmount ); // Allocate tokens to team's address
150
148
event AllocateReservedTokens (address reservedAddress , uint256 tokenAmount ); // Allocate reserved tokens
@@ -175,8 +173,11 @@ contract GreenX is Owner {
175
173
_;
176
174
}
177
175
178
- function GreenX (address _fundAddr , address _adminAddr , address _portalAddr ) public Owner (msg .sender ) {
179
- wallet = _fundAddr;
176
+ function GreenX (address _walletAddr , address _adminAddr , address _portalAddr ) public Owner (msg .sender ) {
177
+ require (_walletAddr != address (0 ));
178
+ require (_adminAddr != address (0 ));
179
+ require (_portalAddr != address (0 ));
180
+ walletAddress = _walletAddr;
180
181
adminAddress = _adminAddr;
181
182
portalAddress = _portalAddr;
182
183
inActive = true ;
@@ -204,27 +205,30 @@ contract GreenX is Owner {
204
205
revert ();
205
206
}
206
207
207
- // Load ether amount to contract for refuding or revoking
208
- function loadFund () external payable isActive {
208
+ // Load ether amount to contract for refunding or revoking
209
+ function loadFund () external payable {
209
210
require (msg .value > 0 );
210
211
totalLoadedRefund = totalLoadedRefund.add (msg .value );
211
212
}
212
213
213
214
// ERC20 standard function
214
- function transfer (address _to , uint256 _value ) external transferable isActive returns (bool ) {
215
+ function transfer (address _to , uint256 _value ) external transferable returns (bool ) {
215
216
require (_to != address (0 ));
216
- require (_value <= balances[msg .sender ]);
217
+ require (_value > 0 );
218
+ // require(_value <= balances[msg.sender]);
217
219
balances[msg .sender ] = balances[msg .sender ].sub (_value);
218
220
balances[_to] = balances[_to].add (_value);
219
221
emit Transfer (msg .sender , _to, _value);
220
222
return true ;
221
223
}
222
224
223
225
// ERC20 standard function
224
- function transferFrom (address _from , address _to , uint256 _value ) external transferable isActive returns (bool ) {
226
+ function transferFrom (address _from , address _to , uint256 _value ) external transferable returns (bool ) {
225
227
require (_to != address (0 ));
226
- require (_value <= balances[_from]);
227
- require (_value <= allowed[_from][msg .sender ]);
228
+ require (_from != address (0 ));
229
+ require (_value > 0 );
230
+ // require(_value <= balances[_from]);
231
+ // require(_value <= allowed[_from][msg.sender]);
228
232
balances[_from] = balances[_from].sub (_value);
229
233
balances[_to] = balances[_to].add (_value);
230
234
allowed[_from][msg .sender ] = allowed[_from][msg .sender ].sub (_value);
@@ -233,7 +237,9 @@ contract GreenX is Owner {
233
237
}
234
238
235
239
// ERC20 standard function
236
- function approve (address _spender , uint256 _value ) external transferable isActive returns (bool ) {
240
+ function approve (address _spender , uint256 _value ) external transferable returns (bool ) {
241
+ require (_spender != address (0 ));
242
+ require (_value > 0 );
237
243
allowed[msg .sender ][_spender] = _value;
238
244
emit Approval (msg .sender , _spender, _value);
239
245
return true ;
@@ -251,7 +257,7 @@ contract GreenX is Owner {
251
257
// Modify private list
252
258
function modifyPrivateList (address [] _investorAddrs , bool _isPrivateListed ) external isActive onlyOwnerOrAdminOrPortal returns (bool ) {
253
259
for (uint256 i = 0 ; i < _investorAddrs.length ; i++ ) {
254
- whiteList [_investorAddrs[i]] = _isPrivateListed;
260
+ privateList [_investorAddrs[i]] = _isPrivateListed;
255
261
emit ModifyPrivateList (_investorAddrs[i], _isPrivateListed);
256
262
}
257
263
return true ;
@@ -270,7 +276,7 @@ contract GreenX is Owner {
270
276
// Start presales
271
277
function startPreSales () external isActive onlyOwnerOrAdmin returns (bool ) {
272
278
require (saleState < IN_PRESALE);
273
- require (preSalePrice != 0 );
279
+ require (preSalePrice > 0 );
274
280
saleState = IN_PRESALE;
275
281
isSelling = true ;
276
282
emit StartPresales (saleState);
@@ -289,6 +295,7 @@ contract GreenX is Owner {
289
295
// Start ICO
290
296
function startICO () external isActive onlyOwnerOrAdmin returns (bool ) {
291
297
require (saleState == END_PRESALE);
298
+ require (icoStandardPrice > 0 );
292
299
saleState = IN_1ST_ICO;
293
300
icoStartTime = now ;
294
301
isSelling = true ;
@@ -309,20 +316,23 @@ contract GreenX is Owner {
309
316
310
317
// Set private sales price
311
318
function setPrivateSalePrice (uint256 _tokenPerEther ) external onlyOwnerOrAdmin returns (bool ) {
319
+ require (_tokenPerEther > 0 );
312
320
privateSalePrice = _tokenPerEther;
313
321
emit SetPrivateSalePrice (privateSalePrice);
314
322
return true ;
315
323
}
316
324
317
325
// Set presales price
318
326
function setPreSalePrice (uint256 _tokenPerEther ) external onlyOwnerOrAdmin returns (bool ) {
327
+ require (_tokenPerEther > 0 );
319
328
preSalePrice = _tokenPerEther;
320
329
emit SetPreSalePrice (preSalePrice);
321
330
return true ;
322
331
}
323
332
324
333
// Set ICO price including ICO standard price, ICO 1st round price, ICO 2nd round price
325
334
function setICOPrice (uint256 _tokenPerEther ) external onlyOwnerOrAdmin returns (bool ) {
335
+ require (_tokenPerEther > 0 );
326
336
icoStandardPrice = _tokenPerEther;
327
337
ico1stPrice = _tokenPerEther + _tokenPerEther * 20 / 100 ;
328
338
ico2ndPrice = _tokenPerEther + _tokenPerEther * 10 / 100 ;
@@ -331,11 +341,13 @@ contract GreenX is Owner {
331
341
}
332
342
333
343
// Revoke tokens from incompleted KYC investors' addresses
334
- function revokeTokens (address _noneKycAddr , uint256 _transactionFee ) external isActive onlyOwnerOrAdmin {
344
+ function revokeTokens (address _noneKycAddr , uint256 _transactionFee ) external onlyOwnerOrAdmin {
345
+ require (_noneKycAddr != address (0 ));
335
346
uint256 investedAmount = totalInvestedAmountOf[_noneKycAddr];
336
347
uint256 totalRemainingRefund = totalLoadedRefund.sub (totalRefundedAmount);
337
348
require (whiteList[_noneKycAddr] == false && privateList[_noneKycAddr] == false );
338
- require (investedAmount > 0 && investedAmount >= _transactionFee);
349
+ // require(investedAmount > 0 && investedAmount >= _transactionFee);
350
+ require (investedAmount > 0 );
339
351
require (totalRemainingRefund >= investedAmount);
340
352
require (saleState == END_SALE);
341
353
uint256 refundAmount = investedAmount.sub (_transactionFee);
@@ -349,7 +361,7 @@ contract GreenX is Owner {
349
361
}
350
362
351
363
// Investors can claim ether refund if total raised fund doesn't reach our softcap
352
- function refund () external isActive {
364
+ function refund () external {
353
365
uint256 refundedAmount = totalInvestedAmountOf[msg .sender ];
354
366
uint256 totalRemainingRefund = totalLoadedRefund.sub (totalRefundedAmount);
355
367
uint256 tokenRevoked = balances[msg .sender ];
@@ -364,42 +376,52 @@ contract GreenX is Owner {
364
376
emit Refund (msg .sender , refundedAmount, tokenRevoked);
365
377
}
366
378
367
- // Activate contract after deploying successfully
379
+ // Activate token sale function
368
380
function activate () external onlyOwner {
369
381
inActive = false ;
370
382
}
371
383
384
+ // Deacivate token sale function
385
+ function deActivate () external onlyOwner {
386
+ inActive = true ;
387
+ }
388
+
372
389
// Enable transfer feature of tokens
373
- function enableTokenTransfer () external onlyOwner {
390
+ function enableTokenTransfer () external isActive onlyOwner {
374
391
isTransferable = true ;
375
392
}
376
393
377
394
// Modify wallet
378
395
function changeWallet (address _newAddress ) external onlyOwner {
379
- require (wallet != _newAddress);
380
- wallet = _newAddress;
396
+ require (_newAddress != address (0 ));
397
+ require (walletAddress != _newAddress);
398
+ walletAddress = _newAddress;
381
399
}
382
400
383
401
// Modify admin
384
402
function changeAdminAddress (address _newAddress ) external onlyOwner {
403
+ require (_newAddress != address (0 ));
385
404
require (adminAddress != _newAddress);
386
405
adminAddress = _newAddress;
387
406
}
388
407
389
408
// Modify portal
390
409
function changePortalAddress (address _newAddress ) external onlyOwner {
410
+ require (_newAddress != address (0 ));
391
411
require (portalAddress != _newAddress);
392
412
portalAddress = _newAddress;
393
413
}
394
414
395
415
// Modify founder address to receive founder tokens allocation
396
416
function changeFounderAddress (address _newAddress ) external onlyOwnerOrAdmin {
417
+ require (_newAddress != address (0 ));
397
418
require (founderAddress != _newAddress);
398
419
founderAddress = _newAddress;
399
420
}
400
421
401
422
// Modify team address to receive team tokens allocation
402
423
function changeTeamAddress (address _newAddress ) external onlyOwnerOrAdmin {
424
+ require (_newAddress != address (0 ));
403
425
require (teamAddress != _newAddress);
404
426
teamAddress = _newAddress;
405
427
}
@@ -429,6 +451,7 @@ contract GreenX is Owner {
429
451
amount = founderAllocation * 50 / 100 ;
430
452
balances[founderAddress] = balances[founderAddress].add (amount);
431
453
emit AllocateTokensForFounder (founderAddress, founderAllocatedTime, amount);
454
+ founderAllocatedTime = 4 ;
432
455
return ;
433
456
}
434
457
revert ();
@@ -459,30 +482,32 @@ contract GreenX is Owner {
459
482
amount = teamAllocation * 50 / 100 ;
460
483
balances[teamAddress] = balances[teamAddress].add (amount);
461
484
emit AllocateTokensForTeam (teamAddress, teamAllocatedTime, amount);
485
+ teamAllocatedTime = 4 ;
462
486
return ;
463
487
}
464
488
revert ();
465
489
}
466
490
467
491
// Remaining tokens for sales will be locked by contract in 2 years
468
492
function allocateRemainingTokens (address _addr ) external isActive onlyOwnerOrAdmin {
493
+ require (_addr != address (0 ));
469
494
require (saleState == END_SALE);
470
495
require (totalRemainingTokensForSales > 0 );
471
496
require (now >= icoEndTime + lockPeriod3);
472
- require (_addr != address (0 ));
473
497
balances[_addr] = balances[_addr].add (totalRemainingTokensForSales);
474
498
totalRemainingTokensForSales = 0 ;
475
499
}
476
500
477
501
// Allocate reserved tokens
478
- function allocateReservedTokens (address _addr , uint amount ) external isActive onlyOwnerOrAdmin {
502
+ function allocateReservedTokens (address _addr , uint _amount ) external isActive onlyOwnerOrAdmin {
479
503
require (saleState == END_SALE);
480
- require (totalReservedAndBonusTokenAllocation > 0 );
481
- require (totalReservedAndBonusTokenAllocation >= amount);
504
+ // require(totalReservedAndBonusTokenAllocation > 0);
505
+ // require(totalReservedAndBonusTokenAllocation >= amount);
506
+ require (_amount > 0 );
482
507
require (_addr != address (0 ));
483
- balances[_addr] = balances[_addr].add (amount );
484
- totalReservedAndBonusTokenAllocation = totalReservedAndBonusTokenAllocation.sub (amount );
485
- emit AllocateReservedTokens (_addr, amount );
508
+ balances[_addr] = balances[_addr].add (_amount );
509
+ totalReservedAndBonusTokenAllocation = totalReservedAndBonusTokenAllocation.sub (_amount );
510
+ emit AllocateReservedTokens (_addr, _amount );
486
511
}
487
512
488
513
// ERC20 standard function
@@ -539,17 +564,17 @@ contract GreenX is Owner {
539
564
540
565
// Issue tokens to investors and transfer ether to wallet
541
566
function issueTokens (uint256 _price , uint _state ) private {
542
- require (wallet != address (0 ));
567
+ require (walletAddress != address (0 ));
543
568
uint tokenAmount = msg .value .mul (_price).mul (10 ** 18 ).div (1 ether);
544
- require (totalRemainingTokensForSales >= tokenAmount);
569
+ // require(totalRemainingTokensForSales >= tokenAmount);
545
570
balances[msg .sender ] = balances[msg .sender ].add (tokenAmount);
546
571
totalInvestedAmountOf[msg .sender ] = totalInvestedAmountOf[msg .sender ].add (msg .value );
547
572
totalRemainingTokensForSales = totalRemainingTokensForSales.sub (tokenAmount);
548
573
totalInvestedAmount = totalInvestedAmount.add (msg .value );
549
- wallet .transfer (msg .value );
574
+ walletAddress .transfer (msg .value );
550
575
emit IssueTokens (msg .sender , msg .value , tokenAmount, _state);
551
576
}
552
-
577
+
553
578
// ForTestOnly
554
579
function checkTokenAllocation () public view returns (bool ) {
555
580
uint256 totalTokenAllocation = salesAllocation + bonusAllocation + reservedAllocation + founderAllocation + teamAllocation;
@@ -565,7 +590,7 @@ contract GreenX is Owner {
565
590
}
566
591
567
592
// ForTestOnly
568
- function decreaseICOEndTimeForTestOnly (uint256 day ) public {
593
+ function decreaseICOEndTime (uint256 day ) public {
569
594
icoEndTime = icoEndTime - day * 1 days ;
570
595
}
571
- }
596
+ }
0 commit comments