forked from CryptoBlockTeam/ERC20SmartContractGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
506 lines (466 loc) · 38.8 KB
/
index.html
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
<!DOCTYPE HTML>
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title>ERC20 Generator</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous" />
<link rel="stylesheet" href="css/generator.css" />
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
</head>
<body>
<form class="container" id="Form">
<div class="col-xs-4"></div>
<div class="col-xs-4 text-center">
<div class="h1">ERC20 Generator</div>
<div class=" form-group col-md-12">
<input type="text" id="companyName" class="form-control col-xs-12 col-md-5 float-left" style="margin: 10px 10px 0 10px;" placeholder="company name: eg. MyCompany" required />
<input type="email" id="userEmail" class="form-control col-xs-12 col-md-5 float-left" style="margin: 10px 10px 0 10px;" placeholder="email: eg. [email protected]" required />
</div>
<div class="form-group col-md-12">
<input type="text" id="tokenName" class="form-control col-xs-12 col-md-7 float-left" style="margin: 10px 10px 0 10px;" placeholder="token name: eg. Simon Bucks" required />
<input type="text" id="tokenTicket" class="form-control col-xs-12 col-md-3 float-left" style="margin: 10px 10px 0 10px;" maxlength="15" placeholder="token ticker: eg. SBX" required />
</div>
<div class="form-group col-md-12">
<input type="number" id="decimalPlaces" class="form-control col-xs-12 col-md-5 float-left" style="margin: 10px 10px 0 10px;" placeholder="decimal places: eg. 18" required />
<input type="number" id="initialSupply" class="form-control col-xs-12 col-md-5 float-left" style="margin: 10px 10px 0 10px;" placeholder="initial supply: eg. 100000000" required />
</div>
<div class="row col-md-12" style="margin-left: 15px;">
<div class="h3 col-md-12" style="margin-top: 25px">Features:</div>
<div class="text-left">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="isPausable" class="form-check-input" />
Pausable - Provides possibility to pause/unpause token transfers.
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="isMintable" class="form-check-input option" />
Mintable - Provides possibility to mint (create) new tokens when needed. Can be used to create and sell new tokens during ICOs, and minting can be stopped when required.
</label>
<ul style="list-style: none;">
<li>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="isCapped" class="form-check-input subOption" />
Capped - Provides token limit for minting.
</label>
<input type="number" id="capAmount" class="form-control" placeholder="initial cap amount: eg. 10" hidden />
</div>
<ul>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="isCappingChangeable" class="form-check-input subSubOption" />
Increase/Decrease Cap amount - Makes token minting limit adjustable to the needs.
</label>
</div>
</ul>
</li>
</ul>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="isBurnable" class="form-check-input" />
Burnable - Provides possibility to destroy unwanted/unnecessary tokens.
</label>
<ul style="list-style: none;">
<li>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="isBurnableByEveryone" class="form-check-input subOption" />
Is Burnable by everyone - Should everyone be able to destroy tokens, or only the token owner.
</label>
</div>
</li>
</ul>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="includeApproveAndCall" class="form-check-input" checked />
Include Approve and Call - Provides flexibility for other contracts to work with the token. Approve and then communicate the approved contract in a single transaction.
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" id="includeTransferAndCall" class="form-check-input" checked />
Include Transfer and Call - Provides flexibility for other contracts to work with the token. Transfer and then communicate the contract in a single transaction.
</label>
</div>
</div>
</div>
<button type="submit" id="render" class="btn btn-outline-dark">Create Token</button>
<br />
<br />
<div class="h4 title" hidden>ERC20 Contract</div>
<div class="col-xs-12 text-left">
<div class="col-xs-3"></div>
<div id="result" class="col-xs-6 result" style="overflow: hidden;"></div>
<div class="col-xs-3"></div>
</div>
</div>
<div class="col-xs-4"></div>
<script type="text/x-tmpl" id="tmpl-demo">
<div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;">
<div class="btn btn-outline-dark copy-to-clipboard">Copy</div>
<pre style="margin: 0; line-height: 125%">
<span style="color: #888888">/** </span>
<span style="color: #888888"> * ERC-20 Standard Token Smart Contract implementation.</span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * Copyright © 2017 by {%=o.companyName%}.</span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * Licensed under the Apache License, Version 2.0 (the "License").</span>
<span style="color: #888888"> * You may not use this file except in compliance with the License.</span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * Unless required by applicable law or agreed to in writing, software </span>
<span style="color: #888888"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
<span style="color: #888888"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND (express or implied).</span>
<span style="color: #888888"> */</span>
pragma solidity <span style="color: #333333">^</span><span style="color: #6600EE; font-weight: bold">0.4</span>.<span style="color: #0000DD; font-weight: bold">16</span>;
{% if (o.includeApproveAndCall || o.includeTransferAndCall) { %}
<span style="color: #6600EE; font-weight: bold">interface</span> TokenRecipient { {% if (o.includeApproveAndCall) { %}
<span style="color: #008800; font-weight: bold">function</span> receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool); {% } %}{% if (o.includeTransferAndCall) { %}
<span style="color: #008800; font-weight: bold">function</span> tokenFallback(address _from, uint256 _value, bytes _extraData) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool);{% } %}
}
{% } %}
<span style="color: #888888">/** </span>
<span style="color: #888888">* ERC-20 standard token interface</span>
<span style="color: #888888">*/</span>
<span style="color: #6600EE; font-weight: bold">contract</span> ERC20Interface {
<span style="color: #888888">/** </span>
<span style="color: #888888"> * Get total number of tokens in circulation.</span>
<span style="color: #888888"> */</span>
uint256 <span style="color: #008800; font-weight: bold">public</span> totalSupply;
<span style="color: #888888">/**</span>
<span style="color: #888888"> * @dev Get number of tokens currently belonging to given owner.</span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * @param _owner address to get number of tokens currently belonging to the owner of </span>
<span style="color: #888888"> * @return number of tokens currently belonging to the owner of given address </span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">function</span> balanceOf (address _owner) <span style="color: #008800; font-weight: bold">constant</span> <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (uint256 balance);
<span style="color: #888888">/**</span>
<span style="color: #888888"> * @dev Transfer given number of tokens from message sender to given recipient.</span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * @param _to address to transfer tokens to the owner of</span>
<span style="color: #888888"> * @param _value number of tokens to transfer to the owner of given address</span>
<span style="color: #888888"> * @return true if tokens were transferred successfully, false otherwise</span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">function</span> transfer (address _to, uint256 _value) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool success);
<span style="color: #888888">/**</span>
<span style="color: #888888"> * @dev Transfer given number of tokens from given owner to given recipient. </span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * @param _from address to transfer tokens from the owner of </span>
<span style="color: #888888"> * @param _to address to transfer tokens to the owner of </span>
<span style="color: #888888"> * @param _value number of tokens to transfer from given owner to given recipient </span>
<span style="color: #888888"> * @return true if tokens were transferred successfully, false otherwise </span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">function</span> transferFrom (address _from, address _to, uint256 _value) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool success);
<span style="color: #888888">/** </span>
<span style="color: #888888"> * @dev Allow given spender to transfer given number of tokens from message sender. </span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * @param _spender address to allow the owner of to transfer tokens from message sender </span>
<span style="color: #888888"> * @param _value number of tokens to allow to transfer </span>
<span style="color: #888888"> * @return true if token transfer was successfully approved, false otherwise </span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">function</span> approve (address _spender, uint256 _value) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool success);
<span style="color: #888888">/** </span>
<span style="color: #888888"> * @dev Tell how many tokens given spender is currently allowed to transfer from </span>
<span style="color: #888888"> * given owner. </span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * @param _owner address to get number of tokens allowed to be transferred from the owner of </span>
<span style="color: #888888"> * @param _spender address to get number of tokens allowed to be transferred by the owner of </span>
<span style="color: #888888"> * @return number of tokens given spender is currently allowed to transfer from given owner </span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">function</span> allowance (address _owner, address _spender) <span style="color: #008800; font-weight: bold">constant</span> <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (uint256 remaining);
<span style="color: #888888">/** </span>
<span style="color: #888888"> * @dev Logged when tokens were transferred from one owner to another. </span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * @param _from address of the owner, tokens were transferred from </span>
<span style="color: #888888"> * @param _to address of the owner, tokens were transferred to </span>
<span style="color: #888888"> * @param _value number of tokens transferred </span>
<span style="color: #888888"> */</span>
<span style="color: #6600EE; font-weight: bold">event</span> Transfer (address indexed _from, address indexed _to, uint256 _value);
<span style="color: #888888">/** </span>
<span style="color: #888888"> * @dev Logged when owner approved his tokens to be transferred by some spender. </span>
<span style="color: #888888"> * </span>
<span style="color: #888888"> * @param _owner owner who approved his tokens to be transferred </span>
<span style="color: #888888"> * @param _spender spender who were allowed to transfer the tokens belonging to the owner </span>
<span style="color: #888888"> * @param _value number of tokens belonging to the owner, approved to be transferred by the spender </span>
<span style="color: #888888"> */</span>
<span style="color: #6600EE; font-weight: bold">event</span> Approval (address indexed _owner, address indexed _spender, uint256 _value);
}
<span style="color: #6600EE; font-weight: bold">contract</span> Ownable {
address <span style="color: #008800; font-weight: bold">public</span> owner;
address <span style="color: #008800; font-weight: bold">public</span> newOwner;
<span style="color: #008800; font-weight: bold">function</span> Ownable() <span style="color: #008800; font-weight: bold">public</span> {
owner <span style="color: #333333">=</span> msg.sender;
}
<span style="color: #6600EE; font-weight: bold">modifier</span> onlyOwner {
assert(msg.sender <span style="color: #333333">==</span> owner);
_;
}
<span style="color: #6600EE; font-weight: bold">modifier</span> onlyNewOwner {
assert(msg.sender <span style="color: #333333">==</span> owner);
_;
}
<span style="color: #888888">/** </span>
<span style="color: #888888">* @dev Transfers ownership. New owner has to accept in order ownership change to take effect </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> transferOwnership(address _newOwner) <span style="color: #008800; font-weight: bold">public</span> onlyOwner {
require(_newOwner <span style="color: #333333">!=</span> owner);
newOwner <span style="color: #333333">=</span> _newOwner;
}
<span style="color: #888888">/** </span>
<span style="color: #888888">* @dev Accepts transferred ownership </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> acceptOwnership() <span style="color: #008800; font-weight: bold">public</span> onlyNewOwner {
OwnerUpdate(owner, newOwner);
owner <span style="color: #333333">=</span> newOwner;
newOwner <span style="color: #333333">=</span> <span style="color: #005588; font-weight: bold">0x0</span>;
}
<span style="color: #6600EE; font-weight: bold">event</span> OwnerUpdate(address _prevOwner, address _newOwner);
}
{% if (o.isPausable) { %}
<span style="color: #888888">/**</span>
<span style="color: #888888">* Pause/Unpanuse protection Smart Contract implementation.</span>
<span style="color: #888888">*/</span>
<span style="color: #6600EE; font-weight: bold">contract</span> Pausable is Ownable {
<span style="color: #6600EE; font-weight: bold">event</span> Pause();
<span style="color: #6600EE; font-weight: bold">event</span> Unpause();
bool <span style="color: #008800; font-weight: bold">public</span> paused <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">false</span>;
<span style="color: #888888">/**</span>
<span style="color: #888888">* @dev Modifier to make a function callable only when the contract is not paused.</span>
<span style="color: #888888">*/</span>
<span style="color: #6600EE; font-weight: bold">modifier</span> whenNotPaused() {
require(<span style="color: #333333">!</span>paused);
_;
}
<span style="color: #888888">/**</span>
<span style="color: #888888">* @dev Modifier to make a function callable only when the contract is paused.</span>
<span style="color: #888888">*/</span>
<span style="color: #6600EE; font-weight: bold">modifier</span> whenPaused() {
require(paused);
_;
}
<span style="color: #888888">/**</span>
<span style="color: #888888">* @dev called by the owner to pause, triggers stopped state</span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> pause() onlyOwner whenNotPaused <span style="color: #008800; font-weight: bold">public</span> {
paused <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">true</span>;
Pause();
}
<span style="color: #888888">/**</span>
<span style="color: #888888">* @dev called by the owner to unpause, returns to normal state</span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> unpause() onlyOwner whenPaused <span style="color: #008800; font-weight: bold">public</span> {
paused <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">false</span>;
Unpause();
}
}
{% } %}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Standard Token Smart Contract that implements ERC-20 token interface </span>
<span style="color: #888888">*/</span>
<span style="color: #6600EE; font-weight: bold">contract</span> {%=o.tokenTicket%}Token is ERC20Interface, Ownable{% if (o.isPausable) { %}, Pausable{% } %} {
<span style="color: #888888">// Public variables of the token </span>
bytes32 <span style="color: #008800; font-weight: bold">public</span> name <span style="color: #333333">=</span> "{%=o.tokenName%}";
bytes3 <span style="color: #008800; font-weight: bold">public</span> symbol <span style="color: #333333">=</span> "{%=o.tokenTicket%}";
uint8 <span style="color: #008800; font-weight: bold">public</span> decimals <span style="color: #333333">=</span> {%=o.decimalPlaces%};
<span style="color: #888888">// 18 decimals is the strongly suggested default, avoid changing it </span>
uint256 <span style="color: #008800; font-weight: bold">public</span> totalSupply;
{% if (o.isMintable) { %}
bool <span style="color: #008800; font-weight: bold">public</span> mintingFinished <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">false</span>;
{% if (o.isCapped) { %}uint256 <span style="color: #008800; font-weight: bold">public</span> capAmount;
{% } %}{% } %}
<span style="color: #888888">// This creates an array with all balances </span>
mapping (address <span style="color: #333333">=></span> uint256) <span style="color: #008800; font-weight: bold">public</span> balances;
mapping (address <span style="color: #333333">=></span> mapping (address <span style="color: #333333">=></span> uint256)) <span style="color: #008800; font-weight: bold">public</span> allowed;
<span style="color: #888888">// Events</span>
<span style="color: #888888">// This generates a public event on the blockchain that will notify clients </span>
<span style="color: #6600EE; font-weight: bold">event</span> Transfer(address indexed from, address indexed to, uint256 value);
<span style="color: #6600EE; font-weight: bold">event</span> ClaimTransfer(address indexed from, uint256 value);
{% if (o.isMintable) { %}
<span style="color: #6600EE; font-weight: bold">event</span> Mint(address indexed to, uint256 amount);
<span style="color: #6600EE; font-weight: bold">event</span> MintFinished();
<span style="color: #6600EE; font-weight: bold">modifier</span> canMint() {
require(<span style="color: #333333">!</span>mintingFinished);
_;
}{% if (o.isCapped) { %}
<span style="color: #6600EE; font-weight: bold">event</span> CapAmountIncreased(uint256 amount);
<span style="color: #6600EE; font-weight: bold">event</span> CapAmountDecreased(uint256 amount);{% } %}
{% } %}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Protection against short address attack </span>
<span style="color: #888888">*/</span>
<span style="color: #6600EE; font-weight: bold">modifier</span> onlyPayloadSize(uint numwords) {
assert(msg.data.length <span style="color: #333333">==</span> numwords <span style="color: #333333">*</span> <span style="color: #0000DD; font-weight: bold">32</span> <span style="color: #333333">+</span> <span style="color: #0000DD; font-weight: bold">4</span>);
_;
}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Constructor function </span>
<span style="color: #888888">* </span>
<span style="color: #888888">* Initializes contract with initial supply tokens to the creator of the contract </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> {%=o.tokenTicket%}Token() <span style="color: #008800; font-weight: bold">public</span> {
totalSupply <span style="color: #333333">=</span> {%=o.initialSupply%} <span style="color: #333333">*</span> <span style="color: #0000DD; font-weight: bold">10</span> <span style="color: #333333">**</span> uint256(decimals); <span style="color: #888888">// Update total supply with the decimal amount </span>{% if (o.isCapped) { %}
capAmount <span style="color: #333333">=</span> {%=o.capAmount%};{% } %}
balances[msg.sender] <span style="color: #333333">=</span> totalSupply; <span style="color: #888888">// Give the creator all initial tokens </span>
}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Transfer sender's tokens to a given address </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> transfer(address _to, uint256 _value) {% if (o.isPausable) { %} whenNotPaused {% } %} onlyPayloadSize(<span style="color: #0000DD; font-weight: bold">2</span>) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool success) {
require(_to <span style="color: #333333">!=</span> <span style="color: #005588; font-weight: bold">0x0</span>);
balances[msg.sender] <span style="color: #333333">=</span> balances[msg.sender] - _value;
balances[_to] <span style="color: #333333">+=</span> _value;
Transfer(msg.sender, _to, _value);
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Transfer _from's tokens to _to's address </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> transferFrom(address _from, address _to, uint256 _value) {% if (o.isPausable) { %}whenNotPaused {% } %}onlyPayloadSize(<span style="color: #0000DD; font-weight: bold">3</span>) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool success) {
require(_to <span style="color: #333333">!=</span> <span style="color: #005588; font-weight: bold">0x0</span>);
require(balances[_from] <span style="color: #333333">>=</span> _value <span style="color: #333333">&&</span> allowed[_from][msg.sender] <span style="color: #333333">>=</span> _value);
balances[_from] <span style="color: #333333">=</span> balances[_from] - _value;
balances[_to] <span style="color: #333333">+=</span> _value;
allowed[_from][msg.sender] <span style="color: #333333">=</span> allowed[_from][msg.sender] - _value;
Transfer(_from, _to, _value);
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Returns number of tokens owned by given address. </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> balanceOf(address _owner) <span style="color: #008800; font-weight: bold">constant</span> <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (uint256 balance) {
<span style="color: #008800; font-weight: bold">return</span> balances[_owner];
}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Sets approved amount of tokens for spender. </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> approve(address _spender, uint256 _value) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool success) {
require(_value <span style="color: #333333">==</span> <span style="color: #0000DD; font-weight: bold">0</span> <span style="color: #333333">||</span> allowed[msg.sender][_spender] <span style="color: #333333">==</span> <span style="color: #0000DD; font-weight: bold">0</span>);
allowed[msg.sender][_spender] <span style="color: #333333">=</span> _value;
Approval(msg.sender, _spender, _value);
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
}
{% if (o.includeApproveAndCall) { %}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Approve and then communicate the approved contract in a single transaction </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> approveAndCall(address _spender, uint256 _value, bytes _extraData) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool success) {
TokenRecipient spender <span style="color: #333333">=</span> TokenRecipient(_spender);
<span style="color: #008800; font-weight: bold">if</span> (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, <span style="color: #008800; font-weight: bold">this</span>, _extraData);
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
}
}
{% } %}{% if (o.includeTransferAndCall) { %}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Transfer and then communicate the contract in a single transaction </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> transferAndCall(address _recipient, uint256 _value, bytes _extraData) <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool success) {
TokenRecipient recipient <span style="color: #333333">=</span> TokenRecipient(_recipient);
<span style="color: #008800; font-weight: bold">if</span> (transfer(_recipient, _value)) {
recipient.tokenFallback(msg.sender, _value, _extraData);
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
}
}
{% } %}
<span style="color: #888888">/** </span>
<span style="color: #888888">* Returns number of allowed tokens for given address. </span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> allowance(address _owner, address _spender) onlyPayloadSize(<span style="color: #0000DD; font-weight: bold">2</span>) <span style="color: #008800; font-weight: bold">constant</span> <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (uint256 remaining) {
<span style="color: #008800; font-weight: bold">return</span> allowed[_owner][_spender];
}{% if (o.isMintable) { %}
<span style="color: #888888">/**</span>
<span style="color: #888888">* @dev Function to mint tokens</span>
<span style="color: #888888">* @param _to The address that will receive the minted tokens.</span>
<span style="color: #888888">* @param _amount The amount of tokens to mint.</span>
<span style="color: #888888">* @return A boolean that indicates if the operation was successful.</span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> mint(address _to, uint256 _amount) onlyOwner canMint <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool) {
uint256 newTotalSupply <span style="color: #333333">=</span> totalSupply + _amount;
{% if (o.isCapped) { %}require(newTotalSupply <span style="color: #333333"><=</span> capAmount);
{% } %}totalSupply <span style="color: #333333">=</span> newTotalSupply;
balances[_to] <span style="color: #333333">=</span> balances[_to] + _amount;
Mint(_to, _amount);
Transfer(address(<span style="color: #0000DD; font-weight: bold">0</span>), _to, _amount);
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
}
<span style="color: #888888">/**</span>
<span style="color: #888888">* @dev Function to stop minting new tokens.</span>
<span style="color: #888888">* @return True if the operation was successful.</span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> finishMinting() onlyOwner canMint <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool) {
mintingFinished <span style="color: #333333">=</span> <span style="color: #008800; font-weight: bold">true</span>;
MintFinished();
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
}{% if (o.isCappingChangeable) { %}
<span style="color: #888888">/**</span>
<span style="color: #888888">* @dev Function to increase tokens cap limit</span>
<span style="color: #888888">* @param _amount The amount of tokens to increase cap</span>
<span style="color: #888888">* @return A boolean that indicates if the operation was successful.</span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> increaseCapAmount(uint256 _amount) onlyOwner <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool) {
capAmount <span style="color: #333333">=</span> capAmount + _amount;
CapAmountIncreased(_amount);
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
}
<span style="color: #888888">/**</span>
<span style="color: #888888">* @dev Function to decrease tokens cap limit</span>
<span style="color: #888888">* @param _amount The amount of tokens to decrease cap</span>
<span style="color: #888888">* @return A boolean that indicates if the operation was successful.</span>
<span style="color: #888888">*/</span>
<span style="color: #008800; font-weight: bold">function</span> decreaseCapAmount(uint256 _amount) onlyOwner <span style="color: #008800; font-weight: bold">public</span> <span style="color: #008800; font-weight: bold">returns</span> (bool) {
capAmount <span style="color: #333333">=</span> capAmount - _amount;
CapAmountDecreased(_amount);
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #008800; font-weight: bold">true</span>;
} {% } %}{% } %} {% if (o.isBurnable) { %}
<span style="color: #6600EE; font-weight: bold">event</span> Burn(address indexed burner, uint256 value);
<span style="color: #888888">/**</span>
<span style="color: #888888"> * @dev Burns a specific amount of tokens.</span>
<span style="color: #888888"> * @param _value The amount of token to be burned.</span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">function</span> burn(uint256 _value) {% if (!o.isBurnableByEveryone) { %}onlyOwner {% } %}<span style="color: #008800; font-weight: bold">public</span> {
require(_value <span style="color: #333333"><=</span> balances[msg.sender]);
<span style="color: #888888">// no need to require value <= totalSupply, since that would imply the</span>
<span style="color: #888888">// sender's balance is greater than the totalSupply, which *should* be an assertion failure</span>
address burner <span style="color: #333333">=</span> msg.sender;
balances[burner] <span style="color: #333333">=</span> balances[burner] - _value;
totalSupply <span style="color: #333333">=</span> totalSupply - _value;
Burn(burner, _value);
}{% } %}
<span style="color: #888888">/** </span>
<span style="color: #888888"> * @dev Dennis Peterson's Law Protection </span>
<span style="color: #888888"> * Claim tokens </span>
<span style="color: #888888"> */</span>
<span style="color: #008800; font-weight: bold">function</span> claimTokens(address _token) <span style="color: #008800; font-weight: bold">public</span> onlyOwner {
<span style="color: #008800; font-weight: bold">if</span> (_token <span style="color: #333333">==</span> <span style="color: #005588; font-weight: bold">0x0</span>) {
owner.transfer(<span style="color: #008800; font-weight: bold">this</span>.balance);
ClaimTransfer(owner, this.balance);
<span style="color: #008800; font-weight: bold">return</span>;
}
{%=o.tokenTicket%}Token token <span style="color: #333333">=</span> {%=o.tokenTicket%}Token(<span style="color: #008800; font-weight: bold">this</span>);
uint balance <span style="color: #333333">=</span> token.balanceOf(<span style="color: #008800; font-weight: bold">this</span>);
token.transfer(owner, balance);
ClaimTransfer(owner, balance);
}
}
</pre>
</div>
</script>
<script type="text/x-tmpl" id="tmpl-error">
<h3 class="error">{%=o.title%}</h3>
<code>{%=o.error%}</code>
</script>
<script src="js/tmpl.js"></script>
<script src="js/generator.js"></script>
</form>
</body>
</html>