-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclickgemd.sol
251 lines (210 loc) · 7.33 KB
/
clickgemd.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
pragma solidity 0.4.25;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
// Used for function invoke restriction
contract Owned {
address public owner; // temporary address
constructor() internal {
owner = msg.sender;
}
modifier onlyOwner() {
if (msg.sender != owner)
revert();
_; // function code inserted here
}
function transferOwnership(address _newOwner) public onlyOwner returns (bool success) {
if (msg.sender != owner)
revert();
owner = _newOwner;
return true;
}
}
contract ClickGem is Owned {
using SafeMath for uint256;
uint256 public totalSupply;
uint8 public decimals;
string public name;
string public symbol;
bool public tokenIsFrozen;
bool public tokenMintingEnabled;
bool public contractLaunched;
bool public stakingStatus;
mapping (address => mapping (address => uint256)) public allowance;
mapping (address => uint256) public balances;
event Transfer(address indexed _sender, address indexed _recipient, uint256 _amount);
event Approve(address indexed _owner, address indexed _spender, uint256 _amount);
event LaunchContract(address indexed _launcher, bool _launched);
event FreezeTransfers(address indexed _invoker, bool _frozen);
event UnFreezeTransfers(address indexed _invoker, bool _thawed);
event MintTokens(address indexed _minter, uint256 _amount, bool indexed _minted);
event TokenMintingDisabled(address indexed _invoker, bool indexed _disabled);
event TokenMintingEnabled(address indexed _invoker, bool indexed _enabled);
constructor() public {
name = "ClickGem Token";
symbol = "CGMT";
decimals = 18;
totalSupply = 300000000000000000000000000000;
balances[msg.sender] = totalSupply;
tokenIsFrozen = false;
tokenMintingEnabled = false;
contractLaunched = false;
}
/// @notice Used to launch the contract, and enabled token minting
function launchContract() public onlyOwner {
require(!contractLaunched);
tokenIsFrozen = false;
tokenMintingEnabled = true;
contractLaunched = true;
emit LaunchContract(msg.sender, true);
}
function disableTokenMinting() public onlyOwner returns (bool disabled) {
tokenMintingEnabled = false;
emit TokenMintingDisabled(msg.sender, true);
return true;
}
function enableTokenMinting() public onlyOwner returns (bool enabled) {
tokenMintingEnabled = true;
emit TokenMintingEnabled(msg.sender, true);
return true;
}
/// @notice Used to transfer funds
/// @param _receiver Eth address to send TEMPLATE-TOKENToken tokens too
/// @param _amount The amount of TEMPLATE-TOKENToken tokens in wei to send
function transfer(address _receiver, uint256 _amount)
public
returns (bool success)
{
require(transferCheck(msg.sender, _receiver, _amount));
balances[msg.sender] = balances[msg.sender].sub(_amount);
balances[_receiver] = balances[_receiver].add(_amount);
emit Transfer(msg.sender, _receiver, _amount);
return true;
}
/// @notice Used to burn tokens and decrease total supply
/// @param _amount The amount of TEMPLATE-TOKENToken tokens in wei to burn
function tokenBurner(uint256 _amount) public
onlyOwner
returns (bool burned)
{
require(_amount > 0);
require(totalSupply.sub(_amount) > 0);
require(balances[msg.sender] > _amount);
require(balances[msg.sender].sub(_amount) > 0);
totalSupply = totalSupply.sub(_amount);
balances[msg.sender] = balances[msg.sender].sub(_amount);
emit Transfer(msg.sender, 0, _amount);
return true;
}
/// @notice Low level function Used to create new tokens and increase total supply
/// @param _amount The amount of TEMPLATE-TOKENToken tokens in wei to create
function tokenMinter(uint256 _amount)
internal
view
returns (bool valid)
{
require(tokenMintingEnabled);
require(_amount > 0);
require(totalSupply.add(_amount) > 0);
require(totalSupply.add(_amount) > totalSupply);
return true;
}
/// @notice Used to create new tokens and increase total supply
/// @param _amount The amount of TEMPLATE-TOKENToken tokens in wei to create
function tokenFactory(uint256 _amount) public
onlyOwner
returns (bool success)
{
require(tokenMinter(_amount));
totalSupply = totalSupply.add(_amount);
balances[msg.sender] = balances[msg.sender].add(_amount);
emit Transfer(0, msg.sender, _amount);
return true;
}
/// @notice Reusable code to do sanity check of transfer variables
function transferCheck(address _sender, address _receiver, uint256 _amount)
private
constant
returns (bool success)
{
require(!tokenIsFrozen);
require(_amount > 0);
require(_receiver != address(0));
require(balances[_sender].sub(_amount) >= 0);
require(balances[_receiver].add(_amount) > 0);
require(balances[_receiver].add(_amount) > balances[_receiver]);
return true;
}
/// @notice Used to retrieve total supply
function totalSupply()
public
constant
returns (uint256 _totalSupply)
{
return totalSupply;
}
/// @notice Used to look up balance of a person
function balanceOf(address _person)
public
constant
returns (uint256 _balance)
{
return balances[_person];
}
function AirDropper(address[] _to, uint256[] _value) public onlyOwner returns (bool) {
require(_to.length > 0);
require(_to.length == _value.length);
for (uint i = 0; i < _to.length; i++) {
if (transfer(_to[i], _value[i]) == false) {
return false;
}
}
return true;
}
/// @notice Used to look up the allowance of someone
function allowance(address _owner, address _spender)
public
constant
returns (uint256 _amount)
{
return allowance[_owner][_spender];
}
}