-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy path0xc3951d77737733174152532e8b0f27e2c4e9f0dc-CLD-Cloud.sol
191 lines (162 loc) · 7.54 KB
/
0xc3951d77737733174152532e8b0f27e2c4e9f0dc-CLD-Cloud.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
pragma solidity ^0.4.16;
library Math {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant 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 c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Token {
/// total amount of tokens
uint256 public totalSupply;
uint256 public decimals;
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract Cloud is Token {
using Math for uint256;
bool trading=false;
mapping (address => bool) public frozenAccount;
event FrozenFunds(address target, bool frozen);
function transfer(address _to, uint256 _value) canTrade returns (bool success) {
require(_value > 0);
require(!frozenAccount[msg.sender]);
require(balances[msg.sender] >= _value);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) canTrade returns (bool success) {
require(_value > 0);
require(!frozenAccount[_from]);
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value);
//require(balances[_from] >= _value);
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/* Checks if tokens can be transferred from one account to another. Trading to be enabled after initial token release */
modifier canTrade {
require(trading==true ||(canRelease==true && msg.sender==owner));
_;
}
function setTrade(bool allow) onlyOwner {
trading=allow;
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
/* Public variables of the token */
event Invested(address investor, uint256 tokens);
uint256 public employeeShare=8;
// Wallets - 4 employee
address[4] employeeWallets = [0x9caeD53A6C6E91546946dD866dFD66c0aaB9f347,0xf1Df495BE71d1E5EdEbCb39D85D5F6b620aaAF47,0xa3C38bc8dD6e26eCc0D64d5B25f5ce855bb57Cd5,0x4d67a23b62399eDec07ad9c0f748D89655F0a0CB];
string public name;
string public symbol;
address public owner;
uint256 public tokensReleased=0;
bool canRelease=false;
/* Initializes contract with initial supply tokens to the owner of the contract */
function Cloud(
uint256 _initialAmount,
uint256 _decimalUnits,
string _tokenName,
string _tokenSymbol,
address ownerWallet
) {
owner=ownerWallet;
decimals = _decimalUnits; // Amount of decimals for display purposes
totalSupply = _initialAmount*(10**decimals); // Update total supply
balances[owner] = totalSupply; // Give the creator all initial tokens
name = _tokenName; // Set the name for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
}
/* Freezing tokens */
function freezeAccount(address target, bool freeze) onlyOwner{
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
}
/* Authenticating owner */
modifier onlyOwner {
require(msg.sender == owner);
_;
}
/* Allow and restrict of release of tokens */
function releaseTokens(bool allow) onlyOwner {
canRelease=allow;
}
/// @param receiver The address of the account which will receive the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the token transfer was successful or not was successful or not
function invest(address receiver, uint256 _value) onlyOwner returns (bool success) {
require(canRelease);
require(_value > 0);
uint256 numTokens = _value;
uint256 employeeTokens = 0;
uint256 employeeTokenShare=0;
// divide employee tokens by 4 shares
employeeTokens = numTokens.mul(employeeShare).div(100);
employeeTokenShare = employeeTokens.div(employeeWallets.length);
//split tokens for different wallets of employees and company
approve(owner,employeeTokens.add(numTokens));
for(uint i = 0; i < employeeWallets.length; i++)
{
require(transferFrom(owner, employeeWallets[i], employeeTokenShare));
}
require(transferFrom(owner, receiver, numTokens));
tokensReleased = tokensReleased.add(numTokens).add(employeeTokens.mul(4));
Invested(receiver,numTokens);
return true;
}
}