-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsource code.txt
More file actions
280 lines (232 loc) · 9.98 KB
/
source code.txt
File metadata and controls
280 lines (232 loc) · 9.98 KB
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
pragma solidity ^0.4.24;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 result = a * b;
assert(a == 0 || result / a == b);
return result;
}
function div(uint256 a, uint256 b)internal pure returns (uint256) {
uint256 result = a / b;
return result;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 result = a + b;
assert(result >= a);
return result;
}
}
contract ERC20Basic {
uint256 public totalSupply;
event Transfer(address indexed from, address indexed to, uint256 value);
function balanceOf(address who) public view returns(uint256);
function transfer(address to, uint256 value) public returns(bool);
}
contract ERC20 is ERC20Basic {
event Approval(address indexed owner, address indexed spender, uint256 value);
function allowance(address owner, address spender) public view returns (uint256);
function approve(address spender, uint256 value) public returns (bool);
function transferFrom(address from, address to, uint256 value) public returns (bool);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
struct WalletData {
uint256 tokensAmount; //Tokens amount on wallet
uint256 freezedAmount; //Freezed tokens amount on wallet.
bool canFreezeTokens; //Is wallet can freeze tokens or not.
uint unfreezeDate; // Date when we can unfreeze tokens on wallet.
}
mapping(address => WalletData) wallets;
function transfer(address _to, uint256 _value) public notSender(_to) returns(bool) {
require(_to != address(0)
&& wallets[msg.sender].tokensAmount >= _value
&& checkIfCanUseTokens(msg.sender, _value));
uint256 amount = wallets[msg.sender].tokensAmount.sub(_value);
wallets[msg.sender].tokensAmount = amount;
wallets[_to].tokensAmount = wallets[_to].tokensAmount.add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns(uint256 balance) {
return wallets[_owner].tokensAmount;
}
// Check wallet on unfreeze tokens amount
function checkIfCanUseTokens(address _owner, uint256 _amount) internal view returns(bool) {
uint256 unfreezedAmount = wallets[_owner].tokensAmount - wallets[_owner].freezedAmount;
return _amount <= unfreezedAmount;
}
// Prevents user to send transaction on his own address
modifier notSender(address _owner) {
require(msg.sender != _owner);
_;
}
}
contract StandartToken is ERC20, BasicToken{
mapping (address => mapping (address => uint256)) allowed;
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0) &&
checkIfCanUseTokens(_from, _value) &&
_value <= wallets[_from].tokensAmount &&
_value <= allowed[_from][msg.sender]);
wallets[_from].tokensAmount = wallets[_from].tokensAmount.sub(_value);
wallets[_to].tokensAmount = wallets[_to].tokensAmount.add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
}
contract Ownable {
constructor() public {
owner = msg.sender;
}
event TransferOwnership(address indexed _previousOwner, address indexed _newOwner);
address public owner = 0x0;
//wallet that can change owner
address internal masterKey = 0x4977A392d8D207B49c7fDE8A6B91C23bCebE7291;
function transferOwnership(address _newOwner) public returns(bool);
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
}
contract FreezableToken is StandartToken, Ownable {
event ChangeFreezePermission(address indexed _owner, bool _permission);
event FreezeTokens(address indexed _owner, uint256 _freezeAmount);
event UnfreezeTokens(address indexed _owner, uint256 _unfreezeAmount);
// Give\deprive permission to a wallet for freeze tokens.
function giveFreezePermission(address[] _owners, bool _permission) public onlyOwner returns(bool) {
for (uint i = 0; i < _owners.length; i++) {
wallets[_owners[i]].canFreezeTokens = _permission;
emit ChangeFreezePermission(_owners[i], _permission);
}
return true;
}
function freezeAllowance(address _owner) public view returns(bool) {
return wallets[_owner].canFreezeTokens;
}
// Freeze tokens on sender wallet if have permission.
function freezeTokens(uint256 _amount, uint _unfreezeDate) public isFreezeAllowed returns(bool) {
//We can freeze tokens only if there are no frozen tokens on the wallet.
require(wallets[msg.sender].freezedAmount == 0
&& wallets[msg.sender].tokensAmount >= _amount);
wallets[msg.sender].freezedAmount = _amount;
wallets[msg.sender].unfreezeDate = _unfreezeDate;
emit FreezeTokens(msg.sender, _amount);
return true;
}
function showFreezedTokensAmount(address _owner) public view returns(uint256) {
return wallets[_owner].freezedAmount;
}
function unfreezeTokens() public returns(bool) {
require(wallets[msg.sender].freezedAmount > 0
&& now >= wallets[msg.sender].unfreezeDate);
emit UnfreezeTokens(msg.sender, wallets[msg.sender].freezedAmount);
wallets[msg.sender].freezedAmount = 0; // Unfreeze all tokens.
wallets[msg.sender].unfreezeDate = 0;
return true;
}
//Show date in UNIX time format.
function showTokensUnfreezeDate(address _owner) public view returns(uint) {
//If wallet don't have freezed tokens - function will return 0.
return wallets[_owner].unfreezeDate;
}
function getUnfreezedTokens(address _owner) internal view returns(uint256) {
return wallets[_owner].tokensAmount - wallets[_owner].freezedAmount;
}
modifier isFreezeAllowed() {
require(freezeAllowance(msg.sender));
_;
}
}
contract MultisendableToken is FreezableToken {
function massTransfer(address[] _addresses, uint[] _values) public onlyOwner returns(bool) {
for (uint i = 0; i < _addresses.length; i++) {
transferFromOwner(_addresses[i], _values[i]);
}
return true;
}
function massApprove(address[] _spenders, uint256[] _values) public returns (bool succes) {
for(uint i = 0; i < _spenders.length; i++) {
approve(_spenders[i], _values[i]);
}
return true;
}
function transferFromOwner(address _to, uint256 _value) internal notSender(_to) onlyOwner {
require(_to != address(0)
&& wallets[owner].tokensAmount >= _value
&& checkIfCanUseTokens(owner, _value));
wallets[owner].tokensAmount = wallets[owner].tokensAmount.sub(_value);
wallets[_to].tokensAmount = wallets[_to].tokensAmount.add(_value);
emit Transfer(owner, _to, _value);
}
}
contract CryptosoulToken is MultisendableToken {
event AllowMinting();
event Burn(address indexed _from, uint256 _value);
event Mint(address indexed _to, uint256 _value);
string constant public name = "CryptoSoul";
string constant public symbol = "SOUL";
uint constant public decimals = 18;
uint256 constant public START_TOKENS = 500000000 * 10**decimals; //500M start
uint256 constant public MINT_AMOUNT = 1370000 * 10**decimals;
uint256 constant public MINT_INTERVAL = 1 days; // 24 hours
uint256 constant private MAX_BALANCE_VALUE = 10000000000 * 10**decimals;
uint256 public nextMintPossibleDate = 0;
bool public canMint = false;
constructor() public {
wallets[owner].tokensAmount = START_TOKENS;
wallets[owner].canFreezeTokens = true;
totalSupply = START_TOKENS;
nextMintPossibleDate = 1538352000; //01.10.2018 (DD, MM, YYYY)
emit Mint(owner, START_TOKENS);
}
function allowMinting() public onlyOwner {
// Can start minting token after 01.10.2018
require(!canMint
&& now >= nextMintPossibleDate);
nextMintPossibleDate = now;
canMint = true;
emit AllowMinting();
}
function mint() public onlyOwner returns(bool) {
require(canMint
&& now >= nextMintPossibleDate
&& totalSupply + MINT_AMOUNT <= MAX_BALANCE_VALUE);
nextMintPossibleDate = nextMintPossibleDate.add(MINT_INTERVAL);
wallets[owner].tokensAmount = wallets[owner].tokensAmount.
add(MINT_AMOUNT);
totalSupply = totalSupply.add(MINT_AMOUNT);
emit Mint(owner, MINT_AMOUNT);
return true;
}
function burn(uint256 value) public onlyOwner returns(bool) {
require(checkIfCanUseTokens(owner, value)
&& wallets[owner].tokensAmount >= value);
wallets[owner].tokensAmount = wallets[owner].
tokensAmount.sub(value);
totalSupply = totalSupply.sub(value);
emit Burn(owner, value);
return true;
}
function transferOwnership(address _newOwner) public notSender(_newOwner) returns(bool) {
require(msg.sender == masterKey
&& _newOwner != address(0));
emit TransferOwnership(owner, _newOwner);
owner = _newOwner;
return true;
}
function() public payable {
revert();
}
}