-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathShare.sol
157 lines (126 loc) · 3.55 KB
/
Share.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
pragma solidity ^0.4.17;
import "installed_contracts/tokens/contracts/HumanStandardToken.sol";
import "./math/SafeMath.sol";
import "./traits/Ownable.sol";
/**
* SHARE token is an ERC20 token.
*/
contract Share is HumanStandardToken, Ownable {
using SafeMath for uint;
string public constant TOKEN_NAME = "Vyral Token";
string public constant TOKEN_SYMBOL = "SHARE";
uint8 public constant TOKEN_DECIMALS = 18;
uint public constant TOTAL_SUPPLY = 777777777 * (10 ** uint(TOKEN_DECIMALS));
mapping (address => uint256) lockedBalances;
mapping (address => bool) public transferrers;
/**
* Init this contract with the same params as a HST.
*/
function Share() HumanStandardToken(TOTAL_SUPPLY, TOKEN_NAME, TOKEN_DECIMALS, TOKEN_SYMBOL)
public
{
transferrers[msg.sender] = true;
}
///-----------------
/// Overrides
///-----------------
/// Off on deployment.
bool isTransferable = false;
/// Bonus tokens are locked on deployment
bool isBonusLocked = true;
/// Allows the owner to transfer tokens whenever, but others to only transfer after owner says so.
modifier canBeTransferred {
require(transferrers[msg.sender] || isTransferable);
_;
}
function transferReward(
address _to,
uint _value
)
canBeTransferred
public
returns (bool)
{
require(balances[msg.sender] >= _value);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
lockedBalances[_to] = lockedBalances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function transfer(
address _to,
uint _value
)
canBeTransferred
public
returns (bool)
{
require(balances[msg.sender] >= _value);
/// Only transfer unlocked balance
if(isBonusLocked) {
require(balances[msg.sender].sub(lockedBalances[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,
uint _value
)
canBeTransferred
public
returns (bool)
{
require(balances[_from] >= _value);
require(allowed[_from][msg.sender] >= _value);
/// Only transfer unlocked balance
if(isBonusLocked) {
require(balances[_from].sub(lockedBalances[_from]) >= _value);
}
allowed[_from][msg.sender] = allowed[_from][_to].sub(_value);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(_from, _to, _value);
return true;
}
function lockedBalanceOf(
address _owner
)
constant
returns (uint)
{
return lockedBalances[_owner];
}
///-----------------
/// Admin
///-----------------
function enableTransfers()
onlyOwner
external
returns (bool)
{
isTransferable = true;
return isTransferable;
}
function addTransferrer(
address _transferrer
)
public
onlyOwner
{
transferrers[_transferrer] = true;
}
/**
* @dev Allow bonus tokens to be withdrawn
*/
function releaseBonus()
public
onlyOwner
{
isBonusLocked = false;
}
}