mm_contract 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/token.sol ADDED
@@ -0,0 +1,260 @@
1
+ pragma solidity ^0.4.0;
2
+
3
+ /**
4
+ * @title BulkSender, support ETH and ERC20 Tokens, send ether or erc20 token to multiple addresses in batch
5
+ * @dev To Use this Dapp: https://bulksender.app
6
+ */
7
+
8
+ library SafeMath {
9
+ function mul(uint256 a, uint256 b) internal pure returns (uint256) {
10
+ uint256 c = a * b;
11
+ require(a == 0 || c / a == b);
12
+ return c;
13
+ }
14
+
15
+ function div(uint256 a, uint256 b) internal pure returns (uint256) {
16
+ require(b > 0);
17
+ uint256 c = a / b;
18
+ require(a == b * c + (a % b));
19
+ return c;
20
+ }
21
+
22
+ function sub(uint256 a, uint256 b) internal pure returns (uint256) {
23
+ require(b <= a);
24
+ return a - b;
25
+ }
26
+
27
+ function add(uint256 a, uint256 b) internal pure returns (uint256) {
28
+ uint256 c = a + b;
29
+ require(c >= a);
30
+ return c;
31
+ }
32
+
33
+ function max64(uint64 a, uint64 b) internal pure returns (uint64) {
34
+ return a >= b ? a : b;
35
+ }
36
+
37
+ function min64(uint64 a, uint64 b) internal pure returns (uint64) {
38
+ return a < b ? a : b;
39
+ }
40
+
41
+ function max256(uint256 a, uint256 b) internal pure returns (uint256) {
42
+ return a >= b ? a : b;
43
+ }
44
+
45
+ function min256(uint256 a, uint256 b) internal pure returns (uint256) {
46
+ return a < b ? a : b;
47
+ }
48
+ }
49
+
50
+ /**
51
+ * @title ERC20Basic
52
+ * @dev Simpler version of ERC20 interface
53
+ * @dev see https://github.com/ethereum/EIPs/issues/179
54
+ */
55
+ contract ERC20Basic {
56
+ function totalSupply() public view returns (uint256);
57
+
58
+ function balanceOf(address who) public view returns (uint256);
59
+
60
+ function transfer(address to, uint256 value) public returns (bool);
61
+
62
+ event Transfer(address indexed from, address indexed to, uint256 value);
63
+ }
64
+
65
+ /**
66
+ * @title ERC20 interface
67
+ * @dev see https://github.com/ethereum/EIPs/issues/20
68
+ */
69
+ contract ERC20 is ERC20Basic {
70
+ function allowance(address owner, address spender)
71
+ public
72
+ view
73
+ returns (uint256);
74
+
75
+ function transferFrom(
76
+ address from,
77
+ address to,
78
+ uint256 value
79
+ ) public returns (bool);
80
+
81
+ function approve(address spender, uint256 value) public returns (bool);
82
+
83
+ event Approval(
84
+ address indexed owner,
85
+ address indexed spender,
86
+ uint256 value
87
+ );
88
+ }
89
+
90
+ /**
91
+ * @title Basic token
92
+ * @dev Basic version of StandardToken, with no allowances.
93
+ */
94
+ contract BasicToken is ERC20Basic {
95
+ using SafeMath for uint256;
96
+
97
+ mapping(address => uint256) balances;
98
+
99
+ uint256 totalSupply_;
100
+
101
+ /**
102
+ * @dev total number of tokens in existence
103
+ */
104
+ function totalSupply() public view returns (uint256) {
105
+ return totalSupply_;
106
+ }
107
+
108
+ /**
109
+ * @dev transfer token for a specified address
110
+ * @param _to The address to transfer to.
111
+ * @param _value The amount to be transferred.
112
+ */
113
+ function transfer(address _to, uint256 _value) public returns (bool) {
114
+ require(_to != address(0));
115
+ require(_value <= balances[msg.sender]);
116
+
117
+ // SafeMath.sub will throw if there is not enough balance.
118
+ balances[msg.sender] = balances[msg.sender].sub(_value);
119
+ balances[_to] = balances[_to].add(_value);
120
+ emit Transfer(msg.sender, _to, _value);
121
+ return true;
122
+ }
123
+
124
+ /**
125
+ * @dev Gets the balance of the specified address.
126
+ * @param _owner The address to query the the balance of.
127
+ * @return An uint256 representing the amount owned by the passed address.
128
+ */
129
+ function balanceOf(address _owner) public view returns (uint256 balance) {
130
+ return balances[_owner];
131
+ }
132
+ }
133
+
134
+ /**
135
+ * @title Standard ERC20 token
136
+ *
137
+ * @dev Implementation of the basic standard token.
138
+ * @dev https://github.com/ethereum/EIPs/issues/20
139
+ * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
140
+ */
141
+ contract StandardToken is ERC20, BasicToken {
142
+ mapping(address => mapping(address => uint256)) internal allowed;
143
+
144
+ /**
145
+ * @dev Transfer tokens from one address to another
146
+ * @param _from address The address which you want to send tokens from
147
+ * @param _to address The address which you want to transfer to
148
+ * @param _value uint256 the amount of tokens to be transferred
149
+ */
150
+ function transferFrom(
151
+ address _from,
152
+ address _to,
153
+ uint256 _value
154
+ ) public returns (bool) {
155
+ require(_to != address(0));
156
+ require(_value <= balances[_from]);
157
+ require(_value <= allowed[_from][msg.sender]);
158
+
159
+ balances[_from] = balances[_from].sub(_value);
160
+ balances[_to] = balances[_to].add(_value);
161
+ allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
162
+ emit Transfer(_from, _to, _value);
163
+ return true;
164
+ }
165
+
166
+ /**
167
+ * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
168
+ *
169
+ * Beware that changing an allowance with this method brings the risk that someone may use both the old
170
+ * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
171
+ * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
172
+ * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
173
+ * @param _spender The address which will spend the funds.
174
+ * @param _value The amount of tokens to be spent.
175
+ */
176
+ function approve(address _spender, uint256 _value) public returns (bool) {
177
+ allowed[msg.sender][_spender] = _value;
178
+ emit Approval(msg.sender, _spender, _value);
179
+ return true;
180
+ }
181
+
182
+ /**
183
+ * @dev Function to check the amount of tokens that an owner allowed to a spender.
184
+ * @param _owner address The address which owns the funds.
185
+ * @param _spender address The address which will spend the funds.
186
+ * @return A uint256 specifying the amount of tokens still available for the spender.
187
+ */
188
+ function allowance(address _owner, address _spender)
189
+ public
190
+ view
191
+ returns (uint256)
192
+ {
193
+ return allowed[_owner][_spender];
194
+ }
195
+
196
+ /**
197
+ * @dev Increase the amount of tokens that an owner allowed to a spender.
198
+ *
199
+ * approve should be called when allowed[_spender] == 0. To increment
200
+ * allowed value is better to use this function to avoid 2 calls (and wait until
201
+ * the first transaction is mined)
202
+ * From MonolithDAO Token.sol
203
+ * @param _spender The address which will spend the funds.
204
+ * @param _addedValue The amount of tokens to increase the allowance by.
205
+ */
206
+ function increaseApproval(address _spender, uint256 _addedValue)
207
+ public
208
+ returns (bool)
209
+ {
210
+ allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(
211
+ _addedValue
212
+ );
213
+ emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
214
+ return true;
215
+ }
216
+
217
+ /**
218
+ * @dev Decrease the amount of tokens that an owner allowed to a spender.
219
+ *
220
+ * approve should be called when allowed[_spender] == 0. To decrement
221
+ * allowed value is better to use this function to avoid 2 calls (and wait until
222
+ * the first transaction is mined)
223
+ * From MonolithDAO Token.sol
224
+ * @param _spender The address which will spend the funds.
225
+ * @param _subtractedValue The amount of tokens to decrease the allowance by.
226
+ */
227
+ function decreaseApproval(address _spender, uint256 _subtractedValue)
228
+ public
229
+ returns (bool)
230
+ {
231
+ uint256 oldValue = allowed[msg.sender][_spender];
232
+ if (_subtractedValue > oldValue) {
233
+ allowed[msg.sender][_spender] = 0;
234
+ } else {
235
+ allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
236
+ }
237
+ emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
238
+ return true;
239
+ }
240
+ }
241
+
242
+ contract MMToken is StandardToken {
243
+ string public name = "MobileMan";
244
+ string public symbol = "MM";
245
+ uint256 public decimals = 8;
246
+ uint256 public INITIAL_SUPPLY = 10000 * (10**decimals);
247
+ uint256 public totalSupply;
248
+
249
+ constructor(
250
+ uint256 initialSupply,
251
+ string memory tokenName,
252
+ string memory tokenSymbol
253
+ ) public {
254
+ totalSupply = initialSupply * 10**uint256(decimals);
255
+ totalSupply = INITIAL_SUPPLY;
256
+ name = tokenName;
257
+ symbol = tokenSymbol;
258
+ balances[msg.sender] = INITIAL_SUPPLY;
259
+ }
260
+ }