├── .babelrc
├── .eslintrc
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build
├── Controlled.sol.js
├── Controlled_all.sol
├── MiniMeToken.sol.js
├── MiniMeToken_all.sol
├── SampleCampaign-TokenController.sol.js
├── SampleCampaign-TokenController_all.sol
├── TokenController.sol.js
└── TokenController_all.sol
├── contracts
├── Controlled.sol
├── MiniMeToken.sol
├── SampleCampaign-TokenController.sol
└── TokenController.sol
├── env.js
├── funding.json
├── index.js
├── js
├── compile.js
├── minimetoken.js
├── minimetokenfactory.js
└── minimetokenstate.js
├── package-lock.json
├── package.json
├── readme-header.png
└── test
└── minimetoken_normal.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015", "stage-2"],
3 | "plugins": [
4 | "add-module-exports"
5 | ]
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "airbnb",
3 | "rules": {
4 | "jsx-a11y/href-no-hash": "off",
5 | "jsx-a11y/anchor-is-valid": ["warn", { "aspects": ["invalidHref"] }]
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: 'node_js'
2 | node_js:
3 | - '8'
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | [](https://travis-ci.org/Giveth/minime)
4 |
5 | The MiniMeToken contract is a standard ERC20 token with extra functionality:
6 |
7 | ### The token is easy to clone!
8 |
9 | Anybody can create a new clone token from any token using this contract with an initial distribution identical to the original token at a specified block. The address calling the `createCloneToken` function will become the token controller and the token's default settings can be specified in the function call.
10 |
11 | function createCloneToken(
12 | string _cloneTokenName,
13 | uint8 _cloneDecimalUnits,
14 | string _cloneTokenSymbol,
15 | uint _snapshotBlock,
16 | bool _isConstant
17 | ) returns(address) {
18 |
19 | Once the clone token is created, it acts as a completely independent token, with it's own unique functionalities.
20 |
21 | ### Balance history is registered and available to be queried
22 |
23 | All MiniMe Tokens maintain a history of the balance changes that occur during each block. Two calls are introduced to read the totalSupply and the balance of any address at any block in the past.
24 |
25 | function totalSupplyAt(uint _blockNumber) constant returns(uint)
26 |
27 | function balanceOfAt(address _holder, uint _blockNumber) constant returns (uint)
28 |
29 | ### Optional token controller
30 |
31 | The controller of the contract can generate/destroy/transfer tokens at its own discretion. The controller can be a regular account, but the intention is for the controller to be another contract that imposes transparent rules on the token's issuance and functionality. The Token Controller is not required for the MiniMe token to function, if there is no reason to generate/destroy/transfer tokens, the token controller can be set to 0x0 and this functionality will be disabled.
32 |
33 | For example, a Token Creation contract can be set as the controller of the MiniMe Token and at the end of the token creation period, the controller can be transferred to the 0x0 address, to guarantee that no new tokens will be created.
34 |
35 | To create and destroy tokens, these two functions are introduced:
36 |
37 | function generateTokens(address _holder, uint _value) onlyController
38 |
39 | function destroyTokens(address _holder, uint _value) onlyController
40 |
41 | ### The Token's Controller can freeze transfers.
42 |
43 | If transfersEnabled == false, tokens cannot be transferred by the users, however they can still be created, destroyed, and transferred by the controller. The controller can also toggle this flag.
44 |
45 | // Allows tokens to be transferred if true or frozen if false
46 | function enableTransfers(bool _transfersEnabled) onlyController
47 |
48 |
49 | ## Applications
50 |
51 | If this token contract is used as the base token, then clones of itself can be easily generated at any given block number, this allows for incredibly powerful functionality, effectively the ability for anyone to give extra features to the token holders without having to migrate to a new contract. Some of the applications that the MiniMe token contract can be used for are:
52 |
53 | 1. Generating a voting token that is burned when you vote.
54 | 2. Generating a discount "coupon" that is redeemed when you use it.
55 | 3. Generating a token for a "spinoff" DAO.
56 | 4. Generating a token that can be used to give explicit support to an action or a campaign, like polling.
57 | 5. Generating a token to enable the token holders to collect daily, monthly or yearly payments.
58 | 6. Generating a token to limit participation in a token sale or similar event to holders of a specific token.
59 | 7. Generating token that allows a central party complete control to transfer/generate/destroy tokens at will.
60 | 8. Lots of other applications including all the applications the standard ERC 20 token can be used for.
61 |
62 | All these applications and more are enabled by the MiniMe Token Contract. The most amazing part being that anyone that wants to add these features can, in a permissionless yet safe manner without affecting the parent token's intended functionality.
63 |
64 | # How to deploy a campaign
65 |
66 | 1. Deploy the MinimeTokenFactory
67 | 2. Deploy the MinimeToken
68 | 3. Deploy the campaign
69 | 4. Assign the controller of the MinimeToken to the campaign.
70 |
71 |
72 |
--------------------------------------------------------------------------------
/build/Controlled.sol.js:
--------------------------------------------------------------------------------
1 | /* This is an autogenerated file. DO NOT EDIT MANUALLY */
2 |
3 | exports.ControlledAbi = [{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]
4 | exports.ControlledByteCode = "0x6060604052341561000f57600080fd5b60008054600160a060020a033316600160a060020a03199091161790556101668061003b6000396000f30060606040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633cebb8238114610050578063f77c47911461007e575b600080fd5b341561005b57600080fd5b61007c73ffffffffffffffffffffffffffffffffffffffff600435166100ba565b005b341561008957600080fd5b61009161011e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6000543373ffffffffffffffffffffffffffffffffffffffff9081169116146100e257600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a72305820348e33213b8644e828ed3b4249fa8ae33458cd699d8de08bf42e589b2b9fe1eb0029"
5 | exports.ControlledRuntimeByteCode = "0x60606040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633cebb8238114610050578063f77c47911461007e575b600080fd5b341561005b57600080fd5b61007c73ffffffffffffffffffffffffffffffffffffffff600435166100ba565b005b341561008957600080fd5b61009161011e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6000543373ffffffffffffffffffffffffffffffffffffffff9081169116146100e257600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a72305820348e33213b8644e828ed3b4249fa8ae33458cd699d8de08bf42e589b2b9fe1eb0029"
6 | exports._solcVersion = "0.4.18+commit.9cf6e910.Emscripten.clang"
7 | exports._sha256 = "0xcd25f1d20c06711ec5147fce5dc8518b5374f61f2313d4035c3650bd229e9de0"
8 |
--------------------------------------------------------------------------------
/build/Controlled_all.sol:
--------------------------------------------------------------------------------
1 |
2 | //File: ./contracts/Controlled.sol
3 | pragma solidity ^0.4.18;
4 |
5 | contract Controlled {
6 | /// @notice The address of the controller is the only address that can call
7 | /// a function with this modifier
8 | modifier onlyController { require(msg.sender == controller); _; }
9 |
10 | address public controller;
11 |
12 | function Controlled() public { controller = msg.sender;}
13 |
14 | /// @notice Changes the controller of the contract
15 | /// @param _newController The new controller of the contract
16 | function changeController(address _newController) public onlyController {
17 | controller = _newController;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/build/MiniMeToken.sol.js:
--------------------------------------------------------------------------------
1 | /* This is an autogenerated file. DO NOT EDIT MANUALLY */
2 |
3 | exports.ApproveAndCallFallBackAbi = [{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_token","type":"address"},{"name":"_data","type":"bytes"}],"name":"receiveApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
4 | exports.ApproveAndCallFallBackByteCode = "0x"
5 | exports.ApproveAndCallFallBackRuntimeByteCode = "0x"
6 | exports.ControlledAbi = [{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]
7 | exports.ControlledByteCode = "0x6060604052341561000f57600080fd5b60008054600160a060020a033316600160a060020a03199091161790556101668061003b6000396000f30060606040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633cebb8238114610050578063f77c47911461007e575b600080fd5b341561005b57600080fd5b61007c73ffffffffffffffffffffffffffffffffffffffff600435166100ba565b005b341561008957600080fd5b61009161011e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6000543373ffffffffffffffffffffffffffffffffffffffff9081169116146100e257600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a72305820dcc7719453e0e160bb95f32d292aeef13b633f36c7afd726f47f7f19a91bdb300029"
8 | exports.ControlledRuntimeByteCode = "0x60606040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633cebb8238114610050578063f77c47911461007e575b600080fd5b341561005b57600080fd5b61007c73ffffffffffffffffffffffffffffffffffffffff600435166100ba565b005b341561008957600080fd5b61009161011e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6000543373ffffffffffffffffffffffffffffffffffffffff9081169116146100e257600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a72305820dcc7719453e0e160bb95f32d292aeef13b633f36c7afd726f47f7f19a91bdb300029"
9 | exports.MiniMeTokenAbi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"creationBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_blockNumber","type":"uint256"}],"name":"balanceOfAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_cloneTokenName","type":"string"},{"name":"_cloneDecimalUnits","type":"uint8"},{"name":"_cloneTokenSymbol","type":"string"},{"name":"_snapshotBlock","type":"uint256"},{"name":"_transfersEnabled","type":"bool"}],"name":"createCloneToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"parentToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"generateTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_blockNumber","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"transfersEnabled","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"parentSnapShotBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"destroyTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"tokenFactory","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_transfersEnabled","type":"bool"}],"name":"enableTransfers","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_tokenFactory","type":"address"},{"name":"_parentToken","type":"address"},{"name":"_parentSnapShotBlock","type":"uint256"},{"name":"_tokenName","type":"string"},{"name":"_decimalUnits","type":"uint8"},{"name":"_tokenSymbol","type":"string"},{"name":"_transfersEnabled","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_token","type":"address"},{"indexed":true,"name":"_controller","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_cloneToken","type":"address"},{"indexed":false,"name":"_snapshotBlock","type":"uint256"}],"name":"NewCloneToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Approval","type":"event"}]
10 | exports.MiniMeTokenByteCode = "0x606060405260408051908101604052600781527f4d4d545f302e3200000000000000000000000000000000000000000000000000602082015260049080516200004d92916020019062000162565b5034156200005a57600080fd5b60405162001a7138038062001a71833981016040528080519190602001805191906020018051919060200180518201919060200180519190602001805182019190602001805160008054600160a060020a03338116600160a060020a031990921691909117909155600b8054918b166101000261010060a860020a0319909216919091179055915060019050848051620000f992916020019062000162565b506002805460ff191660ff851617905560038280516200011e92916020019062000162565b5060058054600160a060020a031916600160a060020a039790971696909617909555505050600655600b805460ff1916911515919091179055504360075562000207565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001a557805160ff1916838001178555620001d5565b82800160010185558215620001d5579182015b82811115620001d5578251825591602001919060010190620001b8565b50620001e3929150620001e7565b5090565b6200020491905b80821115620001e35760008155600101620001ee565b90565b61185a80620002176000396000f30060606040526004361061012f5763ffffffff60e060020a60003504166306fdde0381146101d4578063095ea7b31461025e578063176345141461029457806318160ddd146102b957806323b872dd146102cc578063313ce567146102f45780633cebb8231461031d5780634ee2cd7e1461033c57806354fd4d501461035e5780636638c0871461037157806370a082311461043557806380a5400114610454578063827f32c01461046757806395d89b4114610489578063981b24d01461049c578063a9059cbb146104b2578063bef97c87146104d4578063c5bcc4f1146104e7578063cae9ca51146104fa578063d3ce77fe1461055f578063dd62ed3e14610581578063df8de3e7146105a6578063e77772fe146105c5578063f41e60c5146105d8578063f77c4791146105f0575b60005461014490600160a060020a0316610603565b151561014f57600080fd5b60008054600160a060020a03169063f48c305490349033906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390911660048201526024016020604051808303818588803b15156101ab57600080fd5b6125ee5a03f115156101bc57600080fd5b505050506040518051905015156101d257600080fd5b005b34156101df57600080fd5b6101e7610630565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561022357808201518382015260200161020b565b50505050905090810190601f1680156102505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561026957600080fd5b610280600160a060020a03600435166024356106ce565b604051901515815260200160405180910390f35b341561029f57600080fd5b6102a7610837565b60405190815260200160405180910390f35b34156102c457600080fd5b6102a761083d565b34156102d757600080fd5b610280600160a060020a036004358116906024351660443561084e565b34156102ff57600080fd5b6103076108ed565b60405160ff909116815260200160405180910390f35b341561032857600080fd5b6101d2600160a060020a03600435166108f6565b341561034757600080fd5b6102a7600160a060020a0360043516602435610940565b341561036957600080fd5b6101e7610a76565b341561037c57600080fd5b61041960046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803560ff1690602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528181529291906020840183838082843750949650508435946020013515159350610ae192505050565b604051600160a060020a03909116815260200160405180910390f35b341561044057600080fd5b6102a7600160a060020a0360043516610d0b565b341561045f57600080fd5b610419610d1f565b341561047257600080fd5b610280600160a060020a0360043516602435610d2e565b341561049457600080fd5b6101e7610dec565b34156104a757600080fd5b6102a7600435610e57565b34156104bd57600080fd5b610280600160a060020a0360043516602435610f40565b34156104df57600080fd5b610280610f68565b34156104f257600080fd5b6102a7610f71565b341561050557600080fd5b61028060048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610f7795505050505050565b341561056a57600080fd5b610280600160a060020a0360043516602435611092565b341561058c57600080fd5b6102a7600160a060020a036004358116906024351661114a565b34156105b157600080fd5b6101d2600160a060020a0360043516611175565b34156105d057600080fd5b610419611321565b34156105e357600080fd5b6101d26004351515611335565b34156105fb57600080fd5b610419611363565b600080600160a060020a038316151561061f576000915061062a565b823b90506000811191505b50919050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b820191906000526020600020905b8154815290600101906020018083116106a957829003601f168201915b505050505081565b600b5460009060ff1615156106e257600080fd5b8115806107125750600160a060020a03338116600090815260096020908152604080832093871683529290522054155b151561071d57600080fd5b60005461073290600160a060020a0316610603565b156107cd5760008054600160a060020a03169063da682aeb903390869086906040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156107a757600080fd5b6102c65a03f115156107b857600080fd5b5050506040518051905015156107cd57600080fd5b600160a060020a03338116600081815260096020908152604080832094881680845294909152908190208590557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b60075481565b600061084843610e57565b90505b90565b6000805433600160a060020a039081169116146108d857600b5460ff16151561087657600080fd5b600160a060020a0380851660009081526009602090815260408083203390941683529290522054829010156108aa57600080fd5b600160a060020a03808516600090815260096020908152604080832033909416835292905220805483900390555b6108e3848484611372565b5060019392505050565b60025460ff1681565b60005433600160a060020a0390811691161461091157600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a038216600090815260086020526040812054158061099c5750600160a060020a03831660009081526008602052604081208054849290811061098557fe5b6000918252602090912001546001608060020a0316115b15610a4d57600554600160a060020a031615610a4557600554600654600160a060020a0390911690634ee2cd7e9085906109d7908690611564565b60006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a2357600080fd5b6102c65a03f11515610a3457600080fd5b505050604051805190509050610831565b506000610831565b600160a060020a0383166000908152600860205260409020610a6f908361157c565b9050610831565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b600080831515610aef574393505b600b546101009004600160a060020a0316635b7b72c130868a8a8a8960006040516020015260405160e060020a63ffffffff8916028152600160a060020a038716600482019081526024820187905260ff8516606483015282151560a483015260c0604483019081529091608481019060c40187818151815260200191508051906020019080838360005b83811015610b92578082015183820152602001610b7a565b50505050905090810190601f168015610bbf5780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015610bf5578082015183820152602001610bdd565b50505050905090810190601f168015610c225780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b1515610c4657600080fd5b6102c65a03f11515610c5757600080fd5b5050506040518051915050600160a060020a038116633cebb8233360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610cb057600080fd5b6102c65a03f11515610cc157600080fd5b50505080600160a060020a03167f086c875b377f900b07ce03575813022f05dd10ed7640b5282cf6d3c3fc352ade8560405190815260200160405180910390a29695505050505050565b6000610d178243610940565b90505b919050565b600554600160a060020a031681565b600080548190819033600160a060020a03908116911614610d4e57600080fd5b610d5661083d565b915083820182901015610d6857600080fd5b610d7185610d0b565b905083810181901015610d8357600080fd5b610d90600a8584016116db565b600160a060020a0385166000908152600860205260409020610db4908286016116db565b84600160a060020a0316600060008051602061180f8339815191528660405190815260200160405180910390a3506001949350505050565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b600a546000901580610e8c575081600a6000815481101515610e7557fe5b6000918252602090912001546001608060020a0316115b15610f2e57600554600160a060020a031615610f2657600554600654600160a060020a039091169063981b24d090610ec5908590611564565b60006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610f0457600080fd5b6102c65a03f11515610f1557600080fd5b505050604051805190509050610d1a565b506000610d1a565b610f39600a8361157c565b9050610d1a565b600b5460009060ff161515610f5457600080fd5b610f5f338484611372565b50600192915050565b600b5460ff1681565b60065481565b6000610f8384846106ce565b1515610f8e57600080fd5b83600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561102657808201518382015260200161100e565b50505050905090810190601f1680156110535780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561107457600080fd5b6102c65a03f1151561108557600080fd5b5060019695505050505050565b600080548190819033600160a060020a039081169116146110b257600080fd5b6110ba61083d565b9150838210156110c957600080fd5b6110d285610d0b565b9050838110156110e157600080fd5b6110ee600a8584036116db565b600160a060020a0385166000908152600860205260409020611112908583036116db565b600085600160a060020a031660008051602061180f8339815191528660405190815260200160405180910390a3506001949350505050565b600160a060020a03918216600090815260096020908152604080832093909416825291909152205490565b60008054819033600160a060020a0390811691161461119357600080fd5b600160a060020a03831615156111e157600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f1935050505015156111dc57600080fd5b61131c565b82915081600160a060020a03166370a082313060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561123b57600080fd5b6102c65a03f1151561124c57600080fd5b505050604051805160008054919350600160a060020a03808616935063a9059cbb92169084906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156112bc57600080fd5b6102c65a03f115156112cd57600080fd5b50505060405180515050600054600160a060020a039081169084167ff931edb47c50b4b4104c187b5814a9aef5f709e17e2ecf9617e860cacade929c8360405190815260200160405180910390a35b505050565b600b546101009004600160a060020a031681565b60005433600160a060020a0390811691161461135057600080fd5b600b805460ff1916911515919091179055565b600054600160a060020a031681565b6000808215156113b65783600160a060020a031685600160a060020a031660008051602061180f8339815191528560405190815260200160405180910390a361155d565b6006544390106113c557600080fd5b600160a060020a038416158015906113ef575030600160a060020a031684600160a060020a031614155b15156113fa57600080fd5b6114048543610940565b91508282101561141357600080fd5b60005461142890600160a060020a0316610603565b156114c35760008054600160a060020a031690634a393149908790879087906040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561149d57600080fd5b6102c65a03f115156114ae57600080fd5b5050506040518051905015156114c357600080fd5b600160a060020a03851660009081526008602052604090206114e7908484036116db565b6114f18443610940565b90508281018190101561150357600080fd5b600160a060020a0384166000908152600860205260409020611527908285016116db565b83600160a060020a031685600160a060020a031660008051602061180f8339815191528560405190815260200160405180910390a35b5050505050565b60008183106115735781611575565b825b9392505050565b60008060008085805490506000141561159857600093506116d2565b8554869060001981019081106115aa57fe5b6000918252602090912001546001608060020a03168510611607578554869060001981019081106115d757fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031693506116d2565b85600081548110151561161657fe5b6000918252602090912001546001608060020a031685101561163b57600093506116d2565b8554600093506000190191505b8282111561169857600260018385010104905084868281548110151561166a57fe5b6000918252602090912001546001608060020a03161161168c57809250611693565b6001810391505b611648565b85838154811015156116a657fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031693505b50505092915050565b815460009081901580611714575083544390859060001981019081106116fd57fe5b6000918252602090912001546001608060020a0316105b15611786578354849061172a82600183016117d1565b8154811061173457fe5b600091825260209091200180546001608060020a03858116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff19909316929092171617815591506117cb565b83548490600019810190811061179857fe5b600091825260209091200180546001608060020a0380861670010000000000000000000000000000000002911617815590505b50505050565b81548183558181151161131c5760008381526020902061131c91810190830161084b91905b8082111561180a57600081556001016117f6565b50905600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820872e8915fab8238dba3e3df3c2d59bd66577da1a8c400bfd80f851b5e974bb860029"
11 | exports.MiniMeTokenRuntimeByteCode = "0x60606040526004361061012f5763ffffffff60e060020a60003504166306fdde0381146101d4578063095ea7b31461025e578063176345141461029457806318160ddd146102b957806323b872dd146102cc578063313ce567146102f45780633cebb8231461031d5780634ee2cd7e1461033c57806354fd4d501461035e5780636638c0871461037157806370a082311461043557806380a5400114610454578063827f32c01461046757806395d89b4114610489578063981b24d01461049c578063a9059cbb146104b2578063bef97c87146104d4578063c5bcc4f1146104e7578063cae9ca51146104fa578063d3ce77fe1461055f578063dd62ed3e14610581578063df8de3e7146105a6578063e77772fe146105c5578063f41e60c5146105d8578063f77c4791146105f0575b60005461014490600160a060020a0316610603565b151561014f57600080fd5b60008054600160a060020a03169063f48c305490349033906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390911660048201526024016020604051808303818588803b15156101ab57600080fd5b6125ee5a03f115156101bc57600080fd5b505050506040518051905015156101d257600080fd5b005b34156101df57600080fd5b6101e7610630565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561022357808201518382015260200161020b565b50505050905090810190601f1680156102505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561026957600080fd5b610280600160a060020a03600435166024356106ce565b604051901515815260200160405180910390f35b341561029f57600080fd5b6102a7610837565b60405190815260200160405180910390f35b34156102c457600080fd5b6102a761083d565b34156102d757600080fd5b610280600160a060020a036004358116906024351660443561084e565b34156102ff57600080fd5b6103076108ed565b60405160ff909116815260200160405180910390f35b341561032857600080fd5b6101d2600160a060020a03600435166108f6565b341561034757600080fd5b6102a7600160a060020a0360043516602435610940565b341561036957600080fd5b6101e7610a76565b341561037c57600080fd5b61041960046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803560ff1690602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528181529291906020840183838082843750949650508435946020013515159350610ae192505050565b604051600160a060020a03909116815260200160405180910390f35b341561044057600080fd5b6102a7600160a060020a0360043516610d0b565b341561045f57600080fd5b610419610d1f565b341561047257600080fd5b610280600160a060020a0360043516602435610d2e565b341561049457600080fd5b6101e7610dec565b34156104a757600080fd5b6102a7600435610e57565b34156104bd57600080fd5b610280600160a060020a0360043516602435610f40565b34156104df57600080fd5b610280610f68565b34156104f257600080fd5b6102a7610f71565b341561050557600080fd5b61028060048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610f7795505050505050565b341561056a57600080fd5b610280600160a060020a0360043516602435611092565b341561058c57600080fd5b6102a7600160a060020a036004358116906024351661114a565b34156105b157600080fd5b6101d2600160a060020a0360043516611175565b34156105d057600080fd5b610419611321565b34156105e357600080fd5b6101d26004351515611335565b34156105fb57600080fd5b610419611363565b600080600160a060020a038316151561061f576000915061062a565b823b90506000811191505b50919050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b820191906000526020600020905b8154815290600101906020018083116106a957829003601f168201915b505050505081565b600b5460009060ff1615156106e257600080fd5b8115806107125750600160a060020a03338116600090815260096020908152604080832093871683529290522054155b151561071d57600080fd5b60005461073290600160a060020a0316610603565b156107cd5760008054600160a060020a03169063da682aeb903390869086906040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156107a757600080fd5b6102c65a03f115156107b857600080fd5b5050506040518051905015156107cd57600080fd5b600160a060020a03338116600081815260096020908152604080832094881680845294909152908190208590557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b60075481565b600061084843610e57565b90505b90565b6000805433600160a060020a039081169116146108d857600b5460ff16151561087657600080fd5b600160a060020a0380851660009081526009602090815260408083203390941683529290522054829010156108aa57600080fd5b600160a060020a03808516600090815260096020908152604080832033909416835292905220805483900390555b6108e3848484611372565b5060019392505050565b60025460ff1681565b60005433600160a060020a0390811691161461091157600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a038216600090815260086020526040812054158061099c5750600160a060020a03831660009081526008602052604081208054849290811061098557fe5b6000918252602090912001546001608060020a0316115b15610a4d57600554600160a060020a031615610a4557600554600654600160a060020a0390911690634ee2cd7e9085906109d7908690611564565b60006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a2357600080fd5b6102c65a03f11515610a3457600080fd5b505050604051805190509050610831565b506000610831565b600160a060020a0383166000908152600860205260409020610a6f908361157c565b9050610831565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b600080831515610aef574393505b600b546101009004600160a060020a0316635b7b72c130868a8a8a8960006040516020015260405160e060020a63ffffffff8916028152600160a060020a038716600482019081526024820187905260ff8516606483015282151560a483015260c0604483019081529091608481019060c40187818151815260200191508051906020019080838360005b83811015610b92578082015183820152602001610b7a565b50505050905090810190601f168015610bbf5780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015610bf5578082015183820152602001610bdd565b50505050905090810190601f168015610c225780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b1515610c4657600080fd5b6102c65a03f11515610c5757600080fd5b5050506040518051915050600160a060020a038116633cebb8233360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610cb057600080fd5b6102c65a03f11515610cc157600080fd5b50505080600160a060020a03167f086c875b377f900b07ce03575813022f05dd10ed7640b5282cf6d3c3fc352ade8560405190815260200160405180910390a29695505050505050565b6000610d178243610940565b90505b919050565b600554600160a060020a031681565b600080548190819033600160a060020a03908116911614610d4e57600080fd5b610d5661083d565b915083820182901015610d6857600080fd5b610d7185610d0b565b905083810181901015610d8357600080fd5b610d90600a8584016116db565b600160a060020a0385166000908152600860205260409020610db4908286016116db565b84600160a060020a0316600060008051602061180f8339815191528660405190815260200160405180910390a3506001949350505050565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b600a546000901580610e8c575081600a6000815481101515610e7557fe5b6000918252602090912001546001608060020a0316115b15610f2e57600554600160a060020a031615610f2657600554600654600160a060020a039091169063981b24d090610ec5908590611564565b60006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610f0457600080fd5b6102c65a03f11515610f1557600080fd5b505050604051805190509050610d1a565b506000610d1a565b610f39600a8361157c565b9050610d1a565b600b5460009060ff161515610f5457600080fd5b610f5f338484611372565b50600192915050565b600b5460ff1681565b60065481565b6000610f8384846106ce565b1515610f8e57600080fd5b83600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561102657808201518382015260200161100e565b50505050905090810190601f1680156110535780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561107457600080fd5b6102c65a03f1151561108557600080fd5b5060019695505050505050565b600080548190819033600160a060020a039081169116146110b257600080fd5b6110ba61083d565b9150838210156110c957600080fd5b6110d285610d0b565b9050838110156110e157600080fd5b6110ee600a8584036116db565b600160a060020a0385166000908152600860205260409020611112908583036116db565b600085600160a060020a031660008051602061180f8339815191528660405190815260200160405180910390a3506001949350505050565b600160a060020a03918216600090815260096020908152604080832093909416825291909152205490565b60008054819033600160a060020a0390811691161461119357600080fd5b600160a060020a03831615156111e157600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f1935050505015156111dc57600080fd5b61131c565b82915081600160a060020a03166370a082313060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561123b57600080fd5b6102c65a03f1151561124c57600080fd5b505050604051805160008054919350600160a060020a03808616935063a9059cbb92169084906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156112bc57600080fd5b6102c65a03f115156112cd57600080fd5b50505060405180515050600054600160a060020a039081169084167ff931edb47c50b4b4104c187b5814a9aef5f709e17e2ecf9617e860cacade929c8360405190815260200160405180910390a35b505050565b600b546101009004600160a060020a031681565b60005433600160a060020a0390811691161461135057600080fd5b600b805460ff1916911515919091179055565b600054600160a060020a031681565b6000808215156113b65783600160a060020a031685600160a060020a031660008051602061180f8339815191528560405190815260200160405180910390a361155d565b6006544390106113c557600080fd5b600160a060020a038416158015906113ef575030600160a060020a031684600160a060020a031614155b15156113fa57600080fd5b6114048543610940565b91508282101561141357600080fd5b60005461142890600160a060020a0316610603565b156114c35760008054600160a060020a031690634a393149908790879087906040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561149d57600080fd5b6102c65a03f115156114ae57600080fd5b5050506040518051905015156114c357600080fd5b600160a060020a03851660009081526008602052604090206114e7908484036116db565b6114f18443610940565b90508281018190101561150357600080fd5b600160a060020a0384166000908152600860205260409020611527908285016116db565b83600160a060020a031685600160a060020a031660008051602061180f8339815191528560405190815260200160405180910390a35b5050505050565b60008183106115735781611575565b825b9392505050565b60008060008085805490506000141561159857600093506116d2565b8554869060001981019081106115aa57fe5b6000918252602090912001546001608060020a03168510611607578554869060001981019081106115d757fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031693506116d2565b85600081548110151561161657fe5b6000918252602090912001546001608060020a031685101561163b57600093506116d2565b8554600093506000190191505b8282111561169857600260018385010104905084868281548110151561166a57fe5b6000918252602090912001546001608060020a03161161168c57809250611693565b6001810391505b611648565b85838154811015156116a657fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031693505b50505092915050565b815460009081901580611714575083544390859060001981019081106116fd57fe5b6000918252602090912001546001608060020a0316105b15611786578354849061172a82600183016117d1565b8154811061173457fe5b600091825260209091200180546001608060020a03858116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff19909316929092171617815591506117cb565b83548490600019810190811061179857fe5b600091825260209091200180546001608060020a0380861670010000000000000000000000000000000002911617815590505b50505050565b81548183558181151161131c5760008381526020902061131c91810190830161084b91905b8082111561180a57600081556001016117f6565b50905600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820872e8915fab8238dba3e3df3c2d59bd66577da1a8c400bfd80f851b5e974bb860029"
12 | exports.MiniMeTokenFactoryAbi = [{"constant":false,"inputs":[{"name":"_parentToken","type":"address"},{"name":"_snapshotBlock","type":"uint256"},{"name":"_tokenName","type":"string"},{"name":"_decimalUnits","type":"uint8"},{"name":"_tokenSymbol","type":"string"},{"name":"_transfersEnabled","type":"bool"}],"name":"createCloneToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]
13 | exports.MiniMeTokenFactoryByteCode = "0x6060604052341561000f57600080fd5b611dc08061001e6000396000f3006060604052600436106100405763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416635b7b72c18114610045575b600080fd5b341561005057600080fd5b6101096004803573ffffffffffffffffffffffffffffffffffffffff169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803560ff1690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405281815292919060208401838380828437509496505050509135151591506101329050565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b60008030888888888888610144610313565b73ffffffffffffffffffffffffffffffffffffffff8089168252871660208201526040810186905260ff8416608082015281151560c082015260e0606082018181529060a0830190830187818151815260200191508051906020019080838360005b838110156101be5780820151838201526020016101a6565b50505050905090810190601f1680156101eb5780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015610221578082015183820152602001610209565b50505050905090810190601f16801561024e5780820380516001836020036101000a031916815260200191505b509950505050505050505050604051809103906000f080151561027057600080fd5b90508073ffffffffffffffffffffffffffffffffffffffff16633cebb823336040517c010000000000000000000000000000000000000000000000000000000063ffffffff841602815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401600060405180830381600087803b15156102f357600080fd5b6102c65a03f1151561030457600080fd5b50919998505050505050505050565b604051611a7180610324833901905600606060405260408051908101604052600781527f4d4d545f302e3200000000000000000000000000000000000000000000000000602082015260049080516200004d92916020019062000162565b5034156200005a57600080fd5b60405162001a7138038062001a71833981016040528080519190602001805191906020018051919060200180518201919060200180519190602001805182019190602001805160008054600160a060020a03338116600160a060020a031990921691909117909155600b8054918b166101000261010060a860020a0319909216919091179055915060019050848051620000f992916020019062000162565b506002805460ff191660ff851617905560038280516200011e92916020019062000162565b5060058054600160a060020a031916600160a060020a039790971696909617909555505050600655600b805460ff1916911515919091179055504360075562000207565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001a557805160ff1916838001178555620001d5565b82800160010185558215620001d5579182015b82811115620001d5578251825591602001919060010190620001b8565b50620001e3929150620001e7565b5090565b6200020491905b80821115620001e35760008155600101620001ee565b90565b61185a80620002176000396000f30060606040526004361061012f5763ffffffff60e060020a60003504166306fdde0381146101d4578063095ea7b31461025e578063176345141461029457806318160ddd146102b957806323b872dd146102cc578063313ce567146102f45780633cebb8231461031d5780634ee2cd7e1461033c57806354fd4d501461035e5780636638c0871461037157806370a082311461043557806380a5400114610454578063827f32c01461046757806395d89b4114610489578063981b24d01461049c578063a9059cbb146104b2578063bef97c87146104d4578063c5bcc4f1146104e7578063cae9ca51146104fa578063d3ce77fe1461055f578063dd62ed3e14610581578063df8de3e7146105a6578063e77772fe146105c5578063f41e60c5146105d8578063f77c4791146105f0575b60005461014490600160a060020a0316610603565b151561014f57600080fd5b60008054600160a060020a03169063f48c305490349033906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390911660048201526024016020604051808303818588803b15156101ab57600080fd5b6125ee5a03f115156101bc57600080fd5b505050506040518051905015156101d257600080fd5b005b34156101df57600080fd5b6101e7610630565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561022357808201518382015260200161020b565b50505050905090810190601f1680156102505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561026957600080fd5b610280600160a060020a03600435166024356106ce565b604051901515815260200160405180910390f35b341561029f57600080fd5b6102a7610837565b60405190815260200160405180910390f35b34156102c457600080fd5b6102a761083d565b34156102d757600080fd5b610280600160a060020a036004358116906024351660443561084e565b34156102ff57600080fd5b6103076108ed565b60405160ff909116815260200160405180910390f35b341561032857600080fd5b6101d2600160a060020a03600435166108f6565b341561034757600080fd5b6102a7600160a060020a0360043516602435610940565b341561036957600080fd5b6101e7610a76565b341561037c57600080fd5b61041960046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803560ff1690602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528181529291906020840183838082843750949650508435946020013515159350610ae192505050565b604051600160a060020a03909116815260200160405180910390f35b341561044057600080fd5b6102a7600160a060020a0360043516610d0b565b341561045f57600080fd5b610419610d1f565b341561047257600080fd5b610280600160a060020a0360043516602435610d2e565b341561049457600080fd5b6101e7610dec565b34156104a757600080fd5b6102a7600435610e57565b34156104bd57600080fd5b610280600160a060020a0360043516602435610f40565b34156104df57600080fd5b610280610f68565b34156104f257600080fd5b6102a7610f71565b341561050557600080fd5b61028060048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610f7795505050505050565b341561056a57600080fd5b610280600160a060020a0360043516602435611092565b341561058c57600080fd5b6102a7600160a060020a036004358116906024351661114a565b34156105b157600080fd5b6101d2600160a060020a0360043516611175565b34156105d057600080fd5b610419611321565b34156105e357600080fd5b6101d26004351515611335565b34156105fb57600080fd5b610419611363565b600080600160a060020a038316151561061f576000915061062a565b823b90506000811191505b50919050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b820191906000526020600020905b8154815290600101906020018083116106a957829003601f168201915b505050505081565b600b5460009060ff1615156106e257600080fd5b8115806107125750600160a060020a03338116600090815260096020908152604080832093871683529290522054155b151561071d57600080fd5b60005461073290600160a060020a0316610603565b156107cd5760008054600160a060020a03169063da682aeb903390869086906040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156107a757600080fd5b6102c65a03f115156107b857600080fd5b5050506040518051905015156107cd57600080fd5b600160a060020a03338116600081815260096020908152604080832094881680845294909152908190208590557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b60075481565b600061084843610e57565b90505b90565b6000805433600160a060020a039081169116146108d857600b5460ff16151561087657600080fd5b600160a060020a0380851660009081526009602090815260408083203390941683529290522054829010156108aa57600080fd5b600160a060020a03808516600090815260096020908152604080832033909416835292905220805483900390555b6108e3848484611372565b5060019392505050565b60025460ff1681565b60005433600160a060020a0390811691161461091157600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a038216600090815260086020526040812054158061099c5750600160a060020a03831660009081526008602052604081208054849290811061098557fe5b6000918252602090912001546001608060020a0316115b15610a4d57600554600160a060020a031615610a4557600554600654600160a060020a0390911690634ee2cd7e9085906109d7908690611564565b60006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a2357600080fd5b6102c65a03f11515610a3457600080fd5b505050604051805190509050610831565b506000610831565b600160a060020a0383166000908152600860205260409020610a6f908361157c565b9050610831565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b600080831515610aef574393505b600b546101009004600160a060020a0316635b7b72c130868a8a8a8960006040516020015260405160e060020a63ffffffff8916028152600160a060020a038716600482019081526024820187905260ff8516606483015282151560a483015260c0604483019081529091608481019060c40187818151815260200191508051906020019080838360005b83811015610b92578082015183820152602001610b7a565b50505050905090810190601f168015610bbf5780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015610bf5578082015183820152602001610bdd565b50505050905090810190601f168015610c225780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b1515610c4657600080fd5b6102c65a03f11515610c5757600080fd5b5050506040518051915050600160a060020a038116633cebb8233360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610cb057600080fd5b6102c65a03f11515610cc157600080fd5b50505080600160a060020a03167f086c875b377f900b07ce03575813022f05dd10ed7640b5282cf6d3c3fc352ade8560405190815260200160405180910390a29695505050505050565b6000610d178243610940565b90505b919050565b600554600160a060020a031681565b600080548190819033600160a060020a03908116911614610d4e57600080fd5b610d5661083d565b915083820182901015610d6857600080fd5b610d7185610d0b565b905083810181901015610d8357600080fd5b610d90600a8584016116db565b600160a060020a0385166000908152600860205260409020610db4908286016116db565b84600160a060020a0316600060008051602061180f8339815191528660405190815260200160405180910390a3506001949350505050565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b600a546000901580610e8c575081600a6000815481101515610e7557fe5b6000918252602090912001546001608060020a0316115b15610f2e57600554600160a060020a031615610f2657600554600654600160a060020a039091169063981b24d090610ec5908590611564565b60006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610f0457600080fd5b6102c65a03f11515610f1557600080fd5b505050604051805190509050610d1a565b506000610d1a565b610f39600a8361157c565b9050610d1a565b600b5460009060ff161515610f5457600080fd5b610f5f338484611372565b50600192915050565b600b5460ff1681565b60065481565b6000610f8384846106ce565b1515610f8e57600080fd5b83600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561102657808201518382015260200161100e565b50505050905090810190601f1680156110535780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561107457600080fd5b6102c65a03f1151561108557600080fd5b5060019695505050505050565b600080548190819033600160a060020a039081169116146110b257600080fd5b6110ba61083d565b9150838210156110c957600080fd5b6110d285610d0b565b9050838110156110e157600080fd5b6110ee600a8584036116db565b600160a060020a0385166000908152600860205260409020611112908583036116db565b600085600160a060020a031660008051602061180f8339815191528660405190815260200160405180910390a3506001949350505050565b600160a060020a03918216600090815260096020908152604080832093909416825291909152205490565b60008054819033600160a060020a0390811691161461119357600080fd5b600160a060020a03831615156111e157600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f1935050505015156111dc57600080fd5b61131c565b82915081600160a060020a03166370a082313060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561123b57600080fd5b6102c65a03f1151561124c57600080fd5b505050604051805160008054919350600160a060020a03808616935063a9059cbb92169084906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156112bc57600080fd5b6102c65a03f115156112cd57600080fd5b50505060405180515050600054600160a060020a039081169084167ff931edb47c50b4b4104c187b5814a9aef5f709e17e2ecf9617e860cacade929c8360405190815260200160405180910390a35b505050565b600b546101009004600160a060020a031681565b60005433600160a060020a0390811691161461135057600080fd5b600b805460ff1916911515919091179055565b600054600160a060020a031681565b6000808215156113b65783600160a060020a031685600160a060020a031660008051602061180f8339815191528560405190815260200160405180910390a361155d565b6006544390106113c557600080fd5b600160a060020a038416158015906113ef575030600160a060020a031684600160a060020a031614155b15156113fa57600080fd5b6114048543610940565b91508282101561141357600080fd5b60005461142890600160a060020a0316610603565b156114c35760008054600160a060020a031690634a393149908790879087906040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561149d57600080fd5b6102c65a03f115156114ae57600080fd5b5050506040518051905015156114c357600080fd5b600160a060020a03851660009081526008602052604090206114e7908484036116db565b6114f18443610940565b90508281018190101561150357600080fd5b600160a060020a0384166000908152600860205260409020611527908285016116db565b83600160a060020a031685600160a060020a031660008051602061180f8339815191528560405190815260200160405180910390a35b5050505050565b60008183106115735781611575565b825b9392505050565b60008060008085805490506000141561159857600093506116d2565b8554869060001981019081106115aa57fe5b6000918252602090912001546001608060020a03168510611607578554869060001981019081106115d757fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031693506116d2565b85600081548110151561161657fe5b6000918252602090912001546001608060020a031685101561163b57600093506116d2565b8554600093506000190191505b8282111561169857600260018385010104905084868281548110151561166a57fe5b6000918252602090912001546001608060020a03161161168c57809250611693565b6001810391505b611648565b85838154811015156116a657fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031693505b50505092915050565b815460009081901580611714575083544390859060001981019081106116fd57fe5b6000918252602090912001546001608060020a0316105b15611786578354849061172a82600183016117d1565b8154811061173457fe5b600091825260209091200180546001608060020a03858116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff19909316929092171617815591506117cb565b83548490600019810190811061179857fe5b600091825260209091200180546001608060020a0380861670010000000000000000000000000000000002911617815590505b50505050565b81548183558181151161131c5760008381526020902061131c91810190830161084b91905b8082111561180a57600081556001016117f6565b50905600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820872e8915fab8238dba3e3df3c2d59bd66577da1a8c400bfd80f851b5e974bb860029a165627a7a7230582071a49c4e73c0988d543dd5f789e7f2f3786c7b3899d298a2c02d83406d2e26580029"
14 | exports.MiniMeTokenFactoryRuntimeByteCode = "0x6060604052600436106100405763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416635b7b72c18114610045575b600080fd5b341561005057600080fd5b6101096004803573ffffffffffffffffffffffffffffffffffffffff169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803560ff1690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405281815292919060208401838380828437509496505050509135151591506101329050565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b60008030888888888888610144610313565b73ffffffffffffffffffffffffffffffffffffffff8089168252871660208201526040810186905260ff8416608082015281151560c082015260e0606082018181529060a0830190830187818151815260200191508051906020019080838360005b838110156101be5780820151838201526020016101a6565b50505050905090810190601f1680156101eb5780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015610221578082015183820152602001610209565b50505050905090810190601f16801561024e5780820380516001836020036101000a031916815260200191505b509950505050505050505050604051809103906000f080151561027057600080fd5b90508073ffffffffffffffffffffffffffffffffffffffff16633cebb823336040517c010000000000000000000000000000000000000000000000000000000063ffffffff841602815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401600060405180830381600087803b15156102f357600080fd5b6102c65a03f1151561030457600080fd5b50919998505050505050505050565b604051611a7180610324833901905600606060405260408051908101604052600781527f4d4d545f302e3200000000000000000000000000000000000000000000000000602082015260049080516200004d92916020019062000162565b5034156200005a57600080fd5b60405162001a7138038062001a71833981016040528080519190602001805191906020018051919060200180518201919060200180519190602001805182019190602001805160008054600160a060020a03338116600160a060020a031990921691909117909155600b8054918b166101000261010060a860020a0319909216919091179055915060019050848051620000f992916020019062000162565b506002805460ff191660ff851617905560038280516200011e92916020019062000162565b5060058054600160a060020a031916600160a060020a039790971696909617909555505050600655600b805460ff1916911515919091179055504360075562000207565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001a557805160ff1916838001178555620001d5565b82800160010185558215620001d5579182015b82811115620001d5578251825591602001919060010190620001b8565b50620001e3929150620001e7565b5090565b6200020491905b80821115620001e35760008155600101620001ee565b90565b61185a80620002176000396000f30060606040526004361061012f5763ffffffff60e060020a60003504166306fdde0381146101d4578063095ea7b31461025e578063176345141461029457806318160ddd146102b957806323b872dd146102cc578063313ce567146102f45780633cebb8231461031d5780634ee2cd7e1461033c57806354fd4d501461035e5780636638c0871461037157806370a082311461043557806380a5400114610454578063827f32c01461046757806395d89b4114610489578063981b24d01461049c578063a9059cbb146104b2578063bef97c87146104d4578063c5bcc4f1146104e7578063cae9ca51146104fa578063d3ce77fe1461055f578063dd62ed3e14610581578063df8de3e7146105a6578063e77772fe146105c5578063f41e60c5146105d8578063f77c4791146105f0575b60005461014490600160a060020a0316610603565b151561014f57600080fd5b60008054600160a060020a03169063f48c305490349033906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390911660048201526024016020604051808303818588803b15156101ab57600080fd5b6125ee5a03f115156101bc57600080fd5b505050506040518051905015156101d257600080fd5b005b34156101df57600080fd5b6101e7610630565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561022357808201518382015260200161020b565b50505050905090810190601f1680156102505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561026957600080fd5b610280600160a060020a03600435166024356106ce565b604051901515815260200160405180910390f35b341561029f57600080fd5b6102a7610837565b60405190815260200160405180910390f35b34156102c457600080fd5b6102a761083d565b34156102d757600080fd5b610280600160a060020a036004358116906024351660443561084e565b34156102ff57600080fd5b6103076108ed565b60405160ff909116815260200160405180910390f35b341561032857600080fd5b6101d2600160a060020a03600435166108f6565b341561034757600080fd5b6102a7600160a060020a0360043516602435610940565b341561036957600080fd5b6101e7610a76565b341561037c57600080fd5b61041960046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803560ff1690602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528181529291906020840183838082843750949650508435946020013515159350610ae192505050565b604051600160a060020a03909116815260200160405180910390f35b341561044057600080fd5b6102a7600160a060020a0360043516610d0b565b341561045f57600080fd5b610419610d1f565b341561047257600080fd5b610280600160a060020a0360043516602435610d2e565b341561049457600080fd5b6101e7610dec565b34156104a757600080fd5b6102a7600435610e57565b34156104bd57600080fd5b610280600160a060020a0360043516602435610f40565b34156104df57600080fd5b610280610f68565b34156104f257600080fd5b6102a7610f71565b341561050557600080fd5b61028060048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610f7795505050505050565b341561056a57600080fd5b610280600160a060020a0360043516602435611092565b341561058c57600080fd5b6102a7600160a060020a036004358116906024351661114a565b34156105b157600080fd5b6101d2600160a060020a0360043516611175565b34156105d057600080fd5b610419611321565b34156105e357600080fd5b6101d26004351515611335565b34156105fb57600080fd5b610419611363565b600080600160a060020a038316151561061f576000915061062a565b823b90506000811191505b50919050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b820191906000526020600020905b8154815290600101906020018083116106a957829003601f168201915b505050505081565b600b5460009060ff1615156106e257600080fd5b8115806107125750600160a060020a03338116600090815260096020908152604080832093871683529290522054155b151561071d57600080fd5b60005461073290600160a060020a0316610603565b156107cd5760008054600160a060020a03169063da682aeb903390869086906040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156107a757600080fd5b6102c65a03f115156107b857600080fd5b5050506040518051905015156107cd57600080fd5b600160a060020a03338116600081815260096020908152604080832094881680845294909152908190208590557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b60075481565b600061084843610e57565b90505b90565b6000805433600160a060020a039081169116146108d857600b5460ff16151561087657600080fd5b600160a060020a0380851660009081526009602090815260408083203390941683529290522054829010156108aa57600080fd5b600160a060020a03808516600090815260096020908152604080832033909416835292905220805483900390555b6108e3848484611372565b5060019392505050565b60025460ff1681565b60005433600160a060020a0390811691161461091157600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a038216600090815260086020526040812054158061099c5750600160a060020a03831660009081526008602052604081208054849290811061098557fe5b6000918252602090912001546001608060020a0316115b15610a4d57600554600160a060020a031615610a4557600554600654600160a060020a0390911690634ee2cd7e9085906109d7908690611564565b60006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a2357600080fd5b6102c65a03f11515610a3457600080fd5b505050604051805190509050610831565b506000610831565b600160a060020a0383166000908152600860205260409020610a6f908361157c565b9050610831565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b600080831515610aef574393505b600b546101009004600160a060020a0316635b7b72c130868a8a8a8960006040516020015260405160e060020a63ffffffff8916028152600160a060020a038716600482019081526024820187905260ff8516606483015282151560a483015260c0604483019081529091608481019060c40187818151815260200191508051906020019080838360005b83811015610b92578082015183820152602001610b7a565b50505050905090810190601f168015610bbf5780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015610bf5578082015183820152602001610bdd565b50505050905090810190601f168015610c225780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b1515610c4657600080fd5b6102c65a03f11515610c5757600080fd5b5050506040518051915050600160a060020a038116633cebb8233360405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401600060405180830381600087803b1515610cb057600080fd5b6102c65a03f11515610cc157600080fd5b50505080600160a060020a03167f086c875b377f900b07ce03575813022f05dd10ed7640b5282cf6d3c3fc352ade8560405190815260200160405180910390a29695505050505050565b6000610d178243610940565b90505b919050565b600554600160a060020a031681565b600080548190819033600160a060020a03908116911614610d4e57600080fd5b610d5661083d565b915083820182901015610d6857600080fd5b610d7185610d0b565b905083810181901015610d8357600080fd5b610d90600a8584016116db565b600160a060020a0385166000908152600860205260409020610db4908286016116db565b84600160a060020a0316600060008051602061180f8339815191528660405190815260200160405180910390a3506001949350505050565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106c65780601f1061069b576101008083540402835291602001916106c6565b600a546000901580610e8c575081600a6000815481101515610e7557fe5b6000918252602090912001546001608060020a0316115b15610f2e57600554600160a060020a031615610f2657600554600654600160a060020a039091169063981b24d090610ec5908590611564565b60006040516020015260405160e060020a63ffffffff84160281526004810191909152602401602060405180830381600087803b1515610f0457600080fd5b6102c65a03f11515610f1557600080fd5b505050604051805190509050610d1a565b506000610d1a565b610f39600a8361157c565b9050610d1a565b600b5460009060ff161515610f5457600080fd5b610f5f338484611372565b50600192915050565b600b5460ff1681565b60065481565b6000610f8384846106ce565b1515610f8e57600080fd5b83600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561102657808201518382015260200161100e565b50505050905090810190601f1680156110535780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561107457600080fd5b6102c65a03f1151561108557600080fd5b5060019695505050505050565b600080548190819033600160a060020a039081169116146110b257600080fd5b6110ba61083d565b9150838210156110c957600080fd5b6110d285610d0b565b9050838110156110e157600080fd5b6110ee600a8584036116db565b600160a060020a0385166000908152600860205260409020611112908583036116db565b600085600160a060020a031660008051602061180f8339815191528660405190815260200160405180910390a3506001949350505050565b600160a060020a03918216600090815260096020908152604080832093909416825291909152205490565b60008054819033600160a060020a0390811691161461119357600080fd5b600160a060020a03831615156111e157600054600160a060020a039081169030163180156108fc0290604051600060405180830381858888f1935050505015156111dc57600080fd5b61131c565b82915081600160a060020a03166370a082313060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b151561123b57600080fd5b6102c65a03f1151561124c57600080fd5b505050604051805160008054919350600160a060020a03808616935063a9059cbb92169084906040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156112bc57600080fd5b6102c65a03f115156112cd57600080fd5b50505060405180515050600054600160a060020a039081169084167ff931edb47c50b4b4104c187b5814a9aef5f709e17e2ecf9617e860cacade929c8360405190815260200160405180910390a35b505050565b600b546101009004600160a060020a031681565b60005433600160a060020a0390811691161461135057600080fd5b600b805460ff1916911515919091179055565b600054600160a060020a031681565b6000808215156113b65783600160a060020a031685600160a060020a031660008051602061180f8339815191528560405190815260200160405180910390a361155d565b6006544390106113c557600080fd5b600160a060020a038416158015906113ef575030600160a060020a031684600160a060020a031614155b15156113fa57600080fd5b6114048543610940565b91508282101561141357600080fd5b60005461142890600160a060020a0316610603565b156114c35760008054600160a060020a031690634a393149908790879087906040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b151561149d57600080fd5b6102c65a03f115156114ae57600080fd5b5050506040518051905015156114c357600080fd5b600160a060020a03851660009081526008602052604090206114e7908484036116db565b6114f18443610940565b90508281018190101561150357600080fd5b600160a060020a0384166000908152600860205260409020611527908285016116db565b83600160a060020a031685600160a060020a031660008051602061180f8339815191528560405190815260200160405180910390a35b5050505050565b60008183106115735781611575565b825b9392505050565b60008060008085805490506000141561159857600093506116d2565b8554869060001981019081106115aa57fe5b6000918252602090912001546001608060020a03168510611607578554869060001981019081106115d757fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031693506116d2565b85600081548110151561161657fe5b6000918252602090912001546001608060020a031685101561163b57600093506116d2565b8554600093506000190191505b8282111561169857600260018385010104905084868281548110151561166a57fe5b6000918252602090912001546001608060020a03161161168c57809250611693565b6001810391505b611648565b85838154811015156116a657fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031693505b50505092915050565b815460009081901580611714575083544390859060001981019081106116fd57fe5b6000918252602090912001546001608060020a0316105b15611786578354849061172a82600183016117d1565b8154811061173457fe5b600091825260209091200180546001608060020a03858116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff19909316929092171617815591506117cb565b83548490600019810190811061179857fe5b600091825260209091200180546001608060020a0380861670010000000000000000000000000000000002911617815590505b50505050565b81548183558181151161131c5760008381526020902061131c91810190830161084b91905b8082111561180a57600081556001016117f6565b50905600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820872e8915fab8238dba3e3df3c2d59bd66577da1a8c400bfd80f851b5e974bb860029a165627a7a7230582071a49c4e73c0988d543dd5f789e7f2f3786c7b3899d298a2c02d83406d2e26580029"
15 | exports.TokenControllerAbi = [{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onTransfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onApprove","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"}],"name":"proxyPayment","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"}]
16 | exports.TokenControllerByteCode = "0x"
17 | exports.TokenControllerRuntimeByteCode = "0x"
18 | exports._solcVersion = "0.4.18+commit.9cf6e910.Emscripten.clang"
19 | exports._sha256 = "0xce107acc70c4912b6ae6901846f8ff4464203918656eb585a3f6051b1ef15649"
20 |
--------------------------------------------------------------------------------
/build/MiniMeToken_all.sol:
--------------------------------------------------------------------------------
1 |
2 | //File: contracts/Controlled.sol
3 | pragma solidity ^0.4.18;
4 |
5 | contract Controlled {
6 | /// @notice The address of the controller is the only address that can call
7 | /// a function with this modifier
8 | modifier onlyController { require(msg.sender == controller); _; }
9 |
10 | address public controller;
11 |
12 | function Controlled() public { controller = msg.sender;}
13 |
14 | /// @notice Changes the controller of the contract
15 | /// @param _newController The new controller of the contract
16 | function changeController(address _newController) public onlyController {
17 | controller = _newController;
18 | }
19 | }
20 |
21 | //File: contracts/TokenController.sol
22 | pragma solidity ^0.4.18;
23 |
24 | /// @dev The token controller contract must implement these functions
25 | contract TokenController {
26 | /// @notice Called when `_owner` sends ether to the MiniMe Token contract
27 | /// @param _owner The address that sent the ether to create tokens
28 | /// @return True if the ether is accepted, false if it throws
29 | function proxyPayment(address _owner) public payable returns(bool);
30 |
31 | /// @notice Notifies the controller about a token transfer allowing the
32 | /// controller to react if desired
33 | /// @param _from The origin of the transfer
34 | /// @param _to The destination of the transfer
35 | /// @param _amount The amount of the transfer
36 | /// @return False if the controller does not authorize the transfer
37 | function onTransfer(address _from, address _to, uint _amount) public returns(bool);
38 |
39 | /// @notice Notifies the controller about an approval allowing the
40 | /// controller to react if desired
41 | /// @param _owner The address that calls `approve()`
42 | /// @param _spender The spender in the `approve()` call
43 | /// @param _amount The amount in the `approve()` call
44 | /// @return False if the controller does not authorize the approval
45 | function onApprove(address _owner, address _spender, uint _amount) public
46 | returns(bool);
47 | }
48 |
49 | //File: ./contracts/MiniMeToken.sol
50 | pragma solidity ^0.4.18;
51 |
52 | /*
53 | Copyright 2016, Jordi Baylina
54 |
55 | This program is free software: you can redistribute it and/or modify
56 | it under the terms of the GNU General Public License as published by
57 | the Free Software Foundation, either version 3 of the License, or
58 | (at your option) any later version.
59 |
60 | This program is distributed in the hope that it will be useful,
61 | but WITHOUT ANY WARRANTY; without even the implied warranty of
62 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63 | GNU General Public License for more details.
64 |
65 | You should have received a copy of the GNU General Public License
66 | along with this program. If not, see .
67 | */
68 |
69 | /// @title MiniMeToken Contract
70 | /// @author Jordi Baylina
71 | /// @dev This token contract's goal is to make it easy for anyone to clone this
72 | /// token using the token distribution at a given block, this will allow DAO's
73 | /// and DApps to upgrade their features in a decentralized manner without
74 | /// affecting the original token
75 | /// @dev It is ERC20 compliant, but still needs to under go further testing.
76 |
77 |
78 |
79 |
80 | contract ApproveAndCallFallBack {
81 | function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public;
82 | }
83 |
84 | /// @dev The actual token contract, the default controller is the msg.sender
85 | /// that deploys the contract, so usually this token will be deployed by a
86 | /// token controller contract, which Giveth will call a "Campaign"
87 | contract MiniMeToken is Controlled {
88 |
89 | string public name; //The Token's name: e.g. DigixDAO Tokens
90 | uint8 public decimals; //Number of decimals of the smallest unit
91 | string public symbol; //An identifier: e.g. REP
92 | string public version = 'MMT_0.2'; //An arbitrary versioning scheme
93 |
94 |
95 | /// @dev `Checkpoint` is the structure that attaches a block number to a
96 | /// given value, the block number attached is the one that last changed the
97 | /// value
98 | struct Checkpoint {
99 |
100 | // `fromBlock` is the block number that the value was generated from
101 | uint128 fromBlock;
102 |
103 | // `value` is the amount of tokens at a specific block number
104 | uint128 value;
105 | }
106 |
107 | // `parentToken` is the Token address that was cloned to produce this token;
108 | // it will be 0x0 for a token that was not cloned
109 | MiniMeToken public parentToken;
110 |
111 | // `parentSnapShotBlock` is the block number from the Parent Token that was
112 | // used to determine the initial distribution of the Clone Token
113 | uint public parentSnapShotBlock;
114 |
115 | // `creationBlock` is the block number that the Clone Token was created
116 | uint public creationBlock;
117 |
118 | // `balances` is the map that tracks the balance of each address, in this
119 | // contract when the balance changes the block number that the change
120 | // occurred is also included in the map
121 | mapping (address => Checkpoint[]) balances;
122 |
123 | // `allowed` tracks any extra transfer rights as in all ERC20 tokens
124 | mapping (address => mapping (address => uint256)) allowed;
125 |
126 | // Tracks the history of the `totalSupply` of the token
127 | Checkpoint[] totalSupplyHistory;
128 |
129 | // Flag that determines if the token is transferable or not.
130 | bool public transfersEnabled;
131 |
132 | // The factory used to create new clone tokens
133 | MiniMeTokenFactory public tokenFactory;
134 |
135 | ////////////////
136 | // Constructor
137 | ////////////////
138 |
139 | /// @notice Constructor to create a MiniMeToken
140 | /// @param _tokenFactory The address of the MiniMeTokenFactory contract that
141 | /// will create the Clone token contracts, the token factory needs to be
142 | /// deployed first
143 | /// @param _parentToken Address of the parent token, set to 0x0 if it is a
144 | /// new token
145 | /// @param _parentSnapShotBlock Block of the parent token that will
146 | /// determine the initial distribution of the clone token, set to 0 if it
147 | /// is a new token
148 | /// @param _tokenName Name of the new token
149 | /// @param _decimalUnits Number of decimals of the new token
150 | /// @param _tokenSymbol Token Symbol for the new token
151 | /// @param _transfersEnabled If true, tokens will be able to be transferred
152 | function MiniMeToken(
153 | address _tokenFactory,
154 | address _parentToken,
155 | uint _parentSnapShotBlock,
156 | string _tokenName,
157 | uint8 _decimalUnits,
158 | string _tokenSymbol,
159 | bool _transfersEnabled
160 | ) public {
161 | tokenFactory = MiniMeTokenFactory(_tokenFactory);
162 | name = _tokenName; // Set the name
163 | decimals = _decimalUnits; // Set the decimals
164 | symbol = _tokenSymbol; // Set the symbol
165 | parentToken = MiniMeToken(_parentToken);
166 | parentSnapShotBlock = _parentSnapShotBlock;
167 | transfersEnabled = _transfersEnabled;
168 | creationBlock = block.number;
169 | }
170 |
171 |
172 | ///////////////////
173 | // ERC20 Methods
174 | ///////////////////
175 |
176 | /// @notice Send `_amount` tokens to `_to` from `msg.sender`
177 | /// @param _to The address of the recipient
178 | /// @param _amount The amount of tokens to be transferred
179 | /// @return Whether the transfer was successful or not
180 | function transfer(address _to, uint256 _amount) public returns (bool success) {
181 | require(transfersEnabled);
182 | doTransfer(msg.sender, _to, _amount);
183 | return true;
184 | }
185 |
186 | /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
187 | /// is approved by `_from`
188 | /// @param _from The address holding the tokens being transferred
189 | /// @param _to The address of the recipient
190 | /// @param _amount The amount of tokens to be transferred
191 | /// @return True if the transfer was successful
192 | function transferFrom(address _from, address _to, uint256 _amount
193 | ) public returns (bool success) {
194 |
195 | // The controller of this contract can move tokens around at will,
196 | // this is important to recognize! Confirm that you trust the
197 | // controller of this contract, which in most situations should be
198 | // another open source smart contract or 0x0
199 | if (msg.sender != controller) {
200 | require(transfersEnabled);
201 |
202 | // The standard ERC 20 transferFrom functionality
203 | require(allowed[_from][msg.sender] >= _amount);
204 | allowed[_from][msg.sender] -= _amount;
205 | }
206 | doTransfer(_from, _to, _amount);
207 | return true;
208 | }
209 |
210 | /// @dev This is the actual transfer function in the token contract, it can
211 | /// only be called by other functions in this contract.
212 | /// @param _from The address holding the tokens being transferred
213 | /// @param _to The address of the recipient
214 | /// @param _amount The amount of tokens to be transferred
215 | /// @return True if the transfer was successful
216 | function doTransfer(address _from, address _to, uint _amount
217 | ) internal {
218 |
219 | if (_amount == 0) {
220 | Transfer(_from, _to, _amount); // Follow the spec to louch the event when transfer 0
221 | return;
222 | }
223 |
224 | require(parentSnapShotBlock < block.number);
225 |
226 | // Do not allow transfer to 0x0 or the token contract itself
227 | require((_to != 0) && (_to != address(this)));
228 |
229 | // If the amount being transfered is more than the balance of the
230 | // account the transfer throws
231 | var previousBalanceFrom = balanceOfAt(_from, block.number);
232 |
233 | require(previousBalanceFrom >= _amount);
234 |
235 | // Alerts the token controller of the transfer
236 | if (isContract(controller)) {
237 | require(TokenController(controller).onTransfer(_from, _to, _amount));
238 | }
239 |
240 | // First update the balance array with the new value for the address
241 | // sending the tokens
242 | updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
243 |
244 | // Then update the balance array with the new value for the address
245 | // receiving the tokens
246 | var previousBalanceTo = balanceOfAt(_to, block.number);
247 | require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
248 | updateValueAtNow(balances[_to], previousBalanceTo + _amount);
249 |
250 | // An event to make the transfer easy to find on the blockchain
251 | Transfer(_from, _to, _amount);
252 |
253 | }
254 |
255 | /// @param _owner The address that's balance is being requested
256 | /// @return The balance of `_owner` at the current block
257 | function balanceOf(address _owner) public constant returns (uint256 balance) {
258 | return balanceOfAt(_owner, block.number);
259 | }
260 |
261 | /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
262 | /// its behalf. This is a modified version of the ERC20 approve function
263 | /// to be a little bit safer
264 | /// @param _spender The address of the account able to transfer the tokens
265 | /// @param _amount The amount of tokens to be approved for transfer
266 | /// @return True if the approval was successful
267 | function approve(address _spender, uint256 _amount) public returns (bool success) {
268 | require(transfersEnabled);
269 |
270 | // To change the approve amount you first have to reduce the addresses`
271 | // allowance to zero by calling `approve(_spender,0)` if it is not
272 | // already 0 to mitigate the race condition described here:
273 | // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
274 | require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
275 |
276 | // Alerts the token controller of the approve function call
277 | if (isContract(controller)) {
278 | require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
279 | }
280 |
281 | allowed[msg.sender][_spender] = _amount;
282 | Approval(msg.sender, _spender, _amount);
283 | return true;
284 | }
285 |
286 | /// @dev This function makes it easy to read the `allowed[]` map
287 | /// @param _owner The address of the account that owns the token
288 | /// @param _spender The address of the account able to transfer the tokens
289 | /// @return Amount of remaining tokens of _owner that _spender is allowed
290 | /// to spend
291 | function allowance(address _owner, address _spender
292 | ) public constant returns (uint256 remaining) {
293 | return allowed[_owner][_spender];
294 | }
295 |
296 | /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
297 | /// its behalf, and then a function is triggered in the contract that is
298 | /// being approved, `_spender`. This allows users to use their tokens to
299 | /// interact with contracts in one function call instead of two
300 | /// @param _spender The address of the contract able to transfer the tokens
301 | /// @param _amount The amount of tokens to be approved for transfer
302 | /// @return True if the function call was successful
303 | function approveAndCall(address _spender, uint256 _amount, bytes _extraData
304 | ) public returns (bool success) {
305 | require(approve(_spender, _amount));
306 |
307 | ApproveAndCallFallBack(_spender).receiveApproval(
308 | msg.sender,
309 | _amount,
310 | this,
311 | _extraData
312 | );
313 |
314 | return true;
315 | }
316 |
317 | /// @dev This function makes it easy to get the total number of tokens
318 | /// @return The total number of tokens
319 | function totalSupply() public constant returns (uint) {
320 | return totalSupplyAt(block.number);
321 | }
322 |
323 |
324 | ////////////////
325 | // Query balance and totalSupply in History
326 | ////////////////
327 |
328 | /// @dev Queries the balance of `_owner` at a specific `_blockNumber`
329 | /// @param _owner The address from which the balance will be retrieved
330 | /// @param _blockNumber The block number when the balance is queried
331 | /// @return The balance at `_blockNumber`
332 | function balanceOfAt(address _owner, uint _blockNumber) public constant
333 | returns (uint) {
334 |
335 | // These next few lines are used when the balance of the token is
336 | // requested before a check point was ever created for this token, it
337 | // requires that the `parentToken.balanceOfAt` be queried at the
338 | // genesis block for that token as this contains initial balance of
339 | // this token
340 | if ((balances[_owner].length == 0)
341 | || (balances[_owner][0].fromBlock > _blockNumber)) {
342 | if (address(parentToken) != 0) {
343 | return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
344 | } else {
345 | // Has no parent
346 | return 0;
347 | }
348 |
349 | // This will return the expected balance during normal situations
350 | } else {
351 | return getValueAt(balances[_owner], _blockNumber);
352 | }
353 | }
354 |
355 | /// @notice Total amount of tokens at a specific `_blockNumber`.
356 | /// @param _blockNumber The block number when the totalSupply is queried
357 | /// @return The total amount of tokens at `_blockNumber`
358 | function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
359 |
360 | // These next few lines are used when the totalSupply of the token is
361 | // requested before a check point was ever created for this token, it
362 | // requires that the `parentToken.totalSupplyAt` be queried at the
363 | // genesis block for this token as that contains totalSupply of this
364 | // token at this block number.
365 | if ((totalSupplyHistory.length == 0)
366 | || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
367 | if (address(parentToken) != 0) {
368 | return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
369 | } else {
370 | return 0;
371 | }
372 |
373 | // This will return the expected totalSupply during normal situations
374 | } else {
375 | return getValueAt(totalSupplyHistory, _blockNumber);
376 | }
377 | }
378 |
379 | ////////////////
380 | // Clone Token Method
381 | ////////////////
382 |
383 | /// @notice Creates a new clone token with the initial distribution being
384 | /// this token at `_snapshotBlock`
385 | /// @param _cloneTokenName Name of the clone token
386 | /// @param _cloneDecimalUnits Number of decimals of the smallest unit
387 | /// @param _cloneTokenSymbol Symbol of the clone token
388 | /// @param _snapshotBlock Block when the distribution of the parent token is
389 | /// copied to set the initial distribution of the new clone token;
390 | /// if the block is zero than the actual block, the current block is used
391 | /// @param _transfersEnabled True if transfers are allowed in the clone
392 | /// @return The address of the new MiniMeToken Contract
393 | function createCloneToken(
394 | string _cloneTokenName,
395 | uint8 _cloneDecimalUnits,
396 | string _cloneTokenSymbol,
397 | uint _snapshotBlock,
398 | bool _transfersEnabled
399 | ) public returns(address) {
400 | if (_snapshotBlock == 0) _snapshotBlock = block.number;
401 | MiniMeToken cloneToken = tokenFactory.createCloneToken(
402 | this,
403 | _snapshotBlock,
404 | _cloneTokenName,
405 | _cloneDecimalUnits,
406 | _cloneTokenSymbol,
407 | _transfersEnabled
408 | );
409 |
410 | cloneToken.changeController(msg.sender);
411 |
412 | // An event to make the token easy to find on the blockchain
413 | NewCloneToken(address(cloneToken), _snapshotBlock);
414 | return address(cloneToken);
415 | }
416 |
417 | ////////////////
418 | // Generate and destroy tokens
419 | ////////////////
420 |
421 | /// @notice Generates `_amount` tokens that are assigned to `_owner`
422 | /// @param _owner The address that will be assigned the new tokens
423 | /// @param _amount The quantity of tokens generated
424 | /// @return True if the tokens are generated correctly
425 | function generateTokens(address _owner, uint _amount
426 | ) public onlyController returns (bool) {
427 | uint curTotalSupply = totalSupply();
428 | require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
429 | uint previousBalanceTo = balanceOf(_owner);
430 | require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
431 | updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
432 | updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
433 | Transfer(0, _owner, _amount);
434 | return true;
435 | }
436 |
437 |
438 | /// @notice Burns `_amount` tokens from `_owner`
439 | /// @param _owner The address that will lose the tokens
440 | /// @param _amount The quantity of tokens to burn
441 | /// @return True if the tokens are burned correctly
442 | function destroyTokens(address _owner, uint _amount
443 | ) onlyController public returns (bool) {
444 | uint curTotalSupply = totalSupply();
445 | require(curTotalSupply >= _amount);
446 | uint previousBalanceFrom = balanceOf(_owner);
447 | require(previousBalanceFrom >= _amount);
448 | updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
449 | updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
450 | Transfer(_owner, 0, _amount);
451 | return true;
452 | }
453 |
454 | ////////////////
455 | // Enable tokens transfers
456 | ////////////////
457 |
458 |
459 | /// @notice Enables token holders to transfer their tokens freely if true
460 | /// @param _transfersEnabled True if transfers are allowed in the clone
461 | function enableTransfers(bool _transfersEnabled) public onlyController {
462 | transfersEnabled = _transfersEnabled;
463 | }
464 |
465 | ////////////////
466 | // Internal helper functions to query and set a value in a snapshot array
467 | ////////////////
468 |
469 | /// @dev `getValueAt` retrieves the number of tokens at a given block number
470 | /// @param checkpoints The history of values being queried
471 | /// @param _block The block number to retrieve the value at
472 | /// @return The number of tokens being queried
473 | function getValueAt(Checkpoint[] storage checkpoints, uint _block
474 | ) constant internal returns (uint) {
475 | if (checkpoints.length == 0) return 0;
476 |
477 | // Shortcut for the actual value
478 | if (_block >= checkpoints[checkpoints.length-1].fromBlock)
479 | return checkpoints[checkpoints.length-1].value;
480 | if (_block < checkpoints[0].fromBlock) return 0;
481 |
482 | // Binary search of the value in the array
483 | uint min = 0;
484 | uint max = checkpoints.length-1;
485 | while (max > min) {
486 | uint mid = (max + min + 1)/ 2;
487 | if (checkpoints[mid].fromBlock<=_block) {
488 | min = mid;
489 | } else {
490 | max = mid-1;
491 | }
492 | }
493 | return checkpoints[min].value;
494 | }
495 |
496 | /// @dev `updateValueAtNow` used to update the `balances` map and the
497 | /// `totalSupplyHistory`
498 | /// @param checkpoints The history of data being updated
499 | /// @param _value The new number of tokens
500 | function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
501 | ) internal {
502 | if ((checkpoints.length == 0)
503 | || (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
504 | Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ];
505 | newCheckPoint.fromBlock = uint128(block.number);
506 | newCheckPoint.value = uint128(_value);
507 | } else {
508 | Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
509 | oldCheckPoint.value = uint128(_value);
510 | }
511 | }
512 |
513 | /// @dev Internal function to determine if an address is a contract
514 | /// @param _addr The address being queried
515 | /// @return True if `_addr` is a contract
516 | function isContract(address _addr) constant internal returns(bool) {
517 | uint size;
518 | if (_addr == 0) return false;
519 | assembly {
520 | size := extcodesize(_addr)
521 | }
522 | return size>0;
523 | }
524 |
525 | /// @dev Helper function to return a min betwen the two uints
526 | function min(uint a, uint b) pure internal returns (uint) {
527 | return a < b ? a : b;
528 | }
529 |
530 | /// @notice The fallback function: If the contract's controller has not been
531 | /// set to 0, then the `proxyPayment` method is called which relays the
532 | /// ether and creates tokens as described in the token controller contract
533 | function () public payable {
534 | require(isContract(controller));
535 | require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
536 | }
537 |
538 | //////////
539 | // Safety Methods
540 | //////////
541 |
542 | /// @notice This method can be used by the controller to extract mistakenly
543 | /// sent tokens to this contract.
544 | /// @param _token The address of the token contract that you want to recover
545 | /// set to 0 in case you want to extract ether.
546 | function claimTokens(address _token) public onlyController {
547 | if (_token == 0x0) {
548 | controller.transfer(this.balance);
549 | return;
550 | }
551 |
552 | MiniMeToken token = MiniMeToken(_token);
553 | uint balance = token.balanceOf(this);
554 | token.transfer(controller, balance);
555 | ClaimedTokens(_token, controller, balance);
556 | }
557 |
558 | ////////////////
559 | // Events
560 | ////////////////
561 | event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
562 | event Transfer(address indexed _from, address indexed _to, uint256 _amount);
563 | event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
564 | event Approval(
565 | address indexed _owner,
566 | address indexed _spender,
567 | uint256 _amount
568 | );
569 |
570 | }
571 |
572 |
573 | ////////////////
574 | // MiniMeTokenFactory
575 | ////////////////
576 |
577 | /// @dev This contract is used to generate clone contracts from a contract.
578 | /// In solidity this is the way to create a contract from a contract of the
579 | /// same class
580 | contract MiniMeTokenFactory {
581 |
582 | /// @notice Update the DApp by creating a new token with new functionalities
583 | /// the msg.sender becomes the controller of this clone token
584 | /// @param _parentToken Address of the token being cloned
585 | /// @param _snapshotBlock Block of the parent token that will
586 | /// determine the initial distribution of the clone token
587 | /// @param _tokenName Name of the new token
588 | /// @param _decimalUnits Number of decimals of the new token
589 | /// @param _tokenSymbol Token Symbol for the new token
590 | /// @param _transfersEnabled If true, tokens will be able to be transferred
591 | /// @return The address of the new token contract
592 | function createCloneToken(
593 | address _parentToken,
594 | uint _snapshotBlock,
595 | string _tokenName,
596 | uint8 _decimalUnits,
597 | string _tokenSymbol,
598 | bool _transfersEnabled
599 | ) public returns (MiniMeToken) {
600 | MiniMeToken newToken = new MiniMeToken(
601 | this,
602 | _parentToken,
603 | _snapshotBlock,
604 | _tokenName,
605 | _decimalUnits,
606 | _tokenSymbol,
607 | _transfersEnabled
608 | );
609 |
610 | newToken.changeController(msg.sender);
611 | return newToken;
612 | }
613 | }
614 |
--------------------------------------------------------------------------------
/build/SampleCampaign-TokenController_all.sol:
--------------------------------------------------------------------------------
1 |
2 | //File: contracts/Controlled.sol
3 | pragma solidity ^0.4.18;
4 |
5 | contract Controlled {
6 | /// @notice The address of the controller is the only address that can call
7 | /// a function with this modifier
8 | modifier onlyController { require(msg.sender == controller); _; }
9 |
10 | address public controller;
11 |
12 | function Controlled() public { controller = msg.sender;}
13 |
14 | /// @notice Changes the controller of the contract
15 | /// @param _newController The new controller of the contract
16 | function changeController(address _newController) public onlyController {
17 | controller = _newController;
18 | }
19 | }
20 |
21 | //File: contracts/TokenController.sol
22 | pragma solidity ^0.4.18;
23 |
24 | /// @dev The token controller contract must implement these functions
25 | contract TokenController {
26 | /// @notice Called when `_owner` sends ether to the MiniMe Token contract
27 | /// @param _owner The address that sent the ether to create tokens
28 | /// @return True if the ether is accepted, false if it throws
29 | function proxyPayment(address _owner) public payable returns(bool);
30 |
31 | /// @notice Notifies the controller about a token transfer allowing the
32 | /// controller to react if desired
33 | /// @param _from The origin of the transfer
34 | /// @param _to The destination of the transfer
35 | /// @param _amount The amount of the transfer
36 | /// @return False if the controller does not authorize the transfer
37 | function onTransfer(address _from, address _to, uint _amount) public returns(bool);
38 |
39 | /// @notice Notifies the controller about an approval allowing the
40 | /// controller to react if desired
41 | /// @param _owner The address that calls `approve()`
42 | /// @param _spender The spender in the `approve()` call
43 | /// @param _amount The amount in the `approve()` call
44 | /// @return False if the controller does not authorize the approval
45 | function onApprove(address _owner, address _spender, uint _amount) public
46 | returns(bool);
47 | }
48 |
49 | //File: contracts/MiniMeToken.sol
50 | pragma solidity ^0.4.18;
51 |
52 | /*
53 | Copyright 2016, Jordi Baylina
54 |
55 | This program is free software: you can redistribute it and/or modify
56 | it under the terms of the GNU General Public License as published by
57 | the Free Software Foundation, either version 3 of the License, or
58 | (at your option) any later version.
59 |
60 | This program is distributed in the hope that it will be useful,
61 | but WITHOUT ANY WARRANTY; without even the implied warranty of
62 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63 | GNU General Public License for more details.
64 |
65 | You should have received a copy of the GNU General Public License
66 | along with this program. If not, see .
67 | */
68 |
69 | /// @title MiniMeToken Contract
70 | /// @author Jordi Baylina
71 | /// @dev This token contract's goal is to make it easy for anyone to clone this
72 | /// token using the token distribution at a given block, this will allow DAO's
73 | /// and DApps to upgrade their features in a decentralized manner without
74 | /// affecting the original token
75 | /// @dev It is ERC20 compliant, but still needs to under go further testing.
76 |
77 |
78 |
79 |
80 | contract ApproveAndCallFallBack {
81 | function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public;
82 | }
83 |
84 | /// @dev The actual token contract, the default controller is the msg.sender
85 | /// that deploys the contract, so usually this token will be deployed by a
86 | /// token controller contract, which Giveth will call a "Campaign"
87 | contract MiniMeToken is Controlled {
88 |
89 | string public name; //The Token's name: e.g. DigixDAO Tokens
90 | uint8 public decimals; //Number of decimals of the smallest unit
91 | string public symbol; //An identifier: e.g. REP
92 | string public version = 'MMT_0.2'; //An arbitrary versioning scheme
93 |
94 |
95 | /// @dev `Checkpoint` is the structure that attaches a block number to a
96 | /// given value, the block number attached is the one that last changed the
97 | /// value
98 | struct Checkpoint {
99 |
100 | // `fromBlock` is the block number that the value was generated from
101 | uint128 fromBlock;
102 |
103 | // `value` is the amount of tokens at a specific block number
104 | uint128 value;
105 | }
106 |
107 | // `parentToken` is the Token address that was cloned to produce this token;
108 | // it will be 0x0 for a token that was not cloned
109 | MiniMeToken public parentToken;
110 |
111 | // `parentSnapShotBlock` is the block number from the Parent Token that was
112 | // used to determine the initial distribution of the Clone Token
113 | uint public parentSnapShotBlock;
114 |
115 | // `creationBlock` is the block number that the Clone Token was created
116 | uint public creationBlock;
117 |
118 | // `balances` is the map that tracks the balance of each address, in this
119 | // contract when the balance changes the block number that the change
120 | // occurred is also included in the map
121 | mapping (address => Checkpoint[]) balances;
122 |
123 | // `allowed` tracks any extra transfer rights as in all ERC20 tokens
124 | mapping (address => mapping (address => uint256)) allowed;
125 |
126 | // Tracks the history of the `totalSupply` of the token
127 | Checkpoint[] totalSupplyHistory;
128 |
129 | // Flag that determines if the token is transferable or not.
130 | bool public transfersEnabled;
131 |
132 | // The factory used to create new clone tokens
133 | MiniMeTokenFactory public tokenFactory;
134 |
135 | ////////////////
136 | // Constructor
137 | ////////////////
138 |
139 | /// @notice Constructor to create a MiniMeToken
140 | /// @param _tokenFactory The address of the MiniMeTokenFactory contract that
141 | /// will create the Clone token contracts, the token factory needs to be
142 | /// deployed first
143 | /// @param _parentToken Address of the parent token, set to 0x0 if it is a
144 | /// new token
145 | /// @param _parentSnapShotBlock Block of the parent token that will
146 | /// determine the initial distribution of the clone token, set to 0 if it
147 | /// is a new token
148 | /// @param _tokenName Name of the new token
149 | /// @param _decimalUnits Number of decimals of the new token
150 | /// @param _tokenSymbol Token Symbol for the new token
151 | /// @param _transfersEnabled If true, tokens will be able to be transferred
152 | function MiniMeToken(
153 | address _tokenFactory,
154 | address _parentToken,
155 | uint _parentSnapShotBlock,
156 | string _tokenName,
157 | uint8 _decimalUnits,
158 | string _tokenSymbol,
159 | bool _transfersEnabled
160 | ) public {
161 | tokenFactory = MiniMeTokenFactory(_tokenFactory);
162 | name = _tokenName; // Set the name
163 | decimals = _decimalUnits; // Set the decimals
164 | symbol = _tokenSymbol; // Set the symbol
165 | parentToken = MiniMeToken(_parentToken);
166 | parentSnapShotBlock = _parentSnapShotBlock;
167 | transfersEnabled = _transfersEnabled;
168 | creationBlock = block.number;
169 | }
170 |
171 |
172 | ///////////////////
173 | // ERC20 Methods
174 | ///////////////////
175 |
176 | /// @notice Send `_amount` tokens to `_to` from `msg.sender`
177 | /// @param _to The address of the recipient
178 | /// @param _amount The amount of tokens to be transferred
179 | /// @return Whether the transfer was successful or not
180 | function transfer(address _to, uint256 _amount) public returns (bool success) {
181 | require(transfersEnabled);
182 | doTransfer(msg.sender, _to, _amount);
183 | return true;
184 | }
185 |
186 | /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
187 | /// is approved by `_from`
188 | /// @param _from The address holding the tokens being transferred
189 | /// @param _to The address of the recipient
190 | /// @param _amount The amount of tokens to be transferred
191 | /// @return True if the transfer was successful
192 | function transferFrom(address _from, address _to, uint256 _amount
193 | ) public returns (bool success) {
194 |
195 | // The controller of this contract can move tokens around at will,
196 | // this is important to recognize! Confirm that you trust the
197 | // controller of this contract, which in most situations should be
198 | // another open source smart contract or 0x0
199 | if (msg.sender != controller) {
200 | require(transfersEnabled);
201 |
202 | // The standard ERC 20 transferFrom functionality
203 | require(allowed[_from][msg.sender] >= _amount);
204 | allowed[_from][msg.sender] -= _amount;
205 | }
206 | doTransfer(_from, _to, _amount);
207 | return true;
208 | }
209 |
210 | /// @dev This is the actual transfer function in the token contract, it can
211 | /// only be called by other functions in this contract.
212 | /// @param _from The address holding the tokens being transferred
213 | /// @param _to The address of the recipient
214 | /// @param _amount The amount of tokens to be transferred
215 | /// @return True if the transfer was successful
216 | function doTransfer(address _from, address _to, uint _amount
217 | ) internal {
218 |
219 | if (_amount == 0) {
220 | Transfer(_from, _to, _amount); // Follow the spec to louch the event when transfer 0
221 | return;
222 | }
223 |
224 | require(parentSnapShotBlock < block.number);
225 |
226 | // Do not allow transfer to 0x0 or the token contract itself
227 | require((_to != 0) && (_to != address(this)));
228 |
229 | // If the amount being transfered is more than the balance of the
230 | // account the transfer throws
231 | var previousBalanceFrom = balanceOfAt(_from, block.number);
232 |
233 | require(previousBalanceFrom >= _amount);
234 |
235 | // Alerts the token controller of the transfer
236 | if (isContract(controller)) {
237 | require(TokenController(controller).onTransfer(_from, _to, _amount));
238 | }
239 |
240 | // First update the balance array with the new value for the address
241 | // sending the tokens
242 | updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
243 |
244 | // Then update the balance array with the new value for the address
245 | // receiving the tokens
246 | var previousBalanceTo = balanceOfAt(_to, block.number);
247 | require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
248 | updateValueAtNow(balances[_to], previousBalanceTo + _amount);
249 |
250 | // An event to make the transfer easy to find on the blockchain
251 | Transfer(_from, _to, _amount);
252 |
253 | }
254 |
255 | /// @param _owner The address that's balance is being requested
256 | /// @return The balance of `_owner` at the current block
257 | function balanceOf(address _owner) public constant returns (uint256 balance) {
258 | return balanceOfAt(_owner, block.number);
259 | }
260 |
261 | /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
262 | /// its behalf. This is a modified version of the ERC20 approve function
263 | /// to be a little bit safer
264 | /// @param _spender The address of the account able to transfer the tokens
265 | /// @param _amount The amount of tokens to be approved for transfer
266 | /// @return True if the approval was successful
267 | function approve(address _spender, uint256 _amount) public returns (bool success) {
268 | require(transfersEnabled);
269 |
270 | // To change the approve amount you first have to reduce the addresses`
271 | // allowance to zero by calling `approve(_spender,0)` if it is not
272 | // already 0 to mitigate the race condition described here:
273 | // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
274 | require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
275 |
276 | // Alerts the token controller of the approve function call
277 | if (isContract(controller)) {
278 | require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
279 | }
280 |
281 | allowed[msg.sender][_spender] = _amount;
282 | Approval(msg.sender, _spender, _amount);
283 | return true;
284 | }
285 |
286 | /// @dev This function makes it easy to read the `allowed[]` map
287 | /// @param _owner The address of the account that owns the token
288 | /// @param _spender The address of the account able to transfer the tokens
289 | /// @return Amount of remaining tokens of _owner that _spender is allowed
290 | /// to spend
291 | function allowance(address _owner, address _spender
292 | ) public constant returns (uint256 remaining) {
293 | return allowed[_owner][_spender];
294 | }
295 |
296 | /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
297 | /// its behalf, and then a function is triggered in the contract that is
298 | /// being approved, `_spender`. This allows users to use their tokens to
299 | /// interact with contracts in one function call instead of two
300 | /// @param _spender The address of the contract able to transfer the tokens
301 | /// @param _amount The amount of tokens to be approved for transfer
302 | /// @return True if the function call was successful
303 | function approveAndCall(address _spender, uint256 _amount, bytes _extraData
304 | ) public returns (bool success) {
305 | require(approve(_spender, _amount));
306 |
307 | ApproveAndCallFallBack(_spender).receiveApproval(
308 | msg.sender,
309 | _amount,
310 | this,
311 | _extraData
312 | );
313 |
314 | return true;
315 | }
316 |
317 | /// @dev This function makes it easy to get the total number of tokens
318 | /// @return The total number of tokens
319 | function totalSupply() public constant returns (uint) {
320 | return totalSupplyAt(block.number);
321 | }
322 |
323 |
324 | ////////////////
325 | // Query balance and totalSupply in History
326 | ////////////////
327 |
328 | /// @dev Queries the balance of `_owner` at a specific `_blockNumber`
329 | /// @param _owner The address from which the balance will be retrieved
330 | /// @param _blockNumber The block number when the balance is queried
331 | /// @return The balance at `_blockNumber`
332 | function balanceOfAt(address _owner, uint _blockNumber) public constant
333 | returns (uint) {
334 |
335 | // These next few lines are used when the balance of the token is
336 | // requested before a check point was ever created for this token, it
337 | // requires that the `parentToken.balanceOfAt` be queried at the
338 | // genesis block for that token as this contains initial balance of
339 | // this token
340 | if ((balances[_owner].length == 0)
341 | || (balances[_owner][0].fromBlock > _blockNumber)) {
342 | if (address(parentToken) != 0) {
343 | return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
344 | } else {
345 | // Has no parent
346 | return 0;
347 | }
348 |
349 | // This will return the expected balance during normal situations
350 | } else {
351 | return getValueAt(balances[_owner], _blockNumber);
352 | }
353 | }
354 |
355 | /// @notice Total amount of tokens at a specific `_blockNumber`.
356 | /// @param _blockNumber The block number when the totalSupply is queried
357 | /// @return The total amount of tokens at `_blockNumber`
358 | function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
359 |
360 | // These next few lines are used when the totalSupply of the token is
361 | // requested before a check point was ever created for this token, it
362 | // requires that the `parentToken.totalSupplyAt` be queried at the
363 | // genesis block for this token as that contains totalSupply of this
364 | // token at this block number.
365 | if ((totalSupplyHistory.length == 0)
366 | || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
367 | if (address(parentToken) != 0) {
368 | return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
369 | } else {
370 | return 0;
371 | }
372 |
373 | // This will return the expected totalSupply during normal situations
374 | } else {
375 | return getValueAt(totalSupplyHistory, _blockNumber);
376 | }
377 | }
378 |
379 | ////////////////
380 | // Clone Token Method
381 | ////////////////
382 |
383 | /// @notice Creates a new clone token with the initial distribution being
384 | /// this token at `_snapshotBlock`
385 | /// @param _cloneTokenName Name of the clone token
386 | /// @param _cloneDecimalUnits Number of decimals of the smallest unit
387 | /// @param _cloneTokenSymbol Symbol of the clone token
388 | /// @param _snapshotBlock Block when the distribution of the parent token is
389 | /// copied to set the initial distribution of the new clone token;
390 | /// if the block is zero than the actual block, the current block is used
391 | /// @param _transfersEnabled True if transfers are allowed in the clone
392 | /// @return The address of the new MiniMeToken Contract
393 | function createCloneToken(
394 | string _cloneTokenName,
395 | uint8 _cloneDecimalUnits,
396 | string _cloneTokenSymbol,
397 | uint _snapshotBlock,
398 | bool _transfersEnabled
399 | ) public returns(address) {
400 | if (_snapshotBlock == 0) _snapshotBlock = block.number;
401 | MiniMeToken cloneToken = tokenFactory.createCloneToken(
402 | this,
403 | _snapshotBlock,
404 | _cloneTokenName,
405 | _cloneDecimalUnits,
406 | _cloneTokenSymbol,
407 | _transfersEnabled
408 | );
409 |
410 | cloneToken.changeController(msg.sender);
411 |
412 | // An event to make the token easy to find on the blockchain
413 | NewCloneToken(address(cloneToken), _snapshotBlock);
414 | return address(cloneToken);
415 | }
416 |
417 | ////////////////
418 | // Generate and destroy tokens
419 | ////////////////
420 |
421 | /// @notice Generates `_amount` tokens that are assigned to `_owner`
422 | /// @param _owner The address that will be assigned the new tokens
423 | /// @param _amount The quantity of tokens generated
424 | /// @return True if the tokens are generated correctly
425 | function generateTokens(address _owner, uint _amount
426 | ) public onlyController returns (bool) {
427 | uint curTotalSupply = totalSupply();
428 | require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
429 | uint previousBalanceTo = balanceOf(_owner);
430 | require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
431 | updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
432 | updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
433 | Transfer(0, _owner, _amount);
434 | return true;
435 | }
436 |
437 |
438 | /// @notice Burns `_amount` tokens from `_owner`
439 | /// @param _owner The address that will lose the tokens
440 | /// @param _amount The quantity of tokens to burn
441 | /// @return True if the tokens are burned correctly
442 | function destroyTokens(address _owner, uint _amount
443 | ) onlyController public returns (bool) {
444 | uint curTotalSupply = totalSupply();
445 | require(curTotalSupply >= _amount);
446 | uint previousBalanceFrom = balanceOf(_owner);
447 | require(previousBalanceFrom >= _amount);
448 | updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
449 | updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
450 | Transfer(_owner, 0, _amount);
451 | return true;
452 | }
453 |
454 | ////////////////
455 | // Enable tokens transfers
456 | ////////////////
457 |
458 |
459 | /// @notice Enables token holders to transfer their tokens freely if true
460 | /// @param _transfersEnabled True if transfers are allowed in the clone
461 | function enableTransfers(bool _transfersEnabled) public onlyController {
462 | transfersEnabled = _transfersEnabled;
463 | }
464 |
465 | ////////////////
466 | // Internal helper functions to query and set a value in a snapshot array
467 | ////////////////
468 |
469 | /// @dev `getValueAt` retrieves the number of tokens at a given block number
470 | /// @param checkpoints The history of values being queried
471 | /// @param _block The block number to retrieve the value at
472 | /// @return The number of tokens being queried
473 | function getValueAt(Checkpoint[] storage checkpoints, uint _block
474 | ) constant internal returns (uint) {
475 | if (checkpoints.length == 0) return 0;
476 |
477 | // Shortcut for the actual value
478 | if (_block >= checkpoints[checkpoints.length-1].fromBlock)
479 | return checkpoints[checkpoints.length-1].value;
480 | if (_block < checkpoints[0].fromBlock) return 0;
481 |
482 | // Binary search of the value in the array
483 | uint min = 0;
484 | uint max = checkpoints.length-1;
485 | while (max > min) {
486 | uint mid = (max + min + 1)/ 2;
487 | if (checkpoints[mid].fromBlock<=_block) {
488 | min = mid;
489 | } else {
490 | max = mid-1;
491 | }
492 | }
493 | return checkpoints[min].value;
494 | }
495 |
496 | /// @dev `updateValueAtNow` used to update the `balances` map and the
497 | /// `totalSupplyHistory`
498 | /// @param checkpoints The history of data being updated
499 | /// @param _value The new number of tokens
500 | function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
501 | ) internal {
502 | if ((checkpoints.length == 0)
503 | || (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
504 | Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ];
505 | newCheckPoint.fromBlock = uint128(block.number);
506 | newCheckPoint.value = uint128(_value);
507 | } else {
508 | Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
509 | oldCheckPoint.value = uint128(_value);
510 | }
511 | }
512 |
513 | /// @dev Internal function to determine if an address is a contract
514 | /// @param _addr The address being queried
515 | /// @return True if `_addr` is a contract
516 | function isContract(address _addr) constant internal returns(bool) {
517 | uint size;
518 | if (_addr == 0) return false;
519 | assembly {
520 | size := extcodesize(_addr)
521 | }
522 | return size>0;
523 | }
524 |
525 | /// @dev Helper function to return a min betwen the two uints
526 | function min(uint a, uint b) pure internal returns (uint) {
527 | return a < b ? a : b;
528 | }
529 |
530 | /// @notice The fallback function: If the contract's controller has not been
531 | /// set to 0, then the `proxyPayment` method is called which relays the
532 | /// ether and creates tokens as described in the token controller contract
533 | function () public payable {
534 | require(isContract(controller));
535 | require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
536 | }
537 |
538 | //////////
539 | // Safety Methods
540 | //////////
541 |
542 | /// @notice This method can be used by the controller to extract mistakenly
543 | /// sent tokens to this contract.
544 | /// @param _token The address of the token contract that you want to recover
545 | /// set to 0 in case you want to extract ether.
546 | function claimTokens(address _token) public onlyController {
547 | if (_token == 0x0) {
548 | controller.transfer(this.balance);
549 | return;
550 | }
551 |
552 | MiniMeToken token = MiniMeToken(_token);
553 | uint balance = token.balanceOf(this);
554 | token.transfer(controller, balance);
555 | ClaimedTokens(_token, controller, balance);
556 | }
557 |
558 | ////////////////
559 | // Events
560 | ////////////////
561 | event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
562 | event Transfer(address indexed _from, address indexed _to, uint256 _amount);
563 | event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
564 | event Approval(
565 | address indexed _owner,
566 | address indexed _spender,
567 | uint256 _amount
568 | );
569 |
570 | }
571 |
572 |
573 | ////////////////
574 | // MiniMeTokenFactory
575 | ////////////////
576 |
577 | /// @dev This contract is used to generate clone contracts from a contract.
578 | /// In solidity this is the way to create a contract from a contract of the
579 | /// same class
580 | contract MiniMeTokenFactory {
581 |
582 | /// @notice Update the DApp by creating a new token with new functionalities
583 | /// the msg.sender becomes the controller of this clone token
584 | /// @param _parentToken Address of the token being cloned
585 | /// @param _snapshotBlock Block of the parent token that will
586 | /// determine the initial distribution of the clone token
587 | /// @param _tokenName Name of the new token
588 | /// @param _decimalUnits Number of decimals of the new token
589 | /// @param _tokenSymbol Token Symbol for the new token
590 | /// @param _transfersEnabled If true, tokens will be able to be transferred
591 | /// @return The address of the new token contract
592 | function createCloneToken(
593 | address _parentToken,
594 | uint _snapshotBlock,
595 | string _tokenName,
596 | uint8 _decimalUnits,
597 | string _tokenSymbol,
598 | bool _transfersEnabled
599 | ) public returns (MiniMeToken) {
600 | MiniMeToken newToken = new MiniMeToken(
601 | this,
602 | _parentToken,
603 | _snapshotBlock,
604 | _tokenName,
605 | _decimalUnits,
606 | _tokenSymbol,
607 | _transfersEnabled
608 | );
609 |
610 | newToken.changeController(msg.sender);
611 | return newToken;
612 | }
613 | }
614 |
615 | //File: ./contracts/SampleCampaign-TokenController.sol
616 | pragma solidity ^0.4.6;
617 |
618 | /*
619 | Copyright 2017, Jordi Baylina
620 |
621 | This program is free software: you can redistribute it and/or modify
622 | it under the terms of the GNU General Public License as published by
623 | the Free Software Foundation, either version 3 of the License, or
624 | (at your option) any later version.
625 |
626 | This program is distributed in the hope that it will be useful,
627 | but WITHOUT ANY WARRANTY; without even the implied warranty of
628 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
629 | GNU General Public License for more details.
630 |
631 | You should have received a copy of the GNU General Public License
632 | along with this program. If not, see .
633 | */
634 |
635 | /// @title MilestoneTracker Contract
636 | /// @author Jordi Baylina
637 | /// @dev This contract controls the issuance of tokens for the MiniMe Token
638 | /// Contract. This version specifically acts as a Campaign manager for raising
639 | /// funds for non-profit causes, but it can be customized for any variety of
640 | /// purposes.
641 |
642 |
643 |
644 |
645 | /// @dev `Owned` is a base level contract that assigns an `owner` that can be
646 | /// later changed
647 | contract Owned {
648 | /// @dev `owner` is the only address that can call a function with this
649 | /// modifier
650 | modifier onlyOwner { require (msg.sender == owner); _; }
651 |
652 | address public owner;
653 |
654 | /// @notice The Constructor assigns the message sender to be `owner`
655 | function Owned() { owner = msg.sender;}
656 |
657 | /// @notice `owner` can step down and assign some other address to this role
658 | /// @param _newOwner The address of the new owner. 0x0 can be used to create
659 | /// an unowned neutral vault, however that cannot be undone
660 | function changeOwner(address _newOwner) onlyOwner {
661 | owner = _newOwner;
662 | }
663 | }
664 |
665 |
666 | /// @dev This is designed to control the issuance of a MiniMe Token for a
667 | /// non-profit Campaign. This contract effectively dictates the terms of the
668 | /// funding round.
669 |
670 | contract Campaign is TokenController, Owned {
671 |
672 | uint public startFundingTime; // In UNIX Time Format
673 | uint public endFundingTime; // In UNIX Time Format
674 | uint public maximumFunding; // In wei
675 | uint public totalCollected; // In wei
676 | MiniMeToken public tokenContract; // The new token for this Campaign
677 | address public vaultAddress; // The address to hold the funds donated
678 |
679 | /// @notice 'Campaign()' initiates the Campaign by setting its funding
680 | /// parameters
681 | /// @dev There are several checks to make sure the parameters are acceptable
682 | /// @param _startFundingTime The UNIX time that the Campaign will be able to
683 | /// start receiving funds
684 | /// @param _endFundingTime The UNIX time that the Campaign will stop being able
685 | /// to receive funds
686 | /// @param _maximumFunding In wei, the Maximum amount that the Campaign can
687 | /// receive (currently the max is set at 10,000 ETH for the beta)
688 | /// @param _vaultAddress The address that will store the donated funds
689 | /// @param _tokenAddress Address of the token contract this contract controls
690 |
691 | function Campaign(
692 | uint _startFundingTime,
693 | uint _endFundingTime,
694 | uint _maximumFunding,
695 | address _vaultAddress,
696 | address _tokenAddress
697 |
698 | ) {
699 | require ((_endFundingTime >= now) && // Cannot end in the past
700 | (_endFundingTime > _startFundingTime) &&
701 | (_maximumFunding <= 10000 ether) && // The Beta is limited
702 | (_vaultAddress != 0)); // To prevent burning ETH
703 | startFundingTime = _startFundingTime;
704 | endFundingTime = _endFundingTime;
705 | maximumFunding = _maximumFunding;
706 | tokenContract = MiniMeToken(_tokenAddress);// The Deployed Token Contract
707 | vaultAddress = _vaultAddress;
708 | }
709 |
710 | /// @dev The fallback function is called when ether is sent to the contract, it
711 | /// simply calls `doPayment()` with the address that sent the ether as the
712 | /// `_owner`. Payable is a required solidity modifier for functions to receive
713 | /// ether, without this modifier functions will throw if ether is sent to them
714 |
715 | function () payable {
716 | doPayment(msg.sender);
717 | }
718 |
719 | /////////////////
720 | // TokenController interface
721 | /////////////////
722 |
723 | /// @notice `proxyPayment()` allows the caller to send ether to the Campaign and
724 | /// have the tokens created in an address of their choosing
725 | /// @param _owner The address that will hold the newly created tokens
726 |
727 | function proxyPayment(address _owner) payable returns(bool) {
728 | doPayment(_owner);
729 | return true;
730 | }
731 |
732 | /// @notice Notifies the controller about a transfer, for this Campaign all
733 | /// transfers are allowed by default and no extra notifications are needed
734 | /// @param _from The origin of the transfer
735 | /// @param _to The destination of the transfer
736 | /// @param _amount The amount of the transfer
737 | /// @return False if the controller does not authorize the transfer
738 | function onTransfer(address _from, address _to, uint _amount) returns(bool) {
739 | return true;
740 | }
741 |
742 | /// @notice Notifies the controller about an approval, for this Campaign all
743 | /// approvals are allowed by default and no extra notifications are needed
744 | /// @param _owner The address that calls `approve()`
745 | /// @param _spender The spender in the `approve()` call
746 | /// @param _amount The amount in the `approve()` call
747 | /// @return False if the controller does not authorize the approval
748 | function onApprove(address _owner, address _spender, uint _amount)
749 | returns(bool)
750 | {
751 | return true;
752 | }
753 |
754 |
755 | /// @dev `doPayment()` is an internal function that sends the ether that this
756 | /// contract receives to the `vault` and creates tokens in the address of the
757 | /// `_owner` assuming the Campaign is still accepting funds
758 | /// @param _owner The address that will hold the newly created tokens
759 |
760 | function doPayment(address _owner) internal {
761 |
762 | // First check that the Campaign is allowed to receive this donation
763 | require ((now >= startFundingTime) &&
764 | (now <= endFundingTime) &&
765 | (tokenContract.controller() != 0) && // Extra check
766 | (msg.value != 0) &&
767 | (totalCollected + msg.value <= maximumFunding));
768 |
769 | //Track how much the Campaign has collected
770 | totalCollected += msg.value;
771 |
772 | //Send the ether to the vault
773 | require (vaultAddress.send(msg.value));
774 |
775 | // Creates an equal amount of tokens as ether sent. The new tokens are created
776 | // in the `_owner` address
777 | require (tokenContract.generateTokens(_owner, msg.value));
778 |
779 | return;
780 | }
781 |
782 | /// @notice `finalizeFunding()` ends the Campaign by calling setting the
783 | /// controller to 0, thereby ending the issuance of new tokens and stopping the
784 | /// Campaign from receiving more ether
785 | /// @dev `finalizeFunding()` can only be called after the end of the funding period.
786 |
787 | function finalizeFunding() {
788 | require(now >= endFundingTime);
789 | tokenContract.changeController(0);
790 | }
791 |
792 |
793 | /// @notice `onlyOwner` changes the location that ether is sent
794 | /// @param _newVaultAddress The address that will receive the ether sent to this
795 | /// Campaign
796 | function setVault(address _newVaultAddress) onlyOwner {
797 | vaultAddress = _newVaultAddress;
798 | }
799 |
800 | }
801 |
--------------------------------------------------------------------------------
/build/TokenController.sol.js:
--------------------------------------------------------------------------------
1 | /* This is an autogenerated file. DO NOT EDIT MANUALLY */
2 |
3 | exports.TokenControllerAbi = [{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onTransfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onApprove","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"}],"name":"proxyPayment","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"}]
4 | exports.TokenControllerByteCode = "0x"
5 | exports.TokenControllerRuntimeByteCode = "0x"
6 | exports._solcVersion = "0.4.18+commit.9cf6e910.Emscripten.clang"
7 | exports._sha256 = "0x4ab21dd789d6619432629f4e930c7f6cd05cd149e14a8127f99c7c83f2c4377f"
8 |
--------------------------------------------------------------------------------
/build/TokenController_all.sol:
--------------------------------------------------------------------------------
1 |
2 | //File: ./contracts/TokenController.sol
3 | pragma solidity ^0.4.18;
4 |
5 | /// @dev The token controller contract must implement these functions
6 | contract TokenController {
7 | /// @notice Called when `_owner` sends ether to the MiniMe Token contract
8 | /// @param _owner The address that sent the ether to create tokens
9 | /// @return True if the ether is accepted, false if it throws
10 | function proxyPayment(address _owner) public payable returns(bool);
11 |
12 | /// @notice Notifies the controller about a token transfer allowing the
13 | /// controller to react if desired
14 | /// @param _from The origin of the transfer
15 | /// @param _to The destination of the transfer
16 | /// @param _amount The amount of the transfer
17 | /// @return False if the controller does not authorize the transfer
18 | function onTransfer(address _from, address _to, uint _amount) public returns(bool);
19 |
20 | /// @notice Notifies the controller about an approval allowing the
21 | /// controller to react if desired
22 | /// @param _owner The address that calls `approve()`
23 | /// @param _spender The spender in the `approve()` call
24 | /// @param _amount The amount in the `approve()` call
25 | /// @return False if the controller does not authorize the approval
26 | function onApprove(address _owner, address _spender, uint _amount) public
27 | returns(bool);
28 | }
29 |
--------------------------------------------------------------------------------
/contracts/Controlled.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.18;
2 |
3 | contract Controlled {
4 | /// @notice The address of the controller is the only address that can call
5 | /// a function with this modifier
6 | modifier onlyController { require(msg.sender == controller); _; }
7 |
8 | address public controller;
9 |
10 | function Controlled() public { controller = msg.sender;}
11 |
12 | /// @notice Changes the controller of the contract
13 | /// @param _newController The new controller of the contract
14 | function changeController(address _newController) public onlyController {
15 | controller = _newController;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/contracts/MiniMeToken.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.18;
2 |
3 | /*
4 | Copyright 2016, Jordi Baylina
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | /// @title MiniMeToken Contract
21 | /// @author Jordi Baylina
22 | /// @dev This token contract's goal is to make it easy for anyone to clone this
23 | /// token using the token distribution at a given block, this will allow DAO's
24 | /// and DApps to upgrade their features in a decentralized manner without
25 | /// affecting the original token
26 | /// @dev It is ERC20 compliant, but still needs to under go further testing.
27 |
28 | import "./Controlled.sol";
29 | import "./TokenController.sol";
30 |
31 | contract ApproveAndCallFallBack {
32 | function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public;
33 | }
34 |
35 | /// @dev The actual token contract, the default controller is the msg.sender
36 | /// that deploys the contract, so usually this token will be deployed by a
37 | /// token controller contract, which Giveth will call a "Campaign"
38 | contract MiniMeToken is Controlled {
39 |
40 | string public name; //The Token's name: e.g. DigixDAO Tokens
41 | uint8 public decimals; //Number of decimals of the smallest unit
42 | string public symbol; //An identifier: e.g. REP
43 | string public version = 'MMT_0.2'; //An arbitrary versioning scheme
44 |
45 |
46 | /// @dev `Checkpoint` is the structure that attaches a block number to a
47 | /// given value, the block number attached is the one that last changed the
48 | /// value
49 | struct Checkpoint {
50 |
51 | // `fromBlock` is the block number that the value was generated from
52 | uint128 fromBlock;
53 |
54 | // `value` is the amount of tokens at a specific block number
55 | uint128 value;
56 | }
57 |
58 | // `parentToken` is the Token address that was cloned to produce this token;
59 | // it will be 0x0 for a token that was not cloned
60 | MiniMeToken public parentToken;
61 |
62 | // `parentSnapShotBlock` is the block number from the Parent Token that was
63 | // used to determine the initial distribution of the Clone Token
64 | uint public parentSnapShotBlock;
65 |
66 | // `creationBlock` is the block number that the Clone Token was created
67 | uint public creationBlock;
68 |
69 | // `balances` is the map that tracks the balance of each address, in this
70 | // contract when the balance changes the block number that the change
71 | // occurred is also included in the map
72 | mapping (address => Checkpoint[]) balances;
73 |
74 | // `allowed` tracks any extra transfer rights as in all ERC20 tokens
75 | mapping (address => mapping (address => uint256)) allowed;
76 |
77 | // Tracks the history of the `totalSupply` of the token
78 | Checkpoint[] totalSupplyHistory;
79 |
80 | // Flag that determines if the token is transferable or not.
81 | bool public transfersEnabled;
82 |
83 | // The factory used to create new clone tokens
84 | MiniMeTokenFactory public tokenFactory;
85 |
86 | ////////////////
87 | // Constructor
88 | ////////////////
89 |
90 | /// @notice Constructor to create a MiniMeToken
91 | /// @param _tokenFactory The address of the MiniMeTokenFactory contract that
92 | /// will create the Clone token contracts, the token factory needs to be
93 | /// deployed first
94 | /// @param _parentToken Address of the parent token, set to 0x0 if it is a
95 | /// new token
96 | /// @param _parentSnapShotBlock Block of the parent token that will
97 | /// determine the initial distribution of the clone token, set to 0 if it
98 | /// is a new token
99 | /// @param _tokenName Name of the new token
100 | /// @param _decimalUnits Number of decimals of the new token
101 | /// @param _tokenSymbol Token Symbol for the new token
102 | /// @param _transfersEnabled If true, tokens will be able to be transferred
103 | function MiniMeToken(
104 | address _tokenFactory,
105 | address _parentToken,
106 | uint _parentSnapShotBlock,
107 | string _tokenName,
108 | uint8 _decimalUnits,
109 | string _tokenSymbol,
110 | bool _transfersEnabled
111 | ) public {
112 | tokenFactory = MiniMeTokenFactory(_tokenFactory);
113 | name = _tokenName; // Set the name
114 | decimals = _decimalUnits; // Set the decimals
115 | symbol = _tokenSymbol; // Set the symbol
116 | parentToken = MiniMeToken(_parentToken);
117 | parentSnapShotBlock = _parentSnapShotBlock;
118 | transfersEnabled = _transfersEnabled;
119 | creationBlock = block.number;
120 | }
121 |
122 |
123 | ///////////////////
124 | // ERC20 Methods
125 | ///////////////////
126 |
127 | /// @notice Send `_amount` tokens to `_to` from `msg.sender`
128 | /// @param _to The address of the recipient
129 | /// @param _amount The amount of tokens to be transferred
130 | /// @return Whether the transfer was successful or not
131 | function transfer(address _to, uint256 _amount) public returns (bool success) {
132 | require(transfersEnabled);
133 | doTransfer(msg.sender, _to, _amount);
134 | return true;
135 | }
136 |
137 | /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
138 | /// is approved by `_from`
139 | /// @param _from The address holding the tokens being transferred
140 | /// @param _to The address of the recipient
141 | /// @param _amount The amount of tokens to be transferred
142 | /// @return True if the transfer was successful
143 | function transferFrom(address _from, address _to, uint256 _amount
144 | ) public returns (bool success) {
145 |
146 | // The controller of this contract can move tokens around at will,
147 | // this is important to recognize! Confirm that you trust the
148 | // controller of this contract, which in most situations should be
149 | // another open source smart contract or 0x0
150 | if (msg.sender != controller) {
151 | require(transfersEnabled);
152 |
153 | // The standard ERC 20 transferFrom functionality
154 | require(allowed[_from][msg.sender] >= _amount);
155 | allowed[_from][msg.sender] -= _amount;
156 | }
157 | doTransfer(_from, _to, _amount);
158 | return true;
159 | }
160 |
161 | /// @dev This is the actual transfer function in the token contract, it can
162 | /// only be called by other functions in this contract.
163 | /// @param _from The address holding the tokens being transferred
164 | /// @param _to The address of the recipient
165 | /// @param _amount The amount of tokens to be transferred
166 | /// @return True if the transfer was successful
167 | function doTransfer(address _from, address _to, uint _amount
168 | ) internal {
169 |
170 | if (_amount == 0) {
171 | Transfer(_from, _to, _amount); // Follow the spec to louch the event when transfer 0
172 | return;
173 | }
174 |
175 | require(parentSnapShotBlock < block.number);
176 |
177 | // Do not allow transfer to 0x0 or the token contract itself
178 | require((_to != 0) && (_to != address(this)));
179 |
180 | // If the amount being transfered is more than the balance of the
181 | // account the transfer throws
182 | var previousBalanceFrom = balanceOfAt(_from, block.number);
183 |
184 | require(previousBalanceFrom >= _amount);
185 |
186 | // Alerts the token controller of the transfer
187 | if (isContract(controller)) {
188 | require(TokenController(controller).onTransfer(_from, _to, _amount));
189 | }
190 |
191 | // First update the balance array with the new value for the address
192 | // sending the tokens
193 | updateValueAtNow(balances[_from], previousBalanceFrom - _amount);
194 |
195 | // Then update the balance array with the new value for the address
196 | // receiving the tokens
197 | var previousBalanceTo = balanceOfAt(_to, block.number);
198 | require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
199 | updateValueAtNow(balances[_to], previousBalanceTo + _amount);
200 |
201 | // An event to make the transfer easy to find on the blockchain
202 | Transfer(_from, _to, _amount);
203 |
204 | }
205 |
206 | /// @param _owner The address that's balance is being requested
207 | /// @return The balance of `_owner` at the current block
208 | function balanceOf(address _owner) public constant returns (uint256 balance) {
209 | return balanceOfAt(_owner, block.number);
210 | }
211 |
212 | /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
213 | /// its behalf. This is a modified version of the ERC20 approve function
214 | /// to be a little bit safer
215 | /// @param _spender The address of the account able to transfer the tokens
216 | /// @param _amount The amount of tokens to be approved for transfer
217 | /// @return True if the approval was successful
218 | function approve(address _spender, uint256 _amount) public returns (bool success) {
219 | require(transfersEnabled);
220 |
221 | // To change the approve amount you first have to reduce the addresses`
222 | // allowance to zero by calling `approve(_spender,0)` if it is not
223 | // already 0 to mitigate the race condition described here:
224 | // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
225 | require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
226 |
227 | // Alerts the token controller of the approve function call
228 | if (isContract(controller)) {
229 | require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
230 | }
231 |
232 | allowed[msg.sender][_spender] = _amount;
233 | Approval(msg.sender, _spender, _amount);
234 | return true;
235 | }
236 |
237 | /// @dev This function makes it easy to read the `allowed[]` map
238 | /// @param _owner The address of the account that owns the token
239 | /// @param _spender The address of the account able to transfer the tokens
240 | /// @return Amount of remaining tokens of _owner that _spender is allowed
241 | /// to spend
242 | function allowance(address _owner, address _spender
243 | ) public constant returns (uint256 remaining) {
244 | return allowed[_owner][_spender];
245 | }
246 |
247 | /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
248 | /// its behalf, and then a function is triggered in the contract that is
249 | /// being approved, `_spender`. This allows users to use their tokens to
250 | /// interact with contracts in one function call instead of two
251 | /// @param _spender The address of the contract able to transfer the tokens
252 | /// @param _amount The amount of tokens to be approved for transfer
253 | /// @return True if the function call was successful
254 | function approveAndCall(address _spender, uint256 _amount, bytes _extraData
255 | ) public returns (bool success) {
256 | require(approve(_spender, _amount));
257 |
258 | ApproveAndCallFallBack(_spender).receiveApproval(
259 | msg.sender,
260 | _amount,
261 | this,
262 | _extraData
263 | );
264 |
265 | return true;
266 | }
267 |
268 | /// @dev This function makes it easy to get the total number of tokens
269 | /// @return The total number of tokens
270 | function totalSupply() public constant returns (uint) {
271 | return totalSupplyAt(block.number);
272 | }
273 |
274 |
275 | ////////////////
276 | // Query balance and totalSupply in History
277 | ////////////////
278 |
279 | /// @dev Queries the balance of `_owner` at a specific `_blockNumber`
280 | /// @param _owner The address from which the balance will be retrieved
281 | /// @param _blockNumber The block number when the balance is queried
282 | /// @return The balance at `_blockNumber`
283 | function balanceOfAt(address _owner, uint _blockNumber) public constant
284 | returns (uint) {
285 |
286 | // These next few lines are used when the balance of the token is
287 | // requested before a check point was ever created for this token, it
288 | // requires that the `parentToken.balanceOfAt` be queried at the
289 | // genesis block for that token as this contains initial balance of
290 | // this token
291 | if ((balances[_owner].length == 0)
292 | || (balances[_owner][0].fromBlock > _blockNumber)) {
293 | if (address(parentToken) != 0) {
294 | return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
295 | } else {
296 | // Has no parent
297 | return 0;
298 | }
299 |
300 | // This will return the expected balance during normal situations
301 | } else {
302 | return getValueAt(balances[_owner], _blockNumber);
303 | }
304 | }
305 |
306 | /// @notice Total amount of tokens at a specific `_blockNumber`.
307 | /// @param _blockNumber The block number when the totalSupply is queried
308 | /// @return The total amount of tokens at `_blockNumber`
309 | function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
310 |
311 | // These next few lines are used when the totalSupply of the token is
312 | // requested before a check point was ever created for this token, it
313 | // requires that the `parentToken.totalSupplyAt` be queried at the
314 | // genesis block for this token as that contains totalSupply of this
315 | // token at this block number.
316 | if ((totalSupplyHistory.length == 0)
317 | || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
318 | if (address(parentToken) != 0) {
319 | return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
320 | } else {
321 | return 0;
322 | }
323 |
324 | // This will return the expected totalSupply during normal situations
325 | } else {
326 | return getValueAt(totalSupplyHistory, _blockNumber);
327 | }
328 | }
329 |
330 | ////////////////
331 | // Clone Token Method
332 | ////////////////
333 |
334 | /// @notice Creates a new clone token with the initial distribution being
335 | /// this token at `_snapshotBlock`
336 | /// @param _cloneTokenName Name of the clone token
337 | /// @param _cloneDecimalUnits Number of decimals of the smallest unit
338 | /// @param _cloneTokenSymbol Symbol of the clone token
339 | /// @param _snapshotBlock Block when the distribution of the parent token is
340 | /// copied to set the initial distribution of the new clone token;
341 | /// if the block is zero than the actual block, the current block is used
342 | /// @param _transfersEnabled True if transfers are allowed in the clone
343 | /// @return The address of the new MiniMeToken Contract
344 | function createCloneToken(
345 | string _cloneTokenName,
346 | uint8 _cloneDecimalUnits,
347 | string _cloneTokenSymbol,
348 | uint _snapshotBlock,
349 | bool _transfersEnabled
350 | ) public returns(address) {
351 | if (_snapshotBlock == 0) _snapshotBlock = block.number;
352 | MiniMeToken cloneToken = tokenFactory.createCloneToken(
353 | this,
354 | _snapshotBlock,
355 | _cloneTokenName,
356 | _cloneDecimalUnits,
357 | _cloneTokenSymbol,
358 | _transfersEnabled
359 | );
360 |
361 | cloneToken.changeController(msg.sender);
362 |
363 | // An event to make the token easy to find on the blockchain
364 | NewCloneToken(address(cloneToken), _snapshotBlock);
365 | return address(cloneToken);
366 | }
367 |
368 | ////////////////
369 | // Generate and destroy tokens
370 | ////////////////
371 |
372 | /// @notice Generates `_amount` tokens that are assigned to `_owner`
373 | /// @param _owner The address that will be assigned the new tokens
374 | /// @param _amount The quantity of tokens generated
375 | /// @return True if the tokens are generated correctly
376 | function generateTokens(address _owner, uint _amount
377 | ) public onlyController returns (bool) {
378 | uint curTotalSupply = totalSupply();
379 | require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
380 | uint previousBalanceTo = balanceOf(_owner);
381 | require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
382 | updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
383 | updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
384 | Transfer(0, _owner, _amount);
385 | return true;
386 | }
387 |
388 |
389 | /// @notice Burns `_amount` tokens from `_owner`
390 | /// @param _owner The address that will lose the tokens
391 | /// @param _amount The quantity of tokens to burn
392 | /// @return True if the tokens are burned correctly
393 | function destroyTokens(address _owner, uint _amount
394 | ) onlyController public returns (bool) {
395 | uint curTotalSupply = totalSupply();
396 | require(curTotalSupply >= _amount);
397 | uint previousBalanceFrom = balanceOf(_owner);
398 | require(previousBalanceFrom >= _amount);
399 | updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
400 | updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
401 | Transfer(_owner, 0, _amount);
402 | return true;
403 | }
404 |
405 | ////////////////
406 | // Enable tokens transfers
407 | ////////////////
408 |
409 |
410 | /// @notice Enables token holders to transfer their tokens freely if true
411 | /// @param _transfersEnabled True if transfers are allowed in the clone
412 | function enableTransfers(bool _transfersEnabled) public onlyController {
413 | transfersEnabled = _transfersEnabled;
414 | }
415 |
416 | ////////////////
417 | // Internal helper functions to query and set a value in a snapshot array
418 | ////////////////
419 |
420 | /// @dev `getValueAt` retrieves the number of tokens at a given block number
421 | /// @param checkpoints The history of values being queried
422 | /// @param _block The block number to retrieve the value at
423 | /// @return The number of tokens being queried
424 | function getValueAt(Checkpoint[] storage checkpoints, uint _block
425 | ) constant internal returns (uint) {
426 | if (checkpoints.length == 0) return 0;
427 |
428 | // Shortcut for the actual value
429 | if (_block >= checkpoints[checkpoints.length-1].fromBlock)
430 | return checkpoints[checkpoints.length-1].value;
431 | if (_block < checkpoints[0].fromBlock) return 0;
432 |
433 | // Binary search of the value in the array
434 | uint min = 0;
435 | uint max = checkpoints.length-1;
436 | while (max > min) {
437 | uint mid = (max + min + 1)/ 2;
438 | if (checkpoints[mid].fromBlock<=_block) {
439 | min = mid;
440 | } else {
441 | max = mid-1;
442 | }
443 | }
444 | return checkpoints[min].value;
445 | }
446 |
447 | /// @dev `updateValueAtNow` used to update the `balances` map and the
448 | /// `totalSupplyHistory`
449 | /// @param checkpoints The history of data being updated
450 | /// @param _value The new number of tokens
451 | function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
452 | ) internal {
453 | if ((checkpoints.length == 0)
454 | || (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
455 | Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ];
456 | newCheckPoint.fromBlock = uint128(block.number);
457 | newCheckPoint.value = uint128(_value);
458 | } else {
459 | Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
460 | oldCheckPoint.value = uint128(_value);
461 | }
462 | }
463 |
464 | /// @dev Internal function to determine if an address is a contract
465 | /// @param _addr The address being queried
466 | /// @return True if `_addr` is a contract
467 | function isContract(address _addr) constant internal returns(bool) {
468 | uint size;
469 | if (_addr == 0) return false;
470 | assembly {
471 | size := extcodesize(_addr)
472 | }
473 | return size>0;
474 | }
475 |
476 | /// @dev Helper function to return a min betwen the two uints
477 | function min(uint a, uint b) pure internal returns (uint) {
478 | return a < b ? a : b;
479 | }
480 |
481 | /// @notice The fallback function: If the contract's controller has not been
482 | /// set to 0, then the `proxyPayment` method is called which relays the
483 | /// ether and creates tokens as described in the token controller contract
484 | function () public payable {
485 | require(isContract(controller));
486 | require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
487 | }
488 |
489 | //////////
490 | // Safety Methods
491 | //////////
492 |
493 | /// @notice This method can be used by the controller to extract mistakenly
494 | /// sent tokens to this contract.
495 | /// @param _token The address of the token contract that you want to recover
496 | /// set to 0 in case you want to extract ether.
497 | function claimTokens(address _token) public onlyController {
498 | if (_token == 0x0) {
499 | controller.transfer(this.balance);
500 | return;
501 | }
502 |
503 | MiniMeToken token = MiniMeToken(_token);
504 | uint balance = token.balanceOf(this);
505 | token.transfer(controller, balance);
506 | ClaimedTokens(_token, controller, balance);
507 | }
508 |
509 | ////////////////
510 | // Events
511 | ////////////////
512 | event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
513 | event Transfer(address indexed _from, address indexed _to, uint256 _amount);
514 | event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
515 | event Approval(
516 | address indexed _owner,
517 | address indexed _spender,
518 | uint256 _amount
519 | );
520 |
521 | }
522 |
523 |
524 | ////////////////
525 | // MiniMeTokenFactory
526 | ////////////////
527 |
528 | /// @dev This contract is used to generate clone contracts from a contract.
529 | /// In solidity this is the way to create a contract from a contract of the
530 | /// same class
531 | contract MiniMeTokenFactory {
532 |
533 | /// @notice Update the DApp by creating a new token with new functionalities
534 | /// the msg.sender becomes the controller of this clone token
535 | /// @param _parentToken Address of the token being cloned
536 | /// @param _snapshotBlock Block of the parent token that will
537 | /// determine the initial distribution of the clone token
538 | /// @param _tokenName Name of the new token
539 | /// @param _decimalUnits Number of decimals of the new token
540 | /// @param _tokenSymbol Token Symbol for the new token
541 | /// @param _transfersEnabled If true, tokens will be able to be transferred
542 | /// @return The address of the new token contract
543 | function createCloneToken(
544 | address _parentToken,
545 | uint _snapshotBlock,
546 | string _tokenName,
547 | uint8 _decimalUnits,
548 | string _tokenSymbol,
549 | bool _transfersEnabled
550 | ) public returns (MiniMeToken) {
551 | MiniMeToken newToken = new MiniMeToken(
552 | this,
553 | _parentToken,
554 | _snapshotBlock,
555 | _tokenName,
556 | _decimalUnits,
557 | _tokenSymbol,
558 | _transfersEnabled
559 | );
560 |
561 | newToken.changeController(msg.sender);
562 | return newToken;
563 | }
564 | }
565 |
--------------------------------------------------------------------------------
/contracts/SampleCampaign-TokenController.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.6;
2 |
3 | /*
4 | Copyright 2017, Jordi Baylina
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program. If not, see .
18 | */
19 |
20 | /// @title MilestoneTracker Contract
21 | /// @author Jordi Baylina
22 | /// @dev This contract controls the issuance of tokens for the MiniMe Token
23 | /// Contract. This version specifically acts as a Campaign manager for raising
24 | /// funds for non-profit causes, but it can be customized for any variety of
25 | /// purposes.
26 |
27 | import "MiniMeToken.sol";
28 |
29 |
30 | /// @dev `Owned` is a base level contract that assigns an `owner` that can be
31 | /// later changed
32 | contract Owned {
33 | /// @dev `owner` is the only address that can call a function with this
34 | /// modifier
35 | modifier onlyOwner { require (msg.sender == owner); _; }
36 |
37 | address public owner;
38 |
39 | /// @notice The Constructor assigns the message sender to be `owner`
40 | function Owned() { owner = msg.sender;}
41 |
42 | /// @notice `owner` can step down and assign some other address to this role
43 | /// @param _newOwner The address of the new owner. 0x0 can be used to create
44 | /// an unowned neutral vault, however that cannot be undone
45 | function changeOwner(address _newOwner) onlyOwner {
46 | owner = _newOwner;
47 | }
48 | }
49 |
50 |
51 | /// @dev This is designed to control the issuance of a MiniMe Token for a
52 | /// non-profit Campaign. This contract effectively dictates the terms of the
53 | /// funding round.
54 |
55 | contract Campaign is TokenController, Owned {
56 |
57 | uint public startFundingTime; // In UNIX Time Format
58 | uint public endFundingTime; // In UNIX Time Format
59 | uint public maximumFunding; // In wei
60 | uint public totalCollected; // In wei
61 | MiniMeToken public tokenContract; // The new token for this Campaign
62 | address public vaultAddress; // The address to hold the funds donated
63 |
64 | /// @notice 'Campaign()' initiates the Campaign by setting its funding
65 | /// parameters
66 | /// @dev There are several checks to make sure the parameters are acceptable
67 | /// @param _startFundingTime The UNIX time that the Campaign will be able to
68 | /// start receiving funds
69 | /// @param _endFundingTime The UNIX time that the Campaign will stop being able
70 | /// to receive funds
71 | /// @param _maximumFunding In wei, the Maximum amount that the Campaign can
72 | /// receive (currently the max is set at 10,000 ETH for the beta)
73 | /// @param _vaultAddress The address that will store the donated funds
74 | /// @param _tokenAddress Address of the token contract this contract controls
75 |
76 | function Campaign(
77 | uint _startFundingTime,
78 | uint _endFundingTime,
79 | uint _maximumFunding,
80 | address _vaultAddress,
81 | address _tokenAddress
82 |
83 | ) {
84 | require ((_endFundingTime >= now) && // Cannot end in the past
85 | (_endFundingTime > _startFundingTime) &&
86 | (_maximumFunding <= 10000 ether) && // The Beta is limited
87 | (_vaultAddress != 0)); // To prevent burning ETH
88 | startFundingTime = _startFundingTime;
89 | endFundingTime = _endFundingTime;
90 | maximumFunding = _maximumFunding;
91 | tokenContract = MiniMeToken(_tokenAddress);// The Deployed Token Contract
92 | vaultAddress = _vaultAddress;
93 | }
94 |
95 | /// @dev The fallback function is called when ether is sent to the contract, it
96 | /// simply calls `doPayment()` with the address that sent the ether as the
97 | /// `_owner`. Payable is a required solidity modifier for functions to receive
98 | /// ether, without this modifier functions will throw if ether is sent to them
99 |
100 | function () payable {
101 | doPayment(msg.sender);
102 | }
103 |
104 | /////////////////
105 | // TokenController interface
106 | /////////////////
107 |
108 | /// @notice `proxyPayment()` allows the caller to send ether to the Campaign and
109 | /// have the tokens created in an address of their choosing
110 | /// @param _owner The address that will hold the newly created tokens
111 |
112 | function proxyPayment(address _owner) payable returns(bool) {
113 | doPayment(_owner);
114 | return true;
115 | }
116 |
117 | /// @notice Notifies the controller about a transfer, for this Campaign all
118 | /// transfers are allowed by default and no extra notifications are needed
119 | /// @param _from The origin of the transfer
120 | /// @param _to The destination of the transfer
121 | /// @param _amount The amount of the transfer
122 | /// @return False if the controller does not authorize the transfer
123 | function onTransfer(address _from, address _to, uint _amount) returns(bool) {
124 | return true;
125 | }
126 |
127 | /// @notice Notifies the controller about an approval, for this Campaign all
128 | /// approvals are allowed by default and no extra notifications are needed
129 | /// @param _owner The address that calls `approve()`
130 | /// @param _spender The spender in the `approve()` call
131 | /// @param _amount The amount in the `approve()` call
132 | /// @return False if the controller does not authorize the approval
133 | function onApprove(address _owner, address _spender, uint _amount)
134 | returns(bool)
135 | {
136 | return true;
137 | }
138 |
139 |
140 | /// @dev `doPayment()` is an internal function that sends the ether that this
141 | /// contract receives to the `vault` and creates tokens in the address of the
142 | /// `_owner` assuming the Campaign is still accepting funds
143 | /// @param _owner The address that will hold the newly created tokens
144 |
145 | function doPayment(address _owner) internal {
146 |
147 | // First check that the Campaign is allowed to receive this donation
148 | require ((now >= startFundingTime) &&
149 | (now <= endFundingTime) &&
150 | (tokenContract.controller() != 0) && // Extra check
151 | (msg.value != 0) &&
152 | (totalCollected + msg.value <= maximumFunding));
153 |
154 | //Track how much the Campaign has collected
155 | totalCollected += msg.value;
156 |
157 | //Send the ether to the vault
158 | require (vaultAddress.send(msg.value));
159 |
160 | // Creates an equal amount of tokens as ether sent. The new tokens are created
161 | // in the `_owner` address
162 | require (tokenContract.generateTokens(_owner, msg.value));
163 |
164 | return;
165 | }
166 |
167 | /// @notice `finalizeFunding()` ends the Campaign by calling setting the
168 | /// controller to 0, thereby ending the issuance of new tokens and stopping the
169 | /// Campaign from receiving more ether
170 | /// @dev `finalizeFunding()` can only be called after the end of the funding period.
171 |
172 | function finalizeFunding() {
173 | require(now >= endFundingTime);
174 | tokenContract.changeController(0);
175 | }
176 |
177 |
178 | /// @notice `onlyOwner` changes the location that ether is sent
179 | /// @param _newVaultAddress The address that will receive the ether sent to this
180 | /// Campaign
181 | function setVault(address _newVaultAddress) onlyOwner {
182 | vaultAddress = _newVaultAddress;
183 | }
184 |
185 | }
186 |
--------------------------------------------------------------------------------
/contracts/TokenController.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.18;
2 |
3 | /// @dev The token controller contract must implement these functions
4 | contract TokenController {
5 | /// @notice Called when `_owner` sends ether to the MiniMe Token contract
6 | /// @param _owner The address that sent the ether to create tokens
7 | /// @return True if the ether is accepted, false if it throws
8 | function proxyPayment(address _owner) public payable returns(bool);
9 |
10 | /// @notice Notifies the controller about a token transfer allowing the
11 | /// controller to react if desired
12 | /// @param _from The origin of the transfer
13 | /// @param _to The destination of the transfer
14 | /// @param _amount The amount of the transfer
15 | /// @return False if the controller does not authorize the transfer
16 | function onTransfer(address _from, address _to, uint _amount) public returns(bool);
17 |
18 | /// @notice Notifies the controller about an approval allowing the
19 | /// controller to react if desired
20 | /// @param _owner The address that calls `approve()`
21 | /// @param _spender The spender in the `approve()` call
22 | /// @param _amount The amount in the `approve()` call
23 | /// @return False if the controller does not authorize the approval
24 | function onApprove(address _owner, address _spender, uint _amount) public
25 | returns(bool);
26 | }
27 |
--------------------------------------------------------------------------------
/env.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var Web3 = require('web3');
4 | // create an instance of web3 using the HTTP provider.
5 | // NOTE in mist web3 is already available, so check first if its available before instantiating
6 | var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
7 |
8 | var BigNumber = require('bignumber.js');
9 |
10 | var eth = web3.eth;
11 | var async = require('async');
12 |
13 | var MiniMeToken = require('./dist/minimetoken.js');
14 |
15 | var gcb = function(err, res) {
16 | if (err) {
17 | console.log("ERROR: "+err);
18 | } else {
19 | console.log(JSON.stringify(res,null,2));
20 | }
21 | }
22 |
23 | var minimeToken;
24 |
25 | function deployExample(cb) {
26 | cb = cb || gcb;
27 | async.series([
28 | function(cb) {
29 | MiniMeToken.deploy(web3, {
30 | tokenName: "MiniMe Test Token",
31 | decimalUnits: 18,
32 | tokenSymbol: "MMT",
33 | }, function(err, _minimeToken) {
34 | if (err) return err;
35 | minimeToken = _minimeToken;
36 | console.log("Minime Token: " + minimeToken.contract.address);
37 | cb();
38 | });
39 | },
40 | function(cb) {
41 | minimeToken.generateTokens({
42 | owner: eth.accounts[ 1 ],
43 | amount: 10,
44 | from: eth.accounts[ 0 ],
45 | },cb);
46 | },
47 | ], cb);
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/funding.json:
--------------------------------------------------------------------------------
1 | {
2 | "opRetro": {
3 | "projectId": "0xe434930e189c807b137ff0d8e2fa6a95eaa57dde574143a02ca0d7fb31a40bea"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | exports.MiniMeToken = require('./js/minimetoken');
2 | exports.MiniMeTokenFactory = require('./js/minimetokenfactory');
3 | exports.MiniMeTokenState = require('./js/minimetokenstate');
4 |
--------------------------------------------------------------------------------
/js/compile.js:
--------------------------------------------------------------------------------
1 | const ethConnector = require("ethconnector");
2 | const path = require("path");
3 |
4 | ethConnector.compile(
5 | path.join(__dirname, "../contracts/MiniMeToken.sol"),
6 | path.join(__dirname, "../contracts/MiniMeToken.sol.js"),
7 | (err) => {
8 | if (err) {
9 | console.log(err);
10 | process.exit(1);
11 | } else {
12 | process.exit(0);
13 | }
14 | });
15 |
--------------------------------------------------------------------------------
/js/minimetoken.js:
--------------------------------------------------------------------------------
1 | const MiniMeTokenAbi = require('../build/MiniMeToken.sol').MiniMeTokenAbi;
2 | const MiniMeTokenByteCode = require('../build/MiniMeToken.sol').MiniMeTokenByteCode;
3 | const generateClass = require('eth-contract-class').default;
4 |
5 | module.exports = generateClass(MiniMeTokenAbi, MiniMeTokenByteCode);
6 |
--------------------------------------------------------------------------------
/js/minimetokenfactory.js:
--------------------------------------------------------------------------------
1 | const MiniMeTokenFactoryAbi = require('../build/MiniMeToken.sol').MiniMeTokenFactoryAbi;
2 | const MiniMeTokenFactoryByteCode = require('../build/MiniMeToken.sol').MiniMeTokenFactoryByteCode;
3 | const generateClass = require('eth-contract-class').default;
4 |
5 | module.exports = generateClass(MiniMeTokenFactoryAbi, MiniMeTokenFactoryByteCode);
6 |
--------------------------------------------------------------------------------
/js/minimetokenstate.js:
--------------------------------------------------------------------------------
1 | class MiniMeTokenState {
2 | constructor(minimeToken) {
3 | this.$token = minimeToken;
4 | }
5 |
6 | async getState() {
7 | const st = {
8 | balances: {},
9 | };
10 |
11 | const res = await Promise.all([
12 | this.$token.name(),
13 | this.$token.decimals(),
14 | this.$token.controller(),
15 | this.$token.totalSupply(),
16 | this.$token.parentToken(),
17 | this.$token.controller(),
18 | this.$token.parentSnapShotBlock(),
19 | this.$token.$web3.eth.getAccounts(),
20 | ]);
21 |
22 | st.name = res[0];
23 | st.decimals = res[1];
24 | st.controller = res[2];
25 | st.totalSupply = res[3];
26 | st.parentToken = res[4];
27 | st.controller = res[5];
28 | st.parentSnapShotBlock = res[6];
29 | const accounts = res[7];
30 |
31 | const calls = accounts.map(account => this.$token.balanceOf(account));
32 |
33 | const balances = await Promise.all(calls);
34 |
35 | for (let i = 0; i < accounts.length; i += 1) {
36 | st.balances[accounts[i]] = balances[i];
37 | }
38 |
39 | return st;
40 | }
41 | }
42 |
43 | module.exports = MiniMeTokenState;
44 |
45 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "minimetoken",
3 | "version": "0.2.0",
4 | "description": "MiniMe contract",
5 | "main": "dist/minimetoken.js",
6 | "directories": {
7 | "test": "test"
8 | },
9 | "scripts": {
10 | "build": "solcpiler",
11 | "test": "solcpiler; mocha --harmony"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "https://github.com/Giveth/minime.git"
16 | },
17 | "keywords": [
18 | "dao",
19 | "solidity",
20 | "token",
21 | "charity",
22 | "smart",
23 | "contract",
24 | "minime",
25 | "giveth",
26 | "ethereum"
27 | ],
28 | "author": "Jordi Baylina",
29 | "license": "GPL-3.0",
30 | "bugs": {
31 | "url": "https://github.com/Giveth/minimi/issues"
32 | },
33 | "homepage": "https://github.com/Giveth/minime",
34 | "dependencies": {
35 | "eth-contract-class": "0.0.6"
36 | },
37 | "devDependencies": {
38 | "babel-eslint": "^7.2.3",
39 | "eslint-config-airbnb": "^15.0.1",
40 | "eslint-plugin-import": "^2.6.0",
41 | "eslint-plugin-jsx-a11y": "^6.0.2",
42 | "eslint-plugin-react": "^7.1.0",
43 | "ethereumjs-testrpc": "git://github.com/perissology/testrpc.git#81216dbc",
44 | "lerna": "^2.2.0",
45 | "random-bytes": "^1.0.0",
46 | "mocha": "^3.5.0",
47 | "solcpiler": "0.0.6",
48 | "web3": "git://github.com/perissology/web3.js.git#all_fixes",
49 | "chai": "^4.1.0"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/readme-header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Giveth/minime/8e28ddcce80537a64ef511bed9d4a4394456f245/readme-header.png
--------------------------------------------------------------------------------
/test/minimetoken_normal.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | /* eslint-disable no-await-in-loop */
3 | const TestRPC = require('ethereumjs-testrpc');
4 | const Web3 = require('web3');
5 | const chai = require('chai');
6 |
7 | const MiniMeToken = require('../index.js').MiniMeToken;
8 | const MiniMeTokenFactory = require('../index.js').MiniMeTokenFactory;
9 | const MiniMeTokenState = require('../index.js').MiniMeTokenState;
10 |
11 | const assert = chai.assert;
12 | const { utils } = Web3;
13 |
14 | const verbose = false;
15 |
16 | const log = (S) => {
17 | if (verbose) {
18 | console.log(S);
19 | }
20 | };
21 |
22 | // b[0] -> 0, 0, 0, 0
23 | // b[1] -> 0,10, 0, 0
24 | // b[2] -> 0, 8, 2, 0
25 | // b[3] -> 0, 9, 1, 0
26 | // b[4] -> 0, 6, 1, 0
27 | // Clone token
28 | // b[5] -> 0, 6, 1, 0
29 | // b[6] -> 0, 2, 5. 0
30 |
31 | describe('MiniMeToken test', () => {
32 | let testrpc;
33 | let web3;
34 | let accounts;
35 | let miniMeToken;
36 | let miniMeTokenState;
37 | let miniMeTokenClone;
38 | let miniMeTokenCloneState;
39 | const b = [];
40 |
41 | before(async () => {
42 | testrpc = TestRPC.server({
43 | ws: true,
44 | gasLimit: 5800000,
45 | total_accounts: 10,
46 | });
47 |
48 | testrpc.listen(8546, '127.0.0.1');
49 |
50 | web3 = new Web3('ws://localhost:8546');
51 | accounts = await web3.eth.getAccounts();
52 | });
53 |
54 | after((done) => {
55 | testrpc.close();
56 | done();
57 | });
58 |
59 | it('should deploy all the contracts', async () => {
60 | const tokenFactory = await MiniMeTokenFactory.new(web3);
61 | miniMeToken = await MiniMeToken.new(web3,
62 | tokenFactory.$address,
63 | 0,
64 | 0,
65 | 'MiniMe Test Token',
66 | 18,
67 | 'MMT',
68 | true);
69 | assert.ok(miniMeToken.$address);
70 | miniMeTokenState = new MiniMeTokenState(miniMeToken);
71 | }).timeout(20000);
72 |
73 | it('Should generate tokens for address 1', async () => {
74 | b[0] = await web3.eth.getBlockNumber();
75 | log(`b[0]-> ${b[0]}`);
76 |
77 | await miniMeToken.generateTokens(accounts[1], 10);
78 | const st = await miniMeTokenState.getState();
79 | assert.equal(st.totalSupply, 10);
80 | assert.equal(st.balances[accounts[1]], 10);
81 | b[1] = await web3.eth.getBlockNumber();
82 | }).timeout(6000);
83 |
84 | it('Should transfer tokens from address 1 to address 2', async () => {
85 | await miniMeToken.transfer(accounts[2], 2, { from: accounts[1], gas: 200000 });
86 | b[2] = await web3.eth.getBlockNumber();
87 | log(`b[2]-> ${b[3]}`);
88 | const st = await miniMeTokenState.getState();
89 | assert.equal(st.totalSupply, 10);
90 | assert.equal(st.balances[accounts[1]], 8);
91 | assert.equal(st.balances[accounts[2]], 2);
92 |
93 | const balance = await miniMeToken.balanceOfAt(accounts[1], b[1]);
94 | assert.equal(balance, 10);
95 | }).timeout(6000);
96 |
97 | it('Should allow and transfer tokens from address 2 to address 1 allowed to 3', async () => {
98 | await miniMeToken.approve(accounts[3], 2, { from: accounts[2] });
99 | const allowed = await miniMeToken.allowance(accounts[2], accounts[3]);
100 | assert.equal(allowed, 2);
101 |
102 | await miniMeToken.transferFrom(accounts[2], accounts[1], 1, { from: accounts[3] });
103 |
104 | const allowed2 = await miniMeToken.allowance(accounts[2], accounts[3]);
105 | assert.equal(allowed2, 1);
106 |
107 | b[3] = await web3.eth.getBlockNumber();
108 | log(`b[3]-> ${b[3]}`);
109 | const st = await miniMeTokenState.getState();
110 | assert.equal(st.totalSupply, 10);
111 | assert.equal(st.balances[accounts[1]], 9);
112 | assert.equal(st.balances[accounts[2]], 1);
113 |
114 | let balance;
115 |
116 | balance = await miniMeToken.balanceOfAt(accounts[1], b[2]);
117 | assert.equal(balance, 8);
118 | balance = await miniMeToken.balanceOfAt(accounts[2], b[2]);
119 | assert.equal(balance, 2);
120 | balance = await miniMeToken.balanceOfAt(accounts[1], b[1]);
121 | assert.equal(balance, 10);
122 | balance = await miniMeToken.balanceOfAt(accounts[2], b[1]);
123 | assert.equal(balance, 0);
124 | balance = await miniMeToken.balanceOfAt(accounts[1], b[0]);
125 | assert.equal(balance, 0);
126 | balance = await miniMeToken.balanceOfAt(accounts[2], b[0]);
127 | assert.equal(balance, 0);
128 | balance = await miniMeToken.balanceOfAt(accounts[1], 0);
129 | assert.equal(balance, 0);
130 | balance = await miniMeToken.balanceOfAt(accounts[2], 0);
131 | assert.equal(balance, 0);
132 | });
133 |
134 | it('Should Destroy 3 tokens from 1 and 1 from 2', async () => {
135 | await miniMeToken.destroyTokens(accounts[1], 3, { from: accounts[0], gas: 200000 });
136 | b[4] = await web3.eth.getBlockNumber();
137 | log(`b[4]-> ${b[4]}`);
138 | const st = await miniMeTokenState.getState();
139 | assert.equal(st.totalSupply, 7);
140 | assert.equal(st.balances[accounts[1]], 6);
141 | });
142 |
143 | it('Should Create the clone token', async () => {
144 | const miniMeTokenCloneTx = await miniMeToken.createCloneToken(
145 | 'Clone Token 1',
146 | 18,
147 | 'MMTc',
148 | 0,
149 | true);
150 |
151 | let addr = miniMeTokenCloneTx.events.NewCloneToken.raw.topics[1];
152 | addr = `0x${addr.slice(26)}`;
153 | addr = utils.toChecksumAddress(addr);
154 | miniMeTokenClone = new MiniMeToken(web3, addr);
155 |
156 | miniMeTokenCloneState = new MiniMeTokenState(miniMeTokenClone);
157 |
158 | b[5] = await web3.eth.getBlockNumber();
159 | log(`b[5]-> ${b[5]}`);
160 | const st = await miniMeTokenCloneState.getState();
161 |
162 | assert.equal(st.parentToken, miniMeToken.$address);
163 | assert.equal(st.parentSnapShotBlock, b[5]);
164 | assert.equal(st.totalSupply, 7);
165 | assert.equal(st.balances[accounts[1]], 6);
166 |
167 | const totalSupply = await miniMeTokenClone.totalSupplyAt(b[4]);
168 |
169 | assert.equal(totalSupply, 7);
170 |
171 | const balance = await miniMeTokenClone.balanceOfAt(accounts[2], b[4]);
172 | assert.equal(balance, 1);
173 | }).timeout(6000);
174 |
175 | it('Should mine one block to take effect clone', async () => {
176 | await miniMeToken.transfer(accounts[1], 1, { from: accounts[1] });
177 | });
178 |
179 | it('Should move tokens in the clone token from 2 to 3', async () => {
180 | await miniMeTokenClone.transfer(accounts[2], 4, { from: accounts[1] });
181 | b[6] = await web3.eth.getBlockNumber();
182 | log(`b[6]-> ${b[6]}`);
183 |
184 | const st = await miniMeTokenCloneState.getState();
185 | assert.equal(st.totalSupply, 7);
186 | assert.equal(st.balances[accounts[1]], 2);
187 | assert.equal(st.balances[accounts[2]], 5);
188 |
189 | let balance;
190 |
191 | balance = await miniMeToken.balanceOfAt(accounts[1], b[5]);
192 | assert.equal(balance, 6);
193 | balance = await miniMeToken.balanceOfAt(accounts[2], b[5]);
194 | assert.equal(balance, 1);
195 | balance = await miniMeTokenClone.balanceOfAt(accounts[1], b[5]);
196 | assert.equal(balance, 6);
197 | balance = await miniMeTokenClone.balanceOfAt(accounts[2], b[5]);
198 | assert.equal(balance, 1);
199 | balance = await miniMeTokenClone.balanceOfAt(accounts[1], b[4]);
200 | assert.equal(balance, 6);
201 | balance = await miniMeTokenClone.balanceOfAt(accounts[2], b[4]);
202 | assert.equal(balance, 1);
203 |
204 | let totalSupply;
205 | totalSupply = await miniMeTokenClone.totalSupplyAt(b[5]);
206 | assert.equal(totalSupply, 7);
207 | totalSupply = await miniMeTokenClone.totalSupplyAt(b[4]);
208 | assert.equal(totalSupply, 7);
209 | }).timeout(6000);
210 |
211 | it('Should create tokens in the child token', async () => {
212 | await miniMeTokenClone.generateTokens(accounts[1], 10, { from: accounts[0], gas: 300000 });
213 | const st = await miniMeTokenCloneState.getState();
214 | assert.equal(st.totalSupply, 17);
215 | assert.equal(st.balances[accounts[1]], 12);
216 | assert.equal(st.balances[accounts[2]], 5);
217 | });
218 | });
219 |
--------------------------------------------------------------------------------