@@ -34,6 +34,11 @@ contract StandardToken is ERC20 {
34
34
mapping (address => uint256 ) public balances;
35
35
mapping (address => mapping (address => uint256 )) public allowed;
36
36
37
+ /**
38
+ * @dev transfer token for a specified address
39
+ * @param _to The address to transfer to.
40
+ * @param _value The amount to be transferred.
41
+ */
37
42
function transfer (address _to , uint256 _value ) returns (bool success ) {
38
43
require (balances[msg .sender ] >= _value && balances[_to] + _value > balances[_to]);
39
44
balances[msg .sender ] = balances[msg .sender ].sub (_value);
@@ -42,6 +47,12 @@ contract StandardToken is ERC20 {
42
47
return true ;
43
48
}
44
49
50
+ /**
51
+ * @dev Transfer tokens from one address to another
52
+ * @param _from address The address which you want to send tokens from
53
+ * @param _to address The address which you want to transfer to
54
+ * @param _value uint256 the amout of tokens to be transfered
55
+ */
45
56
function transferFrom (address _from , address _to , uint256 _value ) returns (bool success ) {
46
57
require (balances[_from] >= _value && allowed[_from][msg .sender ] >= _value && balances[_to] + _value > balances[_to]);
47
58
balances[_to] = balances[_to].add (_value);
@@ -51,19 +62,57 @@ contract StandardToken is ERC20 {
51
62
return true ;
52
63
}
53
64
65
+ /**
66
+ * @dev Gets the balance of the specified address.
67
+ * @param _owner The address to query the the balance of.
68
+ * @return An uint256 representing the amount owned by the passed address.
69
+ */
54
70
function balanceOf (address _owner ) constant returns (uint256 balance ) {
55
71
return balances[_owner];
56
72
}
57
73
74
+ /**
75
+ * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
76
+ * @param _spender The address which will spend the funds.
77
+ * @param _value The amount of tokens to be spent.
78
+ */
58
79
function approve (address _spender , uint256 _value ) returns (bool success ) {
80
+ require (allowed[msg .sender ][_spender] == 0 );
59
81
allowed[msg .sender ][_spender] = _value;
60
82
Approval (msg .sender , _spender, _value);
61
83
return true ;
62
84
}
63
85
86
+ /**
87
+ * @dev Function to check the amount of tokens that an owner allowed to a spender.
88
+ * @param _owner address The address which owns the funds.
89
+ * @param _spender address The address which will spend the funds.
90
+ * @return A uint256 specifing the amount of tokens still available for the spender.
91
+ */
64
92
function allowance (address _owner , address _spender ) constant returns (uint256 remaining ) {
65
93
return allowed[_owner][_spender];
66
94
}
95
+
96
+ /**
97
+ * To increment allowed value is better to use this function.
98
+ * From MonolithDAO Token.sol
99
+ */
100
+ function increaseApproval (address _spender , uint _addedValue ) public returns (bool ) {
101
+ allowed[msg .sender ][_spender] = allowed[msg .sender ][_spender].add (_addedValue);
102
+ Approval (msg .sender , _spender, allowed[msg .sender ][_spender]);
103
+ return true ;
104
+ }
105
+
106
+ function decreaseApproval (address _spender , uint _subtractedValue ) public returns (bool ) {
107
+ uint oldValue = allowed[msg .sender ][_spender];
108
+ if (_subtractedValue > oldValue) {
109
+ allowed[msg .sender ][_spender] = 0 ;
110
+ } else {
111
+ allowed[msg .sender ][_spender] = oldValue.sub (_subtractedValue);
112
+ }
113
+ Approval (msg .sender , _spender, allowed[msg .sender ][_spender]);
114
+ return true ;
115
+ }
67
116
}
68
117
69
118
contract Ownable {
@@ -131,22 +180,22 @@ library SafeMath {
131
180
132
181
/* Contract class for adding removing whitelisted contracts */
133
182
contract WhiteListedContracts is Ownable {
134
- mapping (address => uint ) white_listed_contracts;
183
+ mapping (address => bool ) white_listed_contracts;
135
184
136
185
//modifer to check if the contract given is white listed or not
137
186
modifier whitelistedContractsOnly () {
138
- require (white_listed_contracts[msg .sender ] == 1 );
187
+ require (white_listed_contracts[msg .sender ]);
139
188
_;
140
189
}
141
190
142
191
//add a contract to whitelist
143
192
function addWhiteListedContracts (address _address ) onlyOwner public {
144
- white_listed_contracts[_address] = 1 ;
193
+ white_listed_contracts[_address] = true ;
145
194
}
146
195
147
196
//remove contract from whitelist
148
197
function removeWhiteListedContracts (address _address ) onlyOwner public {
149
- white_listed_contracts[_address] = 0 ;
198
+ white_listed_contracts[_address] = false ;
150
199
}
151
200
}
152
201
@@ -160,18 +209,11 @@ contract SRTToken is Ownable,StandardToken,WhiteListedContracts {
160
209
uint256 public totalSupply;
161
210
uint256 public maxSupply;
162
211
163
- /* Contructor function to set initial balance and assign to owner */
212
+ /* Contructor function to set maxSupply */
164
213
function SRTToken (uint256 _maxSupply ){
165
- maxSupply = _maxSupply * 10 ** decimals;
214
+ maxSupply = _maxSupply. mul ( 10 ** decimals) ;
166
215
}
167
216
168
- /*
169
- transfer eth recived to owner account if any
170
- */
171
- function () payable {
172
- owner.transfer (msg .value );
173
- }
174
-
175
217
/*
176
218
do transfer function will allow transfer from a _to to _from provided if the call
177
219
comes from whitelisted contracts only
@@ -190,7 +232,7 @@ contract SRTToken is Ownable,StandardToken,WhiteListedContracts {
190
232
* @return A boolean that indicates if the operation was successful.
191
233
*/
192
234
function mint (uint256 _amount ) onlyOwner public returns (bool ) {
193
- require (maxSupply> (totalSupply.add (_amount)));
235
+ require (maxSupply >= (totalSupply.add (_amount)));
194
236
totalSupply = totalSupply.add (_amount);
195
237
balances[msg .sender ] = balances[msg .sender ].add (_amount);
196
238
Transfer (address (0 ), msg .sender , _amount);
0 commit comments