master cea17ed3d445 cached
52 files
292.8 KB
87.3k tokens
13 symbols
1 requests
Download .txt
Showing preview only (309K chars total). Download the full file or copy to clipboard to get everything.
Repository: status-im/status-network-token
Branch: master
Commit: cea17ed3d445
Files: 52
Total size: 292.8 KB

Directory structure:
gitextract_uyqsp8mt/

├── .babelrc
├── .eslintrc
├── .flake8
├── .gitignore
├── .pylintrc
├── .travis.yml
├── INSTRUCTIONS.md
├── LICENSE
├── MINIME_README.md
├── MULTISIG.md
├── README.md
├── SPEC.md
├── audits/
│   ├── BlockchainLabs-SNT-audit-report.md
│   └── prelim-smartcontractsolutions-ef163f1b6fd6fb0630a4b8c78d3b706f3fe1da33.md
├── contracts/
│   ├── ContributionWallet.sol
│   ├── DevTokensHolder.sol
│   ├── DynamicCeiling.sol
│   ├── ERC20Token.sol
│   ├── MiniMeToken.sol
│   ├── MultiSigWallet.sol
│   ├── Owned.sol
│   ├── SGT.sol
│   ├── SGTExchanger.sol
│   ├── SNT.sol
│   ├── SNTPlaceHolder.sol
│   ├── SafeMath.sol
│   ├── StatusContribution.sol
│   └── test/
│       ├── DevTokensHolderMock.sol
│       ├── ExternalToken.sol
│       ├── Migrations.sol
│       ├── SGTExchangerMock.sol
│       ├── SGTMock.sol
│       ├── SNTMock.sol
│       ├── SNTPlaceHolderMock.sol
│       └── StatusContributionMock.sol
├── migrations/
│   ├── 1_initial_migration.js
│   └── 2_deploy_contracts.js
├── mypy.ini
├── package.json
├── scripts/
│   ├── ceiling_curve_calc.py
│   └── sgtGeneration/
│       ├── deploy.js
│       ├── deploy_test.js
│       ├── initialBalance.csv
│       └── loadBalances.js
├── test/
│   ├── claimExternal.js
│   ├── contribution.js
│   ├── dynamicCeiling.js
│   └── helpers/
│       ├── assertFail.js
│       ├── assertGas.js
│       ├── assertJump.js
│       └── hiddenCurves.js
└── truffle.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .babelrc
================================================
{
  "presets": ["es2015", "stage-2", "stage-3"]
}


================================================
FILE: .eslintrc
================================================
{
    "env": {
        "browser": true,
        "es6": true,
        "node": true,
        "mocha": true
    },
    "extends": "airbnb",
    "parser": "babel-eslint",
    "rules": {
        // indentation
        "indent": [ 2, 4 ],

        // spacing
        "template-curly-spacing": [ 2, "always" ],
        "array-bracket-spacing": [ 2, "always" ],
        "object-curly-spacing": [ 2, "always" ],
        "computed-property-spacing": [ 2, "always" ],
        "no-multiple-empty-lines": [ 2, { "max": 1, "maxEOF": 0, "maxBOF": 0 } ],

        // strings
        "quotes": [ 2, "double", "avoid-escape" ],

        // code arrangement matter
        "no-use-before-define": [ 2, { "functions": false } ],

        // make it meaningful
        "prefer-const": 1,

        // keep it simple
        "complexity": [ 1, 5 ],

        // Consisten return
        "consistent-return": 0,

        "import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.js", "**/*.spec.js", "**/compile.js", "**/test/*.js"]}],

        // react
        "react/prefer-es6-class": 0,
        "react/jsx-filename-extension": 0,
        "react/jsx-indent": [ 2, 4 ]
    },
    "globals": {
        "artifacts": true,
        "web3": true,
        "contract": true,
        "assert": true
    }
}


================================================
FILE: .flake8
================================================
[flake8]
max-line-length = 99


================================================
FILE: .gitignore
================================================
node_modules/
build/
.DS_Store

.mypy_cache
__pycache__


================================================
FILE: .pylintrc
================================================
[BASIC]
good-names=i,j,k,n,ex,Run,_

[FORMAT]
max-line-length = 99
disable=locally-disabled,locally-enabled


================================================
FILE: .travis.yml
================================================
dist: 'trusty'
group: 'beta'

language: 'node_js'
sudo: false
node_js:
  - '8'

cache:
    yarn: true

script:
  - 'truffle compile'
  - 'testrpc --network-id 15 --mnemonic ''status mnemonic status mnemonic status mnemonic status mnemonic status mnemonic status mnemonic'' > /dev/null &'
  - 'truffle test --network development'
  - 'truffle migrate --reset --network development_migrate'


================================================
FILE: INSTRUCTIONS.md
================================================
## Before starting

* Install `yarn` and `npm`.
* Run `yarn` at the repo root.
* Use the same BIP39 compatible mnemonic in both `truffle.js` (can be set by environment variable `TEST_MNEMONIC`) and for your client.
* Change the `from` key in `truffle.js` for any network that requires it.
* Compile contracts:
  ```
  ./node_modules/.bin/truffle compile
  ```
* Start your Ethereum client:
  ```
  ./node_modules/.bin/testrpc --network-id 15 --mnemonic 'status mnemonic status mnemonic status mnemonic status mnemonic status mnemonic status mnemonic'
  ```

## Run tests

* Run tests
  ```
  ./node_modules/.bin/truffle test --network development
  ```

## Deploy

* Change the config constants in `migrations/2_deploy_contracts.js` to match your addresses and parameters.
* Deploy contracts (choose network from `truffle.js`). The following command deploys up to migration step 2:
  ```
  ./node_modules/.bin/truffle migrate --network development_migrate -f 2
  ```

## Calculations

* Install `python3.6`.
* Caculate outcomes of different ceilings by running:
  ```
  ./scripts/ceiling_curve_calc.py --limit=6100000000000000000000 --curve-factor=300 --fee-token=0.1
  ```
* Run the following to see all options:
  ```
  ./scripts/ceiling_curve_calc.py --help
  ```


================================================
FILE: LICENSE
================================================
Jarrad Hope (Status Research & Development) Copyright (C) 2017
Jorge Izquierdo (Aragon Foundation) Copyright (C) 2017
Jordi Baylina (Giveth) Copyright (C) 2017

                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRSNTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRSNTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRSNTIES OF MERCHSNTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    {one line to give the program's name and a brief idea of what it does.}
    Jorge Izquierdo (Aragon Foundation) Copyright (C) 2017

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRSNTY; without even the implied warranty of
    MERCHSNTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    Jorge Izquierdo (Aragon Foundation) Copyright (C) 2017
    This program comes with ABSOLUTELY NO WARRSNTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.


================================================
FILE: MINIME_README.md
================================================
# Status Network Token

The MiniMeToken contract is a standard ERC20 token with extra functionality:

### The token is easy to clone!

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.

    function createCloneToken(
        string _cloneTokenName,
        uint8 _cloneDecimalUnits,
        string _cloneTokenSymbol,
        uint _snapshotBlock,
        bool _isConstant
        ) returns(address) {

Once the clone token is created, it acts as a completely independent token, with it's own unique functionalities.

### Balance history is registered and available to be queried

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.

    function totalSupplyAt(uint _blockNumber) constant returns(uint)

    function balanceOfAt(address _holder, uint _blockNumber) constant returns (uint)

### Optional token controller

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.

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.

To create and destroy tokens, these two functions are introduced:

    function generateTokens(address _holder, uint _value) onlyController

    function destroyTokens(address _holder, uint _value) onlyController

### The Token's Controller can freeze transfers.

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.

    // Allows tokens to be transferred if true or frozen if false
    function enableTransfers(bool _transfersEnabled) onlyController


## Applications

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:

1. Generating a voting token that is burned when you vote.
2. Generating a discount "coupon" that is redeemed when you use it.
3. Generating a token for a "spinoff" DAO.
4. Generating a token that can be used to give explicit support to an action or a campaign, like polling.
5. Generating a token to enable the token holders to collect daily, monthly or yearly payments.
6. Generating a token to limit participation in a contribution period or similar event to holders of a specific token.
7. Generating token that allows a central party complete control to transfer/generate/destroy tokens at will.
8. Lots of other applications including all the applications the standard ERC 20 token can be used for.

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.

# How to deploy a campaign

1. Deploy the MinimeTokenFactory
2. Deploy the MinimeToken
3. Deploy the campaign
4. Assign the controller of the MinimeToken to the campaign.


================================================
FILE: MULTISIG.md
================================================
# Status Community Multisig [0xbbf0cc1c63f509d48a4674e270d26d80ccaf6022](https://etherscan.io/address/0xbbf0cc1c63f509d48a4674e270d26d80ccaf6022)

Required signatures: 3/5

## Signers

- Jordi Baylina, [Giveth](http://www.giveth.io/). [Address](https://etherscan.io/address/0x6b9ef02657339310e28a7a9d4b5f25f7c1f68d61).
- Joe Urgo, [district0x](https://district0x.io/), [Sourcerers](http://sourcerers.io/). [Address](https://etherscan.io/address/0x904Ef6ff8E82478c5604d99884EB9Bcd7F73Cc36).
- Hudson Jameson, [Oaken Innovations](https://www.projectoaken.com/). [Address](https://etherscan.io/address/0x02E3F16cA21cf0508835B190933ECbdE2f7f14DF).
- Jorge Izquierdo, [Aragon](https://aragon.one/). [Address](https://etherscan.io/address/0x4838eab6f43841e0d233db4cea47bd64f614f0c5).
- Status Research & Development Multisig. [Address](https://etherscan.io/address/0xa646e29877d52b9e2de457eca09c724ff16d0a2b).


## Responsibilities

- The Status Community Multisig will serve SNT holders and the broader crypto community to ensure Status' stated mission is carried.
- The Status Community Multisig manages the 29% reserve SNT allocation.
- The Status Community Multisig can be used to solve hypothetical deadlock problems in the Status Research & Development Multisig to ensure resources won't get locked and the project will continue its course.


# Status Research & Development Multisig – [0xa646e29877d52b9e2de457eca09c724ff16d0a2b](https://etherscan.io/address/0xa646e29877d52b9e2de457eca09c724ff16d0a2b)

Required signatures: 2/3

## Signers

- Jarrad Hope, Status Research & Development CEO. [Address](https://etherscan.io/address/0x3ac6cb2ccfd8c8aae3ba31d7ed44c20d241b16a4).
- Carl Bennetts, Status Research & Development CMO. [Address](https://etherscan.io/address/0xdBD6ffD3CB205576367915Dd2f8De0aF7edcCeeF).
- Status Community Multisig – [Address](https://etherscan.io/address/0xbbf0cc1c63f509d48a4674e270d26d80ccaf6022).


## Responsibilities

- Status Research & Development Multisig will hold the Status Research & Development ether funds and SNT tokens.

================================================
FILE: README.md
================================================
# Status Network Token
[![Build Status](https://travis-ci.org/status-im/status-network-token.svg?branch=master)](https://travis-ci.org/status-im/status-network-token)

- [Whitepaper](https://status.im/whitepaper.pdf)
- [Contribution Period Specification](/SPEC.md)
- [The Importance of Distribution](https://blog.status.im/distribution-dynamic-ceilings-e2f427f5cca) blogpost.
- [Encoding the Status ‘Genesis Block’](https://blog.status.im/encoding-the-status-genesis-block-d73d287a750) blogpost.

## Technical definition

At the technical level SGT & SNT are a ERC20-compliant tokens, derived from the [MiniMe Token](https://github.com/Giveth/minime) that allows for token cloning (forking), which will be useful for many future use-cases.

Also built in the token is a vesting schedule for limiting SNT transferability over time. Status Project Founders tokens are vesting.

## Contracts

- [SNT.sol](/contracts/SNT.sol): Main contract for the token.
- [SGT.sol](/contracts/SGT.sol): Token contract for early adopters. Deployed to [0xd248B0D48E44aaF9c49aea0312be7E13a6dc1468](https://etherscan.io/address/0xd248B0D48E44aaF9c49aea0312be7E13a6dc1468#readContract)
- [MiniMeToken.sol](/contracts/MiniMeToken.sol): Token implementation.
- [StatusContribution.sol](/contracts/StatusContribution.sol): Implementation of the initial distribution of SNT.
- [DynamicCeiling.sol](/contracts/DynamicCeiling.sol): Auxiliary contract to manage the dynamic ceiling during the contribution period.
- [SNTPlaceHolder.sol](/contracts/SNTPlaceHolder.sol): Placeholder for the Status Network before its deployment.
- [ContributionWallet.sol](/contracts/ContributionWallet.sol): Simple contract that will hold all funds until final block of the contribution period.
- [MultiSigWallet.sol](/contracts/MultiSigWallet.sol): ConsenSys multisig used for Status and community multisigs.
- [DevTokensHolder.sol](/contracts/DevTokensHolder.sol): Contract where tokens belonging to developers will be held. This contract will release this tokens in a vested timing.
- [SGTExchanger.sol](/contracts/SGTExchanger.sol): Contract responsible for crediting SNTs to the SGT holders after the contribution period ends.

See [INSTRUCTIONS.md](/INSTRUCTIONS.md) for instructions on how to test and deploy the contracts.

## Reviewers and audits.

Code for the SNT token and the offering is being reviewed by:

- Jordi Baylina, Author.
- [Smart Contract Solutions (OpenZeppelin)](https://smartcontractsolutions.com/). [Pending audit results](/) [Preliminary](/audits/prelim-smartcontractsolutions-ef163f1b6fd6fb0630a4b8c78d3b706f3fe1da33.md)
- [CoinFabrik](http://www.coinfabrik.com/). [2152b17aa2ef584a2aea95533c707a345c6ccf69](/audits/coinfabrik-2152b17aa2ef584a2aea95533c707a345c6ccf69.pdf)
- [BlockchainLabs.nz](http://blockchainlabs.nz/). [Audit results](/audits/BlockchainLabs-SNT-audit-report.md)
- [Bok Consulting](https://www.bokconsulting.com.au/). [Pending audit results](/)
- YYYYYY. [Pending audit results](/)

A bug bounty for the SNT token and offering started on 14/6/2017. [More details](https://blog.status.im/status-network-token-bug-bounty-a66fc2324359)


================================================
FILE: SPEC.md
================================================
# Status Network Contribution Period
## Functional Specification

### Distribution
- 29% is for reserve (multisig)
- 20% goes to the status team and founders (multisig, 2 Year Vesting Contract, 6 month cliffs)
- Remaining 51% is divided between the initial contribution period itself and SGT, where SGT is <= 10% of total supply.

### Whitelist
Addresses can be whitelisted and have guaranteed participation up to a set maximum amount, ignores Dynamic Ceiling. Sending ETH to the smart contract address should be no different, whether whitelisted or not.
Status Genesis Tokens
SGT is a Minime Token that’s total supply of 500,000,000 maps to, and cannot exceed 10% of the total supply.
ie. If 250,000,000 of SGT is allocated then SGT maps to 5% of the total supply.
SGT can be redeemed for SNT after contribution period.

### Dynamic Ceiling
A Curve that specifies a series of hidden hard caps at specific block intervals, that can be revealed at anytime during the contribution period. The entire curve must be revealed before finalising the contribution period. Finalising the contribution period can happen at any moment during the curve, as long as entire curve has been revealed. Whitelisted addresses ignore ceiling.

### Misc
Tokens are not transferrable for 1 week after contribution period and are minted at 10,000 SNT per 1 ETH.


================================================
FILE: audits/BlockchainLabs-SNT-audit-report.md
================================================
# Status Network Token Audit

## Preamble
This audit report was undertaken by BlockchainLabs.nz for the purpose of providing feedback to Status Research & Development Gmbh. It has subsequently been shared publicly without any express or implied warranty.

Solidity contracts were sourced from the public Github repo [status-im/status-network-token](https://github.com/status-im/status-network-token) prior to commit [79419f86c1b4bfcfcd18f08aecee168ff1f73fc4](https://github.com/status-im/status-network-token/tree/79419f86c1b4bfcfcd18f08aecee168ff1f73fc4) - we would encourage all community members and token holders to make their own assessment of the contracts.

## Scope
All Solidity code contained in [/contracts](https://github.com/status-im/status-network-token/tree/master/contracts) was considered in scope along with the tests contained in [/test](https://github.com/status-im/status-network-token/tree/master/test) as a basis for static and dynamic analysis.

## Focus Areas
The audit report is focused on the following key areas - though this is *not an exhaustive list*.

### Correctness
* No correctness defects uncovered during static analysis?
* No implemented contract violations uncovered during execution?
* No other generic incorrect behavior detected during execution?
* Adherence to adopted standards such as ERC20?

### Testability
* Test coverage across all functions and events?
* Test cases for both expected behaviour and failure modes?
* Settings for easy testing of a range of parameters?
* No reliance on nested callback functions or console logs?
* Avoidance of test scenarios calling other test scenarios?

### Security
* No presence of known security weaknesses?
* No funds at risk of malicious attempts to withdraw/transfer?
* No funds at risk of control fraud?
* Prevention of Integer Overflow or Underflow?

### Best Practice
* Explicit labeling for the visibility of functions and state variables?
* Proper management of gas limits and nested execution?
* Latest version of the Solidity compiler?

## Classification

### Defect Severity
* **Minor** - A defect that does not have a material impact on the contract execution and is likely to be subjective.
* **Moderate** - A defect that could impact the desired outcome of the contract execution in a specific scenario.
* **Major** - A defect that impacts the desired outcome of the contract execution or introduces a weakness that may be exploited.
* **Critical** - A defect that presents a significant security vulnerability or failure of the contract across a range of scenarios.

## Findings
### Minor

**SGT Exchanger** - While testing the correctness of SGTExchanger, we found that it was possible for a user with no SGT tokens to call the collect() function. It was also possible for a user with SGT tokens to call the collect() function for a second time, after having already collected their SNT.

However, this is a minor issue because in both cases no SNT was issued. Since commit `450fbc85fd7a4a0dc17d22fc7a6ab5071277fb46`, PR 106 on 16th June an exception is now thrown:
https://github.com/status-im/status-network-token/pull/106

**Test Failures** - Tests designed to check for failures were encapsulated within a `catch` and were never properly evaluated. The fix for this issue was addressed on https://github.com/status-im/status-network-token#70 and later improved on https://github.com/status-im/status-network-token#133

**SGT after Contribution** - As of 19 June, attempts to generate additional SGT tokens after the contribution period has begun do not throw an exception.

Prior to 19 June this resulted in a thrown exception, which is preferable.

~~However, no new tokens are created so this is only a minor issue.~~ _Status have advised that SGT can be issued after the contribution period._

### Moderate
_No moderate defects were found during this audit._

### Major

**Short Address** - The current implementation of MiniMeToken is vulnerable to ERC20 Short Address 'Attack'

http://vessenes.com/the-erc20-short-address-attack-explained/
https://blog.golemproject.net/how-to-find-10m-by-just-reading-blockchain-6ae9d39fcd95

While this isn't a critical issue as it only comes into play with user error, we suggest making the fix to MiniMeToken.

A simple fix would be to add a modifier to check address size, and apply this modifier to the transfer function of the MiniMeToken:
```
    modifier onlyPayloadSize(uint size) {
       assert(msg.data.length == size + 4);
       _;
    }

    function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) {
      //function body unchanged
    }
```
**DevTokensHolder** - The function collectTokens on the DevTokensHolder contract will mistakenly floor the division of any period of time by 24 months. Making it impossible for developers to collect any token until 2 years. The fix was merged on status-im/status-network-token#105

### Critical
_No critical defects were found during this audit._

## Conclusion
Overall we have been satisfied with the quality of the code and responsiveness of the developers in fixing defects. There was good test coverage for some components such as MultiSigWallet and MiniMeToken as they've been used in other projects, meanwhile tests for the other contracts/functions were written during the audit period to improve the testability of the project as a whole.

The developers have followed common best practices and demonstrated an awareness of security weaknesses that could put funds at risk. During the audit the **Short Address** advisory was published and we recommend that this be handled upstream as a modifier in the MiniMeToken contract itself.


================================================
FILE: audits/prelim-smartcontractsolutions-ef163f1b6fd6fb0630a4b8c78d3b706f3fe1da33.md
================================================
Hi all!

Here are the severe issues we've found so far:

#### Cloning a MiniMeToken with snapshot block set to the current block is subject to a value change attack.

If a `MiniMeToken` is cloned by calling the `createCloneToken` function on [line 384 of MiniMeToken.sol](https://github.com/status-im/status-network-token/blob/2152b17aa2ef584a2aea95533c707a345c6ccf69/contracts/MiniMeToken.sol#L384) with the `_snapshotBlock` parameter set to zero or `block.number`, the clone will be creating using the current block as `parentSnapShotBlock`.

This opens a small window of time for an attacker to see this transaction in the network, and insert `transfer` transactions in the same block. Given these will be [in the context of the current block too](https://github.com/status-im/status-network-token/blob/2152b17aa2ef584a2aea95533c707a345c6ccf69/contracts/MiniMeToken.sol#L500), the values used for the clone token will contain the modifications by the attacker. This would be confusing for the user creating the clone at the very least, and potentially dangerous. 

Luckily this can be very easily fixed. Consider replacing [line 391 of MiniMeToken.sol](https://github.com/status-im/status-network-token/blob/2152b17aa2ef584a2aea95533c707a345c6ccf69/contracts/MiniMeToken.sol#L391) for a check that will throw if `_snapshotBlock` equals `block.number`. Consider adding the same check [in the MiniMeToken constructor](https://github.com/status-im/status-network-token/blob/2152b17aa2ef584a2aea95533c707a345c6ccf69/contracts/MiniMeToken.sol#L156) too, for `_parentSnapShotBlock`.

#### ContributionWallet finalBlock can be different from StatusContribution stopBlock

Withdrawal from the `ContributionWallet` contract is enabled once [the contribution is finalized](https://github.com/status-im/status-network-token/blob/2152b17aa2ef584a2aea95533c707a345c6ccf69/contracts/ContributionWallet.sol#L58) or when the current block is after `finalBlock`, a state variable. For the contract to serve its purpose, `finalBlock` should be the same as the contribution's `stopBlock` or greater. Otherwise, the funds could be withdrawn [before the contribution is finalized](https://github.com/status-im/status-network-token/blob/2152b17aa2ef584a2aea95533c707a345c6ccf69/contracts/ContributionWallet.sol#L57), which would defeat the purpose of `ContributionWallet`. 

Consider using `contribution.stopBlock()` in place of `finalBlock` or checking that `finalBlock` is greater or equal than `stopBlock`.

**Addendum**

We also have and additional comment about [a PR you merged adding gas price cap to transactions](https://github.com/status-im/status-network-token/pull/20/files) and [a pending PR adding a cap to call frequency by address](https://github.com/status-im/status-network-token/pull/67/files). Both are out of the audit's commit scope, but we want to let you guys know our thoughts anyway as a friendly help. We don't this this additions are a good idea, and recommend you revert them. 

See [Vitalik's post](http://vitalik.ca/general/2017/06/09/sales.html) about the gas price cap issue, and the frequency cap can be easily circumvented so it doesn't add security but does add complexity and attack surface.

Let me know your thoughts/questions. The final report will be delivered on Friday, as agreed.

Happy to be working on this together,

Cheers,

Manuel Araoz

[openzeppelin.com](https://openzeppelin.com/)

================================================
FILE: contracts/ContributionWallet.sol
================================================
pragma solidity ^0.4.11;

/*
    Copyright 2017, Jordi Baylina

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/// @title ContributionWallet Contract
/// @author Jordi Baylina
/// @dev This contract will be hold the Ether during the contribution period.
///  The idea of this contract is to avoid recycling Ether during the contribution
///  period. So all the ETH collected will be locked here until the contribution
///  period ends

// @dev Contract to hold sale raised funds during the sale period.
// Prevents attack in which the Aragon Multisig sends raised ether
// to the sale contract to mint tokens to itself, and getting the
// funds back immediately.


import "./StatusContribution.sol";


contract ContributionWallet {

    // Public variables
    address public multisig;
    uint256 public endBlock;
    StatusContribution public contribution;

    // @dev Constructor initializes public variables
    // @param _multisig The address of the multisig that will receive the funds
    // @param _endBlock Block after which the multisig can request the funds
    // @param _contribution Address of the StatusContribution contract
    function ContributionWallet(address _multisig, uint256 _endBlock, address _contribution) {
        require(_multisig != 0x0);
        require(_contribution != 0x0);
        require(_endBlock != 0 && _endBlock <= 4000000);
        multisig = _multisig;
        endBlock = _endBlock;
        contribution = StatusContribution(_contribution);
    }

    // @dev Receive all sent funds without any further logic
    function () public payable {}

    // @dev Withdraw function sends all the funds to the wallet if conditions are correct
    function withdraw() public {
        require(msg.sender == multisig);              // Only the multisig can request it
        require(block.number > endBlock ||            // Allow after end block
                contribution.finalizedBlock() != 0);  // Allow when sale is finalized
        multisig.transfer(this.balance);
    }

}


================================================
FILE: contracts/DevTokensHolder.sol
================================================
pragma solidity ^0.4.11;

/*
    Copyright 2017, Jordi Baylina

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/// @title DevTokensHolder Contract
/// @author Jordi Baylina
/// @dev This contract will hold the tokens of the developers.
///  Tokens will not be able to be collected until 6 months after the contribution
///  period ends. And it will be increasing linearly until 2 years.


//  collectable tokens
//   |                         _/--------   vestedTokens rect
//   |                       _/
//   |                     _/
//   |                   _/
//   |                 _/
//   |               _/
//   |             _/
//   |           _/
//   |          |
//   |        . |
//   |      .   |
//   |    .     |
//   +===+======+--------------+----------> time
//     Contrib   6 Months       24 Months
//       End


import "./MiniMeToken.sol";
import "./StatusContribution.sol";
import "./SafeMath.sol";
import "./ERC20Token.sol";


contract DevTokensHolder is Owned {
    using SafeMath for uint256;

    uint256 collectedTokens;
    StatusContribution contribution;
    MiniMeToken snt;

    function DevTokensHolder(address _owner, address _contribution, address _snt) {
        owner = _owner;
        contribution = StatusContribution(_contribution);
        snt = MiniMeToken(_snt);
    }


    /// @notice The Dev (Owner) will call this method to extract the tokens
    function collectTokens() public onlyOwner {
        uint256 balance = snt.balanceOf(address(this));
        uint256 total = collectedTokens.add(balance);

        uint256 finalizedTime = contribution.finalizedTime();

        require(finalizedTime > 0 && getTime() > finalizedTime.add(months(6)));

        uint256 canExtract = total.mul(getTime().sub(finalizedTime)).div(months(24));

        canExtract = canExtract.sub(collectedTokens);

        if (canExtract > balance) {
            canExtract = balance;
        }

        collectedTokens = collectedTokens.add(canExtract);
        assert(snt.transfer(owner, canExtract));

        TokensWithdrawn(owner, canExtract);
    }

    function months(uint256 m) internal returns (uint256) {
        return m.mul(30 days);
    }

    function getTime() internal returns (uint256) {
        return now;
    }


    //////////
    // Safety Methods
    //////////

    /// @notice This method can be used by the controller to extract mistakenly
    ///  sent tokens to this contract.
    /// @param _token The address of the token contract that you want to recover
    ///  set to 0 in case you want to extract ether.
    function claimTokens(address _token) public onlyOwner {
        require(_token != address(snt));
        if (_token == 0x0) {
            owner.transfer(this.balance);
            return;
        }

        ERC20Token token = ERC20Token(_token);
        uint256 balance = token.balanceOf(this);
        token.transfer(owner, balance);
        ClaimedTokens(_token, owner, balance);
    }

    event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount);
    event TokensWithdrawn(address indexed _holder, uint256 _amount);
}


================================================
FILE: contracts/DynamicCeiling.sol
================================================
pragma solidity ^0.4.11;

/*
    Copyright 2017, Jordi Baylina

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/// @title DynamicCeiling Contract
/// @author Jordi Baylina
/// @dev This contract calculates the ceiling from a series of curves.
///  These curves are committed first and revealed later.
///  All the curves must be in increasing order and the last curve is marked
///  as the last one.
///  This contract allows to hide and reveal the ceiling at will of the owner.


import "./SafeMath.sol";
import "./Owned.sol";


contract DynamicCeiling is Owned {
    using SafeMath for uint256;

    struct Curve {
        bytes32 hash;
        // Absolute limit for this curve
        uint256 limit;
        // The funds remaining to be collected are divided by `slopeFactor` smooth ceiling
        // with a long tail where big and small buyers can take part.
        uint256 slopeFactor;
        // This keeps the curve flat at this number, until funds to be collected is less than this
        uint256 collectMinimum;
    }

    address public contribution;

    Curve[] public curves;
    uint256 public currentIndex;
    uint256 public revealedCurves;
    bool public allRevealed;

    /// @dev `contribution` is the only address that can call a function with this
    /// modifier
    modifier onlyContribution {
        require(msg.sender == contribution);
        _;
    }

    function DynamicCeiling(address _owner, address _contribution) {
        owner = _owner;
        contribution = _contribution;
    }

    /// @notice This should be called by the creator of the contract to commit
    ///  all the curves.
    /// @param _curveHashes Array of hashes of each curve. Each hash is calculated
    ///  by the `calculateHash` method. More hashes than actual curves can be
    ///  committed in order to hide also the number of curves.
    ///  The remaining hashes can be just random numbers.
    function setHiddenCurves(bytes32[] _curveHashes) public onlyOwner {
        require(curves.length == 0);

        curves.length = _curveHashes.length;
        for (uint256 i = 0; i < _curveHashes.length; i = i.add(1)) {
            curves[i].hash = _curveHashes[i];
        }
    }


    /// @notice Anybody can reveal the next curve if he knows it.
    /// @param _limit Ceiling cap.
    ///  (must be greater or equal to the previous one).
    /// @param _last `true` if it's the last curve.
    /// @param _salt Random number used to commit the curve
    function revealCurve(uint256 _limit, uint256 _slopeFactor, uint256 _collectMinimum,
                         bool _last, bytes32 _salt) public {
        require(!allRevealed);

        require(curves[revealedCurves].hash == calculateHash(_limit, _slopeFactor, _collectMinimum,
                                                             _last, _salt));

        require(_limit != 0 && _slopeFactor != 0 && _collectMinimum != 0);
        if (revealedCurves > 0) {
            require(_limit >= curves[revealedCurves.sub(1)].limit);
        }

        curves[revealedCurves].limit = _limit;
        curves[revealedCurves].slopeFactor = _slopeFactor;
        curves[revealedCurves].collectMinimum = _collectMinimum;
        revealedCurves = revealedCurves.add(1);

        if (_last) allRevealed = true;
    }

    /// @notice Reveal multiple curves at once
    function revealMulti(uint256[] _limits, uint256[] _slopeFactors, uint256[] _collectMinimums,
                         bool[] _lasts, bytes32[] _salts) public {
        // Do not allow none and needs to be same length for all parameters
        require(_limits.length != 0 &&
                _limits.length == _slopeFactors.length &&
                _limits.length == _collectMinimums.length &&
                _limits.length == _lasts.length &&
                _limits.length == _salts.length);

        for (uint256 i = 0; i < _limits.length; i = i.add(1)) {
            revealCurve(_limits[i], _slopeFactors[i], _collectMinimums[i],
                        _lasts[i], _salts[i]);
        }
    }

    /// @notice Move to curve, used as a failsafe
    function moveTo(uint256 _index) public onlyOwner {
        require(_index < revealedCurves &&       // No more curves
                _index == currentIndex.add(1));  // Only move one index at a time
        currentIndex = _index;
    }

    /// @return Return the funds to collect for the current point on the curve
    ///  (or 0 if no curves revealed yet)
    function toCollect(uint256 collected) public onlyContribution returns (uint256) {
        if (revealedCurves == 0) return 0;

        // Move to the next curve
        if (collected >= curves[currentIndex].limit) {  // Catches `limit == 0`
            uint256 nextIndex = currentIndex.add(1);
            if (nextIndex >= revealedCurves) return 0;  // No more curves
            currentIndex = nextIndex;
            if (collected >= curves[currentIndex].limit) return 0;  // Catches `limit == 0`
        }

        // Everything left to collect from this limit
        uint256 difference = curves[currentIndex].limit.sub(collected);

        // Current point on the curve
        uint256 collect = difference.div(curves[currentIndex].slopeFactor);

        // Prevents paying too much fees vs to be collected; breaks long tail
        if (collect <= curves[currentIndex].collectMinimum) {
            if (difference > curves[currentIndex].collectMinimum) {
                return curves[currentIndex].collectMinimum;
            } else {
                return difference;
            }
        } else {
            return collect;
        }
    }

    /// @notice Calculates the hash of a curve.
    /// @param _limit Ceiling cap.
    /// @param _last `true` if it's the last curve.
    /// @param _salt Random number that will be needed to reveal this curve.
    /// @return The calculated hash of this curve to be used in the `setHiddenCurves` method
    function calculateHash(uint256 _limit, uint256 _slopeFactor, uint256 _collectMinimum,
                           bool _last, bytes32 _salt) public constant returns (bytes32) {
        return keccak256(_limit, _slopeFactor, _collectMinimum, _last, _salt);
    }

    /// @return Return the total number of curves committed
    ///  (can be larger than the number of actual curves on the curve to hide
    ///  the real number of curves)
    function nCurves() public constant returns (uint256) {
        return curves.length;
    }

}


================================================
FILE: contracts/ERC20Token.sol
================================================
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/issues/20
pragma solidity ^0.4.11;

contract ERC20Token {
    /* This is a slight change to the ERC20 base standard.
    function totalSupply() constant returns (uint256 supply);
    is replaced with:
    uint256 public totalSupply;
    This automatically creates a getter function for the totalSupply.
    This is moved to the base contract since public getter functions are not
    currently recognised as an implementation of the matching abstract
    function by the compiler.
    */
    /// total amount of tokens
    uint256 public totalSupply;

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) constant returns (uint256 balance);

    /// @notice send `_value` token to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _value) returns (bool success);

    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transferFrom(address _from, address _to, uint256 _value) returns (bool success);

    /// @notice `msg.sender` approves `_spender` to spend `_value` tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of tokens to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _value) returns (bool success);

    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens allowed to spent
    function allowance(address _owner, address _spender) constant returns (uint256 remaining);

    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}


================================================
FILE: contracts/MiniMeToken.sol
================================================
pragma solidity ^0.4.11;


import "./ERC20Token.sol";

/*
    Copyright 2016, Jordi Baylina

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/// @title MiniMeToken Contract
/// @author Jordi Baylina
/// @dev This token contract's goal is to make it easy for anyone to clone this
///  token using the token distribution at a given block, this will allow DAO's
///  and DApps to upgrade their features in a decentralized manner without
///  affecting the original token
/// @dev It is ERC20 compliant, but still needs to under go further testing.


/// @dev The token controller contract must implement these functions
contract TokenController {
    /// @notice Called when `_owner` sends ether to the MiniMe Token contract
    /// @param _owner The address that sent the ether to create tokens
    /// @return True if the ether is accepted, false if it throws
    function proxyPayment(address _owner) payable returns(bool);

    /// @notice Notifies the controller about a token transfer allowing the
    ///  controller to react if desired
    /// @param _from The origin of the transfer
    /// @param _to The destination of the transfer
    /// @param _amount The amount of the transfer
    /// @return False if the controller does not authorize the transfer
    function onTransfer(address _from, address _to, uint _amount) returns(bool);

    /// @notice Notifies the controller about an approval allowing the
    ///  controller to react if desired
    /// @param _owner The address that calls `approve()`
    /// @param _spender The spender in the `approve()` call
    /// @param _amount The amount in the `approve()` call
    /// @return False if the controller does not authorize the approval
    function onApprove(address _owner, address _spender, uint _amount)
        returns(bool);
}

contract Controlled {
    /// @notice The address of the controller is the only address that can call
    ///  a function with this modifier
    modifier onlyController { if (msg.sender != controller) throw; _; }

    address public controller;

    function Controlled() { controller = msg.sender;}

    /// @notice Changes the controller of the contract
    /// @param _newController The new controller of the contract
    function changeController(address _newController) onlyController {
        controller = _newController;
    }
}

contract ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 _amount, address _token, bytes _data);
}

/// @dev The actual token contract, the default controller is the msg.sender
///  that deploys the contract, so usually this token will be deployed by a
///  token controller contract, which Giveth will call a "Campaign"
contract MiniMeToken is Controlled {

    string public name;                //The Token's name: e.g. DigixDAO Tokens
    uint8 public decimals;             //Number of decimals of the smallest unit
    string public symbol;              //An identifier: e.g. REP
    string public version = 'MMT_0.1'; //An arbitrary versioning scheme


    /// @dev `Checkpoint` is the structure that attaches a block number to a
    ///  given value, the block number attached is the one that last changed the
    ///  value
    struct  Checkpoint {

        // `fromBlock` is the block number that the value was generated from
        uint128 fromBlock;

        // `value` is the amount of tokens at a specific block number
        uint128 value;
    }

    // `parentToken` is the Token address that was cloned to produce this token;
    //  it will be 0x0 for a token that was not cloned
    MiniMeToken public parentToken;

    // `parentSnapShotBlock` is the block number from the Parent Token that was
    //  used to determine the initial distribution of the Clone Token
    uint public parentSnapShotBlock;

    // `creationBlock` is the block number that the Clone Token was created
    uint public creationBlock;

    // `balances` is the map that tracks the balance of each address, in this
    //  contract when the balance changes the block number that the change
    //  occurred is also included in the map
    mapping (address => Checkpoint[]) balances;

    // `allowed` tracks any extra transfer rights as in all ERC20 tokens
    mapping (address => mapping (address => uint256)) allowed;

    // Tracks the history of the `totalSupply` of the token
    Checkpoint[] totalSupplyHistory;

    // Flag that determines if the token is transferable or not.
    bool public transfersEnabled;

    // The factory used to create new clone tokens
    MiniMeTokenFactory public tokenFactory;

////////////////
// Constructor
////////////////

    /// @notice Constructor to create a MiniMeToken
    /// @param _tokenFactory The address of the MiniMeTokenFactory contract that
    ///  will create the Clone token contracts, the token factory needs to be
    ///  deployed first
    /// @param _parentToken Address of the parent token, set to 0x0 if it is a
    ///  new token
    /// @param _parentSnapShotBlock Block of the parent token that will
    ///  determine the initial distribution of the clone token, set to 0 if it
    ///  is a new token
    /// @param _tokenName Name of the new token
    /// @param _decimalUnits Number of decimals of the new token
    /// @param _tokenSymbol Token Symbol for the new token
    /// @param _transfersEnabled If true, tokens will be able to be transferred
    function MiniMeToken(
        address _tokenFactory,
        address _parentToken,
        uint _parentSnapShotBlock,
        string _tokenName,
        uint8 _decimalUnits,
        string _tokenSymbol,
        bool _transfersEnabled
    ) {
        tokenFactory = MiniMeTokenFactory(_tokenFactory);
        name = _tokenName;                                 // Set the name
        decimals = _decimalUnits;                          // Set the decimals
        symbol = _tokenSymbol;                             // Set the symbol
        parentToken = MiniMeToken(_parentToken);
        parentSnapShotBlock = _parentSnapShotBlock;
        transfersEnabled = _transfersEnabled;
        creationBlock = getBlockNumber();
    }


///////////////////
// ERC20 Methods
///////////////////

    /// @notice Send `_amount` tokens to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _amount) returns (bool success) {
        if (!transfersEnabled) throw;
        return doTransfer(msg.sender, _to, _amount);
    }

    /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it
    ///  is approved by `_from`
    /// @param _from The address holding the tokens being transferred
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return True if the transfer was successful
    function transferFrom(address _from, address _to, uint256 _amount
    ) returns (bool success) {

        // The controller of this contract can move tokens around at will,
        //  this is important to recognize! Confirm that you trust the
        //  controller of this contract, which in most situations should be
        //  another open source smart contract or 0x0
        if (msg.sender != controller) {
            if (!transfersEnabled) throw;

            // The standard ERC 20 transferFrom functionality
            if (allowed[_from][msg.sender] < _amount) return false;
            allowed[_from][msg.sender] -= _amount;
        }
        return doTransfer(_from, _to, _amount);
    }

    /// @dev This is the actual transfer function in the token contract, it can
    ///  only be called by other functions in this contract.
    /// @param _from The address holding the tokens being transferred
    /// @param _to The address of the recipient
    /// @param _amount The amount of tokens to be transferred
    /// @return True if the transfer was successful
    function doTransfer(address _from, address _to, uint _amount
    ) internal returns(bool) {

           if (_amount == 0) {
               return true;
           }

           if (parentSnapShotBlock >= getBlockNumber()) throw;

           // Do not allow transfer to 0x0 or the token contract itself
           if ((_to == 0) || (_to == address(this))) throw;

           // If the amount being transfered is more than the balance of the
           //  account the transfer returns false
           var previousBalanceFrom = balanceOfAt(_from, getBlockNumber());
           if (previousBalanceFrom < _amount) {
               return false;
           }

           // Alerts the token controller of the transfer
           if (isContract(controller)) {
               if (!TokenController(controller).onTransfer(_from, _to, _amount))
               throw;
           }

           // First update the balance array with the new value for the address
           //  sending the tokens
           updateValueAtNow(balances[_from], previousBalanceFrom - _amount);

           // Then update the balance array with the new value for the address
           //  receiving the tokens
           var previousBalanceTo = balanceOfAt(_to, getBlockNumber());
           if (previousBalanceTo + _amount < previousBalanceTo) throw; // Check for overflow
           updateValueAtNow(balances[_to], previousBalanceTo + _amount);

           // An event to make the transfer easy to find on the blockchain
           Transfer(_from, _to, _amount);

           return true;
    }

    /// @param _owner The address that's balance is being requested
    /// @return The balance of `_owner` at the current block
    function balanceOf(address _owner) constant returns (uint256 balance) {
        return balanceOfAt(_owner, getBlockNumber());
    }

    /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
    ///  its behalf. This is a modified version of the ERC20 approve function
    ///  to be a little bit safer
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return True if the approval was successful
    function approve(address _spender, uint256 _amount) returns (bool success) {
        if (!transfersEnabled) throw;

        // To change the approve amount you first have to reduce the addresses`
        //  allowance to zero by calling `approve(_spender,0)` if it is not
        //  already 0 to mitigate the race condition described here:
        //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
        if ((_amount!=0) && (allowed[msg.sender][_spender] !=0)) throw;

        // Alerts the token controller of the approve function call
        if (isContract(controller)) {
            if (!TokenController(controller).onApprove(msg.sender, _spender, _amount))
                throw;
        }

        allowed[msg.sender][_spender] = _amount;
        Approval(msg.sender, _spender, _amount);
        return true;
    }

    /// @dev This function makes it easy to read the `allowed[]` map
    /// @param _owner The address of the account that owns the token
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens of _owner that _spender is allowed
    ///  to spend
    function allowance(address _owner, address _spender
    ) constant returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }

    /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
    ///  its behalf, and then a function is triggered in the contract that is
    ///  being approved, `_spender`. This allows users to use their tokens to
    ///  interact with contracts in one function call instead of two
    /// @param _spender The address of the contract able to transfer the tokens
    /// @param _amount The amount of tokens to be approved for transfer
    /// @return True if the function call was successful
    function approveAndCall(address _spender, uint256 _amount, bytes _extraData
    ) returns (bool success) {
        if (!approve(_spender, _amount)) throw;

        ApproveAndCallFallBack(_spender).receiveApproval(
            msg.sender,
            _amount,
            this,
            _extraData
        );

        return true;
    }

    /// @dev This function makes it easy to get the total number of tokens
    /// @return The total number of tokens
    function totalSupply() constant returns (uint) {
        return totalSupplyAt(getBlockNumber());
    }


////////////////
// Query balance and totalSupply in History
////////////////

    /// @dev Queries the balance of `_owner` at a specific `_blockNumber`
    /// @param _owner The address from which the balance will be retrieved
    /// @param _blockNumber The block number when the balance is queried
    /// @return The balance at `_blockNumber`
    function balanceOfAt(address _owner, uint _blockNumber) constant
        returns (uint) {

        // These next few lines are used when the balance of the token is
        //  requested before a check point was ever created for this token, it
        //  requires that the `parentToken.balanceOfAt` be queried at the
        //  genesis block for that token as this contains initial balance of
        //  this token
        if ((balances[_owner].length == 0)
            || (balances[_owner][0].fromBlock > _blockNumber)) {
            if (address(parentToken) != 0) {
                return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
            } else {
                // Has no parent
                return 0;
            }

        // This will return the expected balance during normal situations
        } else {
            return getValueAt(balances[_owner], _blockNumber);
        }
    }

    /// @notice Total amount of tokens at a specific `_blockNumber`.
    /// @param _blockNumber The block number when the totalSupply is queried
    /// @return The total amount of tokens at `_blockNumber`
    function totalSupplyAt(uint _blockNumber) constant returns(uint) {

        // These next few lines are used when the totalSupply of the token is
        //  requested before a check point was ever created for this token, it
        //  requires that the `parentToken.totalSupplyAt` be queried at the
        //  genesis block for this token as that contains totalSupply of this
        //  token at this block number.
        if ((totalSupplyHistory.length == 0)
            || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
            if (address(parentToken) != 0) {
                return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
            } else {
                return 0;
            }

        // This will return the expected totalSupply during normal situations
        } else {
            return getValueAt(totalSupplyHistory, _blockNumber);
        }
    }

////////////////
// Clone Token Method
////////////////

    /// @notice Creates a new clone token with the initial distribution being
    ///  this token at `_snapshotBlock`
    /// @param _cloneTokenName Name of the clone token
    /// @param _cloneDecimalUnits Number of decimals of the smallest unit
    /// @param _cloneTokenSymbol Symbol of the clone token
    /// @param _snapshotBlock Block when the distribution of the parent token is
    ///  copied to set the initial distribution of the new clone token;
    ///  if the block is zero than the actual block, the current block is used
    /// @param _transfersEnabled True if transfers are allowed in the clone
    /// @return The address of the new MiniMeToken Contract
    function createCloneToken(
        string _cloneTokenName,
        uint8 _cloneDecimalUnits,
        string _cloneTokenSymbol,
        uint _snapshotBlock,
        bool _transfersEnabled
        ) returns(address) {
        if (_snapshotBlock == 0) _snapshotBlock = getBlockNumber();
        MiniMeToken cloneToken = tokenFactory.createCloneToken(
            this,
            _snapshotBlock,
            _cloneTokenName,
            _cloneDecimalUnits,
            _cloneTokenSymbol,
            _transfersEnabled
            );

        cloneToken.changeController(msg.sender);

        // An event to make the token easy to find on the blockchain
        NewCloneToken(address(cloneToken), _snapshotBlock);
        return address(cloneToken);
    }

////////////////
// Generate and destroy tokens
////////////////

    /// @notice Generates `_amount` tokens that are assigned to `_owner`
    /// @param _owner The address that will be assigned the new tokens
    /// @param _amount The quantity of tokens generated
    /// @return True if the tokens are generated correctly
    function generateTokens(address _owner, uint _amount
    ) onlyController returns (bool) {
        uint curTotalSupply = getValueAt(totalSupplyHistory, getBlockNumber());
        if (curTotalSupply + _amount < curTotalSupply) throw; // Check for overflow
        updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
        var previousBalanceTo = balanceOf(_owner);
        if (previousBalanceTo + _amount < previousBalanceTo) throw; // Check for overflow
        updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
        Transfer(0, _owner, _amount);
        return true;
    }


    /// @notice Burns `_amount` tokens from `_owner`
    /// @param _owner The address that will lose the tokens
    /// @param _amount The quantity of tokens to burn
    /// @return True if the tokens are burned correctly
    function destroyTokens(address _owner, uint _amount
    ) onlyController returns (bool) {
        uint curTotalSupply = getValueAt(totalSupplyHistory, getBlockNumber());
        if (curTotalSupply < _amount) throw;
        updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
        var previousBalanceFrom = balanceOf(_owner);
        if (previousBalanceFrom < _amount) throw;
        updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
        Transfer(_owner, 0, _amount);
        return true;
    }

////////////////
// Enable tokens transfers
////////////////


    /// @notice Enables token holders to transfer their tokens freely if true
    /// @param _transfersEnabled True if transfers are allowed in the clone
    function enableTransfers(bool _transfersEnabled) onlyController {
        transfersEnabled = _transfersEnabled;
    }

////////////////
// Internal helper functions to query and set a value in a snapshot array
////////////////

    /// @dev `getValueAt` retrieves the number of tokens at a given block number
    /// @param checkpoints The history of values being queried
    /// @param _block The block number to retrieve the value at
    /// @return The number of tokens being queried
    function getValueAt(Checkpoint[] storage checkpoints, uint _block
    ) constant internal returns (uint) {
        if (checkpoints.length == 0) return 0;

        // Shortcut for the actual value
        if (_block >= checkpoints[checkpoints.length-1].fromBlock)
            return checkpoints[checkpoints.length-1].value;
        if (_block < checkpoints[0].fromBlock) return 0;

        // Binary search of the value in the array
        uint min = 0;
        uint max = checkpoints.length-1;
        while (max > min) {
            uint mid = (max + min + 1)/ 2;
            if (checkpoints[mid].fromBlock<=_block) {
                min = mid;
            } else {
                max = mid-1;
            }
        }
        return checkpoints[min].value;
    }

    /// @dev `updateValueAtNow` used to update the `balances` map and the
    ///  `totalSupplyHistory`
    /// @param checkpoints The history of data being updated
    /// @param _value The new number of tokens
    function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
    ) internal  {
        if ((checkpoints.length == 0)
        || (checkpoints[checkpoints.length -1].fromBlock < getBlockNumber())) {
               Checkpoint newCheckPoint = checkpoints[ checkpoints.length++ ];
               newCheckPoint.fromBlock =  uint128(getBlockNumber());
               newCheckPoint.value = uint128(_value);
           } else {
               Checkpoint oldCheckPoint = checkpoints[checkpoints.length-1];
               oldCheckPoint.value = uint128(_value);
           }
    }

    /// @dev Internal function to determine if an address is a contract
    /// @param _addr The address being queried
    /// @return True if `_addr` is a contract
    function isContract(address _addr) constant internal returns(bool) {
        uint size;
        if (_addr == 0) return false;
        assembly {
            size := extcodesize(_addr)
        }
        return size>0;
    }

    /// @dev Helper function to return a min betwen the two uints
    function min(uint a, uint b) internal returns (uint) {
        return a < b ? a : b;
    }

    /// @notice The fallback function: If the contract's controller has not been
    ///  set to 0, then the `proxyPayment` method is called which relays the
    ///  ether and creates tokens as described in the token controller contract
    function ()  payable {
        if (isContract(controller)) {
            if (! TokenController(controller).proxyPayment.value(msg.value)(msg.sender))
                throw;
        } else {
            throw;
        }
    }


//////////
// Testing specific methods
//////////

    /// @notice This function is overridden by the test Mocks.
    function getBlockNumber() internal constant returns (uint256) {
        return block.number;
    }

//////////
// Safety Methods
//////////

    /// @notice This method can be used by the controller to extract mistakenly
    ///  sent tokens to this contract.
    /// @param _token The address of the token contract that you want to recover
    ///  set to 0 in case you want to extract ether.
    function claimTokens(address _token) onlyController {
        if (_token == 0x0) {
            controller.transfer(this.balance);
            return;
        }

        ERC20Token token = ERC20Token(_token);
        uint balance = token.balanceOf(this);
        token.transfer(controller, balance);
        ClaimedTokens(_token, controller, balance);
    }

////////////////
// Events
////////////////

    event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
    event Transfer(address indexed _from, address indexed _to, uint256 _amount);
    event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
    event Approval(
        address indexed _owner,
        address indexed _spender,
        uint256 _amount
        );

}


////////////////
// MiniMeTokenFactory
////////////////

/// @dev This contract is used to generate clone contracts from a contract.
///  In solidity this is the way to create a contract from a contract of the
///  same class
contract MiniMeTokenFactory {

    /// @notice Update the DApp by creating a new token with new functionalities
    ///  the msg.sender becomes the controller of this clone token
    /// @param _parentToken Address of the token being cloned
    /// @param _snapshotBlock Block of the parent token that will
    ///  determine the initial distribution of the clone token
    /// @param _tokenName Name of the new token
    /// @param _decimalUnits Number of decimals of the new token
    /// @param _tokenSymbol Token Symbol for the new token
    /// @param _transfersEnabled If true, tokens will be able to be transferred
    /// @return The address of the new token contract
    function createCloneToken(
        address _parentToken,
        uint _snapshotBlock,
        string _tokenName,
        uint8 _decimalUnits,
        string _tokenSymbol,
        bool _transfersEnabled
    ) returns (MiniMeToken) {
        MiniMeToken newToken = new MiniMeToken(
            this,
            _parentToken,
            _snapshotBlock,
            _tokenName,
            _decimalUnits,
            _tokenSymbol,
            _transfersEnabled
            );

        newToken.changeController(msg.sender);
        return newToken;
    }
}


================================================
FILE: contracts/MultiSigWallet.sol
================================================
pragma solidity ^0.4.11;


/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
/// @author Stefan George - <stefan.george@consensys.net>
contract MultiSigWallet {

    uint constant public MAX_OWNER_COUNT = 50;

    event Confirmation(address indexed _sender, uint indexed _transactionId);
    event Revocation(address indexed _sender, uint indexed _transactionId);
    event Submission(uint indexed _transactionId);
    event Execution(uint indexed _transactionId);
    event ExecutionFailure(uint indexed _transactionId);
    event Deposit(address indexed _sender, uint _value);
    event OwnerAddition(address indexed _owner);
    event OwnerRemoval(address indexed _owner);
    event RequirementChange(uint _required);

    mapping (uint => Transaction) public transactions;
    mapping (uint => mapping (address => bool)) public confirmations;
    mapping (address => bool) public isOwner;
    address[] public owners;
    uint public required;
    uint public transactionCount;

    struct Transaction {
        address destination;
        uint value;
        bytes data;
        bool executed;
    }

    modifier onlyWallet() {
        if (msg.sender != address(this))
            throw;
        _;
    }

    modifier ownerDoesNotExist(address owner) {
        if (isOwner[owner])
            throw;
        _;
    }

    modifier ownerExists(address owner) {
        if (!isOwner[owner])
            throw;
        _;
    }

    modifier transactionExists(uint transactionId) {
        if (transactions[transactionId].destination == 0)
            throw;
        _;
    }

    modifier confirmed(uint transactionId, address owner) {
        if (!confirmations[transactionId][owner])
            throw;
        _;
    }

    modifier notConfirmed(uint transactionId, address owner) {
        if (confirmations[transactionId][owner])
            throw;
        _;
    }

    modifier notExecuted(uint transactionId) {
        if (transactions[transactionId].executed)
            throw;
        _;
    }

    modifier notNull(address _address) {
        if (_address == 0)
            throw;
        _;
    }

    modifier validRequirement(uint ownerCount, uint _required) {
        if (   ownerCount > MAX_OWNER_COUNT
            || _required > ownerCount
            || _required == 0
            || ownerCount == 0)
            throw;
        _;
    }

    /// @dev Fallback function allows to deposit ether.
    function()
        payable
    {
        if (msg.value > 0)
            Deposit(msg.sender, msg.value);
    }

    /*
     * Public functions
     */
    /// @dev Contract constructor sets initial owners and required number of confirmations.
    /// @param _owners List of initial owners.
    /// @param _required Number of required confirmations.
    function MultiSigWallet(address[] _owners, uint _required)
        public
        validRequirement(_owners.length, _required)
    {
        for (uint i=0; i<_owners.length; i++) {
            if (isOwner[_owners[i]] || _owners[i] == 0)
                throw;
            isOwner[_owners[i]] = true;
        }
        owners = _owners;
        required = _required;
    }

    /// @dev Allows to add a new owner. Transaction has to be sent by wallet.
    /// @param owner Address of new owner.
    function addOwner(address owner)
        public
        onlyWallet
        ownerDoesNotExist(owner)
        notNull(owner)
        validRequirement(owners.length + 1, required)
    {
        isOwner[owner] = true;
        owners.push(owner);
        OwnerAddition(owner);
    }

    /// @dev Allows to remove an owner. Transaction has to be sent by wallet.
    /// @param owner Address of owner.
    function removeOwner(address owner)
        public
        onlyWallet
        ownerExists(owner)
    {
        isOwner[owner] = false;
        for (uint i=0; i<owners.length - 1; i++)
            if (owners[i] == owner) {
                owners[i] = owners[owners.length - 1];
                break;
            }
        owners.length -= 1;
        if (required > owners.length)
            changeRequirement(owners.length);
        OwnerRemoval(owner);
    }

    /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
    /// @param owner Address of owner to be replaced.
    /// @param owner Address of new owner.
    function replaceOwner(address owner, address newOwner)
        public
        onlyWallet
        ownerExists(owner)
        ownerDoesNotExist(newOwner)
    {
        for (uint i=0; i<owners.length; i++)
            if (owners[i] == owner) {
                owners[i] = newOwner;
                break;
            }
        isOwner[owner] = false;
        isOwner[newOwner] = true;
        OwnerRemoval(owner);
        OwnerAddition(newOwner);
    }

    /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
    /// @param _required Number of required confirmations.
    function changeRequirement(uint _required)
        public
        onlyWallet
        validRequirement(owners.length, _required)
    {
        required = _required;
        RequirementChange(_required);
    }

    /// @dev Allows an owner to submit and confirm a transaction.
    /// @param destination Transaction target address.
    /// @param value Transaction ether value.
    /// @param data Transaction data payload.
    /// @return Returns transaction ID.
    function submitTransaction(address destination, uint value, bytes data)
        public
        returns (uint transactionId)
    {
        transactionId = addTransaction(destination, value, data);
        confirmTransaction(transactionId);
    }

    /// @dev Allows an owner to confirm a transaction.
    /// @param transactionId Transaction ID.
    function confirmTransaction(uint transactionId)
        public
        ownerExists(msg.sender)
        transactionExists(transactionId)
        notConfirmed(transactionId, msg.sender)
    {
        confirmations[transactionId][msg.sender] = true;
        Confirmation(msg.sender, transactionId);
        executeTransaction(transactionId);
    }

    /// @dev Allows an owner to revoke a confirmation for a transaction.
    /// @param transactionId Transaction ID.
    function revokeConfirmation(uint transactionId)
        public
        ownerExists(msg.sender)
        confirmed(transactionId, msg.sender)
        notExecuted(transactionId)
    {
        confirmations[transactionId][msg.sender] = false;
        Revocation(msg.sender, transactionId);
    }

    /// @dev Allows anyone to execute a confirmed transaction.
    /// @param transactionId Transaction ID.
    function executeTransaction(uint transactionId)
        public
        notExecuted(transactionId)
    {
        if (isConfirmed(transactionId)) {
            Transaction tx = transactions[transactionId];
            tx.executed = true;
            if (tx.destination.call.value(tx.value)(tx.data))
                Execution(transactionId);
            else {
                ExecutionFailure(transactionId);
                tx.executed = false;
            }
        }
    }

    /// @dev Returns the confirmation status of a transaction.
    /// @param transactionId Transaction ID.
    /// @return Confirmation status.
    function isConfirmed(uint transactionId)
        public
        constant
        returns (bool)
    {
        uint count = 0;
        for (uint i=0; i<owners.length; i++) {
            if (confirmations[transactionId][owners[i]])
                count += 1;
            if (count == required)
                return true;
        }
    }

    /*
     * Internal functions
     */
    /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
    /// @param destination Transaction target address.
    /// @param value Transaction ether value.
    /// @param data Transaction data payload.
    /// @return Returns transaction ID.
    function addTransaction(address destination, uint value, bytes data)
        internal
        notNull(destination)
        returns (uint transactionId)
    {
        transactionId = transactionCount;
        transactions[transactionId] = Transaction({
            destination: destination,
            value: value,
            data: data,
            executed: false
        });
        transactionCount += 1;
        Submission(transactionId);
    }

    /*
     * Web3 call functions
     */
    /// @dev Returns number of confirmations of a transaction.
    /// @param transactionId Transaction ID.
    /// @return Number of confirmations.
    function getConfirmationCount(uint transactionId)
        public
        constant
        returns (uint count)
    {
        for (uint i=0; i<owners.length; i++)
            if (confirmations[transactionId][owners[i]])
                count += 1;
    }

    /// @dev Returns total number of transactions after filters are applied.
    /// @param pending Include pending transactions.
    /// @param executed Include executed transactions.
    /// @return Total number of transactions after filters are applied.
    function getTransactionCount(bool pending, bool executed)
        public
        constant
        returns (uint count)
    {
        for (uint i=0; i<transactionCount; i++)
            if (   pending && !transactions[i].executed
                || executed && transactions[i].executed)
                count += 1;
    }

    /// @dev Returns list of owners.
    /// @return List of owner addresses.
    function getOwners()
        public
        constant
        returns (address[])
    {
        return owners;
    }

    /// @dev Returns array with owner addresses, which confirmed transaction.
    /// @param transactionId Transaction ID.
    /// @return Returns array of owner addresses.
    function getConfirmations(uint transactionId)
        public
        constant
        returns (address[] _confirmations)
    {
        address[] memory confirmationsTemp = new address[](owners.length);
        uint count = 0;
        uint i;
        for (i=0; i<owners.length; i++)
            if (confirmations[transactionId][owners[i]]) {
                confirmationsTemp[count] = owners[i];
                count += 1;
            }
        _confirmations = new address[](count);
        for (i=0; i<count; i++)
            _confirmations[i] = confirmationsTemp[i];
    }

    /// @dev Returns list of transaction IDs in defined range.
    /// @param from Index start position of transaction array.
    /// @param to Index end position of transaction array.
    /// @param pending Include pending transactions.
    /// @param executed Include executed transactions.
    /// @return Returns array of transaction IDs.
    function getTransactionIds(uint from, uint to, bool pending, bool executed)
        public
        constant
        returns (uint[] _transactionIds)
    {
        uint[] memory transactionIdsTemp = new uint[](transactionCount);
        uint count = 0;
        uint i;
        for (i=0; i<transactionCount; i++)
            if (   pending && !transactions[i].executed
                || executed && transactions[i].executed)
            {
                transactionIdsTemp[count] = i;
                count += 1;
            }
        _transactionIds = new uint[](to - from);
        for (i=from; i<to; i++)
            _transactionIds[i - from] = transactionIdsTemp[i];
    }
}


================================================
FILE: contracts/Owned.sol
================================================
pragma solidity ^0.4.11;


/// @dev `Owned` is a base level contract that assigns an `owner` that can be
///  later changed
contract Owned {

    /// @dev `owner` is the only address that can call a function with this
    /// modifier
    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }

    address public owner;

    /// @notice The Constructor assigns the message sender to be `owner`
    function Owned() {
        owner = msg.sender;
    }

    address public newOwner;

    /// @notice `owner` can step down and assign some other address to this role
    /// @param _newOwner The address of the new owner. 0x0 can be used to create
    ///  an unowned neutral vault, however that cannot be undone
    function changeOwner(address _newOwner) onlyOwner {
        newOwner = _newOwner;
    }


    function acceptOwnership() {
        if (msg.sender == newOwner) {
            owner = newOwner;
        }
    }
}


================================================
FILE: contracts/SGT.sol
================================================
pragma solidity ^0.4.11;

/*
    Copyright 2017, Jarrad Hope (Status Research & Development GmbH)
*/


import "./MiniMeToken.sol";


contract SGT is MiniMeToken {

    uint256 constant D160 = 0x0010000000000000000000000000000000000000000;

    function SGT(address _tokenFactory)
            MiniMeToken(
                _tokenFactory,
                0x0,                     // no parent token
                0,                       // no snapshot block number from parent
                "Status Genesis Token",  // Token name
                1,                       // Decimals
                "SGT",                   // Symbol
                false                    // Enable transfers
            ) {}

    // data is an array of uint256s. Each uint256 represents a transfer.
    // The 160 LSB is the destination of the address that wants to be sent
    // The 96 MSB is the amount of tokens that wants to be sent.
    function multiMint(uint256[] data) public onlyController {
        for (uint256 i = 0; i < data.length; i++) {
            address addr = address(data[i] & (D160 - 1));
            uint256 amount = data[i] / D160;

            assert(generateTokens(addr, amount));
        }
    }

}


================================================
FILE: contracts/SGTExchanger.sol
================================================
pragma solidity ^0.4.11;

/*
    Copyright 2017, Jordi Baylina

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/// @title SGTExchanger Contract
/// @author Jordi Baylina
/// @dev This contract will be used to distribute SNT between SGT holders.
///  SGT token is not transferable, and we just keep an accounting between all tokens
///  deposited and the tokens collected.
///  The controllerShip of SGT should be transferred to this contract before the
///  contribution period starts.


import "./MiniMeToken.sol";
import "./SafeMath.sol";
import "./Owned.sol";
import "./StatusContribution.sol";
import "./ERC20Token.sol";

contract SGTExchanger is TokenController, Owned {
    using SafeMath for uint256;

    mapping (address => uint256) public collected;
    uint256 public totalCollected;
    MiniMeToken public sgt;
    MiniMeToken public snt;
    StatusContribution public statusContribution;

    function SGTExchanger(address _sgt, address _snt, address _statusContribution) {
        sgt = MiniMeToken(_sgt);
        snt = MiniMeToken(_snt);
        statusContribution = StatusContribution(_statusContribution);
    }

    /// @notice This method should be called by the SGT holders to collect their
    ///  corresponding SNTs
    function collect() public {
        uint256 finalizedBlock = statusContribution.finalizedBlock();

        require(finalizedBlock != 0);
        require(getBlockNumber() > finalizedBlock);

        uint256 total = totalCollected.add(snt.balanceOf(address(this)));

        uint256 balance = sgt.balanceOfAt(msg.sender, finalizedBlock);

        // First calculate how much correspond to him
        uint256 amount = total.mul(balance).div(sgt.totalSupplyAt(finalizedBlock));

        // And then subtract the amount already collected
        amount = amount.sub(collected[msg.sender]);

        require(amount > 0);  // Notify the user that there are no tokens to exchange

        totalCollected = totalCollected.add(amount);
        collected[msg.sender] = collected[msg.sender].add(amount);

        assert(snt.transfer(msg.sender, amount));

        TokensCollected(msg.sender, amount);
    }

    function proxyPayment(address) public payable returns (bool) {
        throw;
    }

    function onTransfer(address, address, uint256) public returns (bool) {
        return false;
    }

    function onApprove(address, address, uint256) public returns (bool) {
        return false;
    }

    //////////
    // Testing specific methods
    //////////

    /// @notice This function is overridden by the test Mocks.
    function getBlockNumber() internal constant returns (uint256) {
        return block.number;
    }

    //////////
    // Safety Method
    //////////

    /// @notice This method can be used by the controller to extract mistakenly
    ///  sent tokens to this contract.
    /// @param _token The address of the token contract that you want to recover
    ///  set to 0 in case you want to extract ether.
    function claimTokens(address _token) public onlyOwner {
        require(_token != address(snt));
        if (_token == 0x0) {
            owner.transfer(this.balance);
            return;
        }

        ERC20Token token = ERC20Token(_token);
        uint256 balance = token.balanceOf(this);
        token.transfer(owner, balance);
        ClaimedTokens(_token, owner, balance);
    }

    event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount);
    event TokensCollected(address indexed _holder, uint256 _amount);

}


================================================
FILE: contracts/SNT.sol
================================================
pragma solidity ^0.4.11;

/*
    Copyright 2017, Jarrad Hope (Status Research & Development GmbH)
*/


import "./MiniMeToken.sol";


contract SNT is MiniMeToken {
    // @dev SNT constructor just parametrizes the MiniMeIrrevocableVestedToken constructor
    function SNT(address _tokenFactory)
            MiniMeToken(
                _tokenFactory,
                0x0,                     // no parent token
                0,                       // no snapshot block number from parent
                "Status Network Token",  // Token name
                18,                      // Decimals
                "SNT",                   // Symbol
                true                     // Enable transfers
            ) {}
}


================================================
FILE: contracts/SNTPlaceHolder.sol
================================================
pragma solidity ^0.4.11;

/*
    Copyright 2017, Jordi Baylina

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/// @title SNTPlaceholder Contract
/// @author Jordi Baylina
/// @dev The SNTPlaceholder contract will take control over the SNT after the contribution
///  is finalized and before the Status Network is deployed.
///  The contract allows for SNT transfers and transferFrom and implements the
///  logic for transferring control of the token to the network when the offering
///  asks it to do so.


import "./MiniMeToken.sol";
import "./StatusContribution.sol";
import "./SafeMath.sol";
import "./Owned.sol";
import "./ERC20Token.sol";


contract SNTPlaceHolder is TokenController, Owned {
    using SafeMath for uint256;

    MiniMeToken public snt;
    StatusContribution public contribution;
    uint256 public activationTime;
    address public sgtExchanger;

    /// @notice Constructor
    /// @param _owner Trusted owner for this contract.
    /// @param _snt SNT token contract address
    /// @param _contribution StatusContribution contract address
    /// @param _sgtExchanger SGT-SNT Exchange address. (During the first week
    ///  only this exchanger will be able to move tokens)
    function SNTPlaceHolder(address _owner, address _snt, address _contribution, address _sgtExchanger) {
        owner = _owner;
        snt = MiniMeToken(_snt);
        contribution = StatusContribution(_contribution);
        sgtExchanger = _sgtExchanger;
    }

    /// @notice The owner of this contract can change the controller of the SNT token
    ///  Please, be sure that the owner is a trusted agent or 0x0 address.
    /// @param _newController The address of the new controller

    function changeController(address _newController) public onlyOwner {
        snt.changeController(_newController);
        ControllerChanged(_newController);
    }


    //////////
    // MiniMe Controller Interface functions
    //////////

    // In between the offering and the network. Default settings for allowing token transfers.
    function proxyPayment(address) public payable returns (bool) {
        return false;
    }

    function onTransfer(address _from, address, uint256) public returns (bool) {
        return transferable(_from);
    }

    function onApprove(address _from, address, uint256) public returns (bool) {
        return transferable(_from);
    }

    function transferable(address _from) internal returns (bool) {
        // Allow the exchanger to work from the beginning
        if (activationTime == 0) {
            uint256 f = contribution.finalizedTime();
            if (f > 0) {
                activationTime = f.add(1 weeks);
            } else {
                return false;
            }
        }
        return (getTime() > activationTime) || (_from == sgtExchanger);
    }


    //////////
    // Testing specific methods
    //////////

    /// @notice This function is overrided by the test Mocks.
    function getTime() internal returns (uint256) {
        return now;
    }


    //////////
    // Safety Methods
    //////////

    /// @notice This method can be used by the controller to extract mistakenly
    ///  sent tokens to this contract.
    /// @param _token The address of the token contract that you want to recover
    ///  set to 0 in case you want to extract ether.
    function claimTokens(address _token) public onlyOwner {
        if (snt.controller() == address(this)) {
            snt.claimTokens(_token);
        }
        if (_token == 0x0) {
            owner.transfer(this.balance);
            return;
        }

        ERC20Token token = ERC20Token(_token);
        uint256 balance = token.balanceOf(this);
        token.transfer(owner, balance);
        ClaimedTokens(_token, owner, balance);
    }

    event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount);
    event ControllerChanged(address indexed _newController);
}


================================================
FILE: contracts/SafeMath.sol
================================================
pragma solidity ^0.4.11;


/**
 * Math operations with safety checks
 */
library SafeMath {
  function mul(uint a, uint b) internal returns (uint) {
    uint c = a * b;
    assert(a == 0 || c / a == b);
    return c;
  }

  function div(uint a, uint b) internal returns (uint) {
    // assert(b > 0); // Solidity automatically throws when dividing by 0
    uint c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return c;
  }

  function sub(uint a, uint b) internal returns (uint) {
    assert(b <= a);
    return a - b;
  }

  function add(uint a, uint b) internal returns (uint) {
    uint c = a + b;
    assert(c >= a);
    return c;
  }

  function max64(uint64 a, uint64 b) internal constant returns (uint64) {
    return a >= b ? a : b;
  }

  function min64(uint64 a, uint64 b) internal constant returns (uint64) {
    return a < b ? a : b;
  }

  function max256(uint256 a, uint256 b) internal constant returns (uint256) {
    return a >= b ? a : b;
  }

  function min256(uint256 a, uint256 b) internal constant returns (uint256) {
    return a < b ? a : b;
  }
}


================================================
FILE: contracts/StatusContribution.sol
================================================
pragma solidity ^0.4.11;

/*
    Copyright 2017, Jordi Baylina

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/// @title StatusContribution Contract
/// @author Jordi Baylina
/// @dev This contract will be the SNT controller during the contribution period.
///  This contract will determine the rules during this period.
///  Final users will generally not interact directly with this contract. ETH will
///  be sent to the SNT token contract. The ETH is sent to this contract and from here,
///  ETH is sent to the contribution walled and SNTs are mined according to the defined
///  rules.


import "./Owned.sol";
import "./MiniMeToken.sol";
import "./DynamicCeiling.sol";
import "./SafeMath.sol";
import "./ERC20Token.sol";


contract StatusContribution is Owned, TokenController {
    using SafeMath for uint256;

    uint256 constant public failSafeLimit = 300000 ether;
    uint256 constant public maxGuaranteedLimit = 30000 ether;
    uint256 constant public exchangeRate = 10000;
    uint256 constant public maxGasPrice = 50000000000;
    uint256 constant public maxCallFrequency = 100;

    MiniMeToken public SGT;
    MiniMeToken public SNT;
    uint256 public startBlock;
    uint256 public endBlock;

    address public destEthDevs;

    address public destTokensDevs;
    address public destTokensReserve;
    uint256 public maxSGTSupply;
    address public destTokensSgt;
    DynamicCeiling public dynamicCeiling;

    address public sntController;

    mapping (address => uint256) public guaranteedBuyersLimit;
    mapping (address => uint256) public guaranteedBuyersBought;

    uint256 public totalGuaranteedCollected;
    uint256 public totalNormalCollected;

    uint256 public finalizedBlock;
    uint256 public finalizedTime;

    mapping (address => uint256) public lastCallBlock;

    bool public paused;

    modifier initialized() {
        require(address(SNT) != 0x0);
        _;
    }

    modifier contributionOpen() {
        require(getBlockNumber() >= startBlock &&
                getBlockNumber() <= endBlock &&
                finalizedBlock == 0 &&
                address(SNT) != 0x0);
        _;
    }

    modifier notPaused() {
        require(!paused);
        _;
    }

    function StatusContribution() {
        paused = false;
    }


    /// @notice This method should be called by the owner before the contribution
    ///  period starts This initializes most of the parameters
    /// @param _snt Address of the SNT token contract
    /// @param _sntController Token controller for the SNT that will be transferred after
    ///  the contribution finalizes.
    /// @param _startBlock Block when the contribution period starts
    /// @param _endBlock The last block that the contribution period is active
    /// @param _dynamicCeiling Address of the contract that controls the ceiling
    /// @param _destEthDevs Destination address where the contribution ether is sent
    /// @param _destTokensReserve Address where the tokens for the reserve are sent
    /// @param _destTokensSgt Address of the exchanger SGT-SNT where the SNT are sent
    ///  to be distributed to the SGT holders.
    /// @param _destTokensDevs Address where the tokens for the dev are sent
    /// @param _sgt Address of the SGT token contract
    /// @param _maxSGTSupply Quantity of SGT tokens that would represent 10% of status.
    function initialize(
        address _snt,
        address _sntController,

        uint256 _startBlock,
        uint256 _endBlock,

        address _dynamicCeiling,

        address _destEthDevs,

        address _destTokensReserve,
        address _destTokensSgt,
        address _destTokensDevs,

        address _sgt,
        uint256 _maxSGTSupply
    ) public onlyOwner {
        // Initialize only once
        require(address(SNT) == 0x0);

        SNT = MiniMeToken(_snt);
        require(SNT.totalSupply() == 0);
        require(SNT.controller() == address(this));
        require(SNT.decimals() == 18);  // Same amount of decimals as ETH

        require(_sntController != 0x0);
        sntController = _sntController;

        require(_startBlock >= getBlockNumber());
        require(_startBlock < _endBlock);
        startBlock = _startBlock;
        endBlock = _endBlock;

        require(_dynamicCeiling != 0x0);
        dynamicCeiling = DynamicCeiling(_dynamicCeiling);

        require(_destEthDevs != 0x0);
        destEthDevs = _destEthDevs;

        require(_destTokensReserve != 0x0);
        destTokensReserve = _destTokensReserve;

        require(_destTokensSgt != 0x0);
        destTokensSgt = _destTokensSgt;

        require(_destTokensDevs != 0x0);
        destTokensDevs = _destTokensDevs;

        require(_sgt != 0x0);
        SGT = MiniMeToken(_sgt);

        require(_maxSGTSupply >= MiniMeToken(SGT).totalSupply());
        maxSGTSupply = _maxSGTSupply;
    }

    /// @notice Sets the limit for a guaranteed address. All the guaranteed addresses
    ///  will be able to get SNTs during the contribution period with his own
    ///  specific limit.
    ///  This method should be called by the owner after the initialization
    ///  and before the contribution starts.
    /// @param _th Guaranteed address
    /// @param _limit Limit for the guaranteed address.
    function setGuaranteedAddress(address _th, uint256 _limit) public initialized onlyOwner {
        require(getBlockNumber() < startBlock);
        require(_limit > 0 && _limit <= maxGuaranteedLimit);
        guaranteedBuyersLimit[_th] = _limit;
        GuaranteedAddress(_th, _limit);
    }

    /// @notice If anybody sends Ether directly to this contract, consider he is
    ///  getting SNTs.
    function () public payable notPaused {
        proxyPayment(msg.sender);
    }


    //////////
    // MiniMe Controller functions
    //////////

    /// @notice This method will generally be called by the SNT token contract to
    ///  acquire SNTs. Or directly from third parties that want to acquire SNTs in
    ///  behalf of a token holder.
    /// @param _th SNT holder where the SNTs will be minted.
    function proxyPayment(address _th) public payable notPaused initialized contributionOpen returns (bool) {
        require(_th != 0x0);
        if (guaranteedBuyersLimit[_th] > 0) {
            buyGuaranteed(_th);
        } else {
            buyNormal(_th);
        }
        return true;
    }

    function onTransfer(address, address, uint256) public returns (bool) {
        return false;
    }

    function onApprove(address, address, uint256) public returns (bool) {
        return false;
    }

    function buyNormal(address _th) internal {
        require(tx.gasprice <= maxGasPrice);

        // Antispam mechanism
        address caller;
        if (msg.sender == address(SNT)) {
            caller = _th;
        } else {
            caller = msg.sender;
        }

        // Do not allow contracts to game the system
        require(!isContract(caller));

        require(getBlockNumber().sub(lastCallBlock[caller]) >= maxCallFrequency);
        lastCallBlock[caller] = getBlockNumber();

        uint256 toCollect = dynamicCeiling.toCollect(totalNormalCollected);

        uint256 toFund;
        if (msg.value <= toCollect) {
            toFund = msg.value;
        } else {
            toFund = toCollect;
        }

        totalNormalCollected = totalNormalCollected.add(toFund);
        doBuy(_th, toFund, false);
    }

    function buyGuaranteed(address _th) internal {
        uint256 toCollect = guaranteedBuyersLimit[_th];

        uint256 toFund;
        if (guaranteedBuyersBought[_th].add(msg.value) > toCollect) {
            toFund = toCollect.sub(guaranteedBuyersBought[_th]);
        } else {
            toFund = msg.value;
        }

        guaranteedBuyersBought[_th] = guaranteedBuyersBought[_th].add(toFund);
        totalGuaranteedCollected = totalGuaranteedCollected.add(toFund);
        doBuy(_th, toFund, true);
    }

    function doBuy(address _th, uint256 _toFund, bool _guaranteed) internal {
        assert(msg.value >= _toFund);  // Not needed, but double check.
        assert(totalCollected() <= failSafeLimit);

        if (_toFund > 0) {
            uint256 tokensGenerated = _toFund.mul(exchangeRate);
            assert(SNT.generateTokens(_th, tokensGenerated));
            destEthDevs.transfer(_toFund);
            NewSale(_th, _toFund, tokensGenerated, _guaranteed);
        }

        uint256 toReturn = msg.value.sub(_toFund);
        if (toReturn > 0) {
            // If the call comes from the Token controller,
            // then we return it to the token Holder.
            // Otherwise we return to the sender.
            if (msg.sender == address(SNT)) {
                _th.transfer(toReturn);
            } else {
                msg.sender.transfer(toReturn);
            }
        }
    }

    // NOTE on Percentage format
    // Right now, Solidity does not support decimal numbers. (This will change very soon)
    //  So in this contract we use a representation of a percentage that consist in
    //  expressing the percentage in "x per 10**18"
    // This format has a precision of 16 digits for a percent.
    // Examples:
    //  3%   =   3*(10**16)
    //  100% = 100*(10**16) = 10**18
    //
    // To get a percentage of a value we do it by first multiplying it by the percentage in  (x per 10^18)
    //  and then divide it by 10**18
    //
    //              Y * X(in x per 10**18)
    //  X% of Y = -------------------------
    //               100(in x per 10**18)
    //


    /// @notice This method will can be called by the owner before the contribution period
    ///  end or by anybody after the `endBlock`. This method finalizes the contribution period
    ///  by creating the remaining tokens and transferring the controller to the configured
    ///  controller.
    function finalize() public initialized {
        require(getBlockNumber() >= startBlock);
        require(msg.sender == owner || getBlockNumber() > endBlock);
        require(finalizedBlock == 0);

        // Do not allow termination until all curves revealed.
        require(dynamicCeiling.allRevealed());

        // Allow premature finalization if final limit is reached
        if (getBlockNumber() <= endBlock) {
            var (,lastLimit,,) = dynamicCeiling.curves(dynamicCeiling.revealedCurves().sub(1));
            require(totalNormalCollected >= lastLimit);
        }

        finalizedBlock = getBlockNumber();
        finalizedTime = now;

        uint256 percentageToSgt;
        if (SGT.totalSupply() >= maxSGTSupply) {
            percentageToSgt = percent(10);  // 10%
        } else {

            //
            //                           SGT.totalSupply()
            //  percentageToSgt = 10% * -------------------
            //                             maxSGTSupply
            //
            percentageToSgt = percent(10).mul(SGT.totalSupply()).div(maxSGTSupply);
        }

        uint256 percentageToDevs = percent(20);  // 20%


        //
        //  % To Contributors = 41% + (10% - % to SGT holders)
        //
        uint256 percentageToContributors = percent(41).add(percent(10).sub(percentageToSgt));

        uint256 percentageToReserve = percent(29);


        // SNT.totalSupply() -> Tokens minted during the contribution
        //  totalTokens  -> Total tokens that should be after the allocation
        //                   of devTokens, sgtTokens and reserve
        //  percentageToContributors -> Which percentage should go to the
        //                               contribution participants
        //                               (x per 10**18 format)
        //  percent(100) -> 100% in (x per 10**18 format)
        //
        //                       percentageToContributors
        //  SNT.totalSupply() = -------------------------- * totalTokens  =>
        //                             percent(100)
        //
        //
        //                            percent(100)
        //  =>  totalTokens = ---------------------------- * SNT.totalSupply()
        //                      percentageToContributors
        //
        uint256 totalTokens = SNT.totalSupply().mul(percent(100)).div(percentageToContributors);


        // Generate tokens for SGT Holders.

        //
        //                    percentageToReserve
        //  reserveTokens = ----------------------- * totalTokens
        //                      percentage(100)
        //
        assert(SNT.generateTokens(
            destTokensReserve,
            totalTokens.mul(percentageToReserve).div(percent(100))));

        //
        //                  percentageToSgt
        //  sgtTokens = ----------------------- * totalTokens
        //                   percentage(100)
        //
        assert(SNT.generateTokens(
            destTokensSgt,
            totalTokens.mul(percentageToSgt).div(percent(100))));


        //
        //                   percentageToDevs
        //  devTokens = ----------------------- * totalTokens
        //                   percentage(100)
        //
        assert(SNT.generateTokens(
            destTokensDevs,
            totalTokens.mul(percentageToDevs).div(percent(100))));

        SNT.changeController(sntController);

        Finalized();
    }

    function percent(uint256 p) internal returns (uint256) {
        return p.mul(10**16);
    }

    /// @dev Internal function to determine if an address is a contract
    /// @param _addr The address being queried
    /// @return True if `_addr` is a contract
    function isContract(address _addr) constant internal returns (bool) {
        if (_addr == 0) return false;
        uint256 size;
        assembly {
            size := extcodesize(_addr)
        }
        return (size > 0);
    }


    //////////
    // Constant functions
    //////////

    /// @return Total tokens issued in weis.
    function tokensIssued() public constant returns (uint256) {
        return SNT.totalSupply();
    }

    /// @return Total Ether collected.
    function totalCollected() public constant returns (uint256) {
        return totalNormalCollected.add(totalGuaranteedCollected);
    }


    //////////
    // Testing specific methods
    //////////

    /// @notice This function is overridden by the test Mocks.
    function getBlockNumber() internal constant returns (uint256) {
        return block.number;
    }


    //////////
    // Safety Methods
    //////////

    /// @notice This method can be used by the controller to extract mistakenly
    ///  sent tokens to this contract.
    /// @param _token The address of the token contract that you want to recover
    ///  set to 0 in case you want to extract ether.
    function claimTokens(address _token) public onlyOwner {
        if (SNT.controller() == address(this)) {
            SNT.claimTokens(_token);
        }
        if (_token == 0x0) {
            owner.transfer(this.balance);
            return;
        }

        ERC20Token token = ERC20Token(_token);
        uint256 balance = token.balanceOf(this);
        token.transfer(owner, balance);
        ClaimedTokens(_token, owner, balance);
    }


    /// @notice Pauses the contribution if there is any issue
    function pauseContribution() onlyOwner {
        paused = true;
    }

    /// @notice Resumes the contribution
    function resumeContribution() onlyOwner {
        paused = false;
    }

    event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount);
    event NewSale(address indexed _th, uint256 _amount, uint256 _tokens, bool _guaranteed);
    event GuaranteedAddress(address indexed _th, uint256 _limit);
    event Finalized();
}


================================================
FILE: contracts/test/DevTokensHolderMock.sol
================================================
pragma solidity ^0.4.11;

import '../DevTokensHolder.sol';

// @dev DevTokensHolderMock mocks current block number

contract DevTokensHolderMock is DevTokensHolder {

    uint mock_time;

    function DevTokensHolderMock(address _owner, address _contribution, address _snt)
    DevTokensHolder(_owner, _contribution, _snt) {
        mock_time = now;
    }

    function getTime() internal returns (uint) {
        return mock_time;
    }

    function setMockedTime(uint _t) {
        mock_time = _t;
    }
}


================================================
FILE: contracts/test/ExternalToken.sol
================================================
pragma solidity ^0.4.11;

import "../MiniMeToken.sol";

contract ExternalToken is MiniMeToken {

    function ExternalToken(address _tokenFactory)
            MiniMeToken(
                _tokenFactory,
                0x0,                           // no parent token
                0,                             // no snapshot block number from parent
                "External Token for testing",  // Token name
                1,                             // Decimals
                "EXT",                         // Symbol
                true                           // Enable transfers
            ) {}
}


================================================
FILE: contracts/test/Migrations.sol
================================================
pragma solidity ^0.4.11;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

  modifier restricted() {
    if (msg.sender == owner) _;
  }

  function Migrations() {
    owner = msg.sender;
  }

  function setCompleted(uint completed) restricted {
    last_completed_migration = completed;
  }

  function upgrade(address new_address) restricted {
    Migrations upgraded = Migrations(new_address);
    upgraded.setCompleted(last_completed_migration);
  }
}


================================================
FILE: contracts/test/SGTExchangerMock.sol
================================================
pragma solidity ^0.4.11;

import '../SGTExchanger.sol';

// @dev SGTExchangerMock mocks current block number

contract SGTExchangerMock is SGTExchanger {

    function SGTExchangerMock(address _sgt, address _snt, address _statusContribution)
        SGTExchanger(_sgt,  _snt, _statusContribution) {}

    function getBlockNumber() internal constant returns (uint) {
        return mock_blockNumber;
    }

    function setMockedBlockNumber(uint _b) public {
        mock_blockNumber = _b;
    }

    uint public mock_blockNumber = 1;
}


================================================
FILE: contracts/test/SGTMock.sol
================================================
pragma solidity ^0.4.11;

import '../SGT.sol';

// @dev SGTMock mocks current block number

contract SGTMock is SGT {

    function SGTMock(address _tokenFactory) SGT(_tokenFactory) {}

    function getBlockNumber() internal constant returns (uint) {
        return mock_blockNumber;
    }

    function setMockedBlockNumber(uint _b) public {
        mock_blockNumber = _b;
    }

    uint mock_blockNumber = 1;
}


================================================
FILE: contracts/test/SNTMock.sol
================================================
pragma solidity ^0.4.11;

import '../SNT.sol';

// @dev SNTMock mocks current block number

contract SNTMock is SNT {

    function SNTMock(address _tokenFactory) SNT(_tokenFactory) {}

    function getBlockNumber() internal constant returns (uint) {
        return mock_blockNumber;
    }

    function setMockedBlockNumber(uint _b) public {
        mock_blockNumber = _b;
    }

    uint mock_blockNumber = 1;
}


================================================
FILE: contracts/test/SNTPlaceHolderMock.sol
================================================
pragma solidity ^0.4.11;

import '../SNTPlaceHolder.sol';

// @dev SNTPlaceHolderMock mocks current block number

contract SNTPlaceHolderMock is SNTPlaceHolder {

    uint mock_time;

    function SNTPlaceHolderMock(address _owner, address _snt, address _contribution, address _sgtExchanger)
            SNTPlaceHolder(_owner, _snt, _contribution, _sgtExchanger) {
        mock_time = now;
    }

    function getTime() internal returns (uint) {
        return mock_time;
    }

    function setMockedTime(uint _t) public {
        mock_time = _t;
    }
}


================================================
FILE: contracts/test/StatusContributionMock.sol
================================================
pragma solidity ^0.4.11;

import '../StatusContribution.sol';

// @dev StatusContributionMock mocks current block number

contract StatusContributionMock is StatusContribution {

    function StatusContributionMock() StatusContribution() {}

    function getBlockNumber() internal constant returns (uint) {
        return mock_blockNumber;
    }

    function setMockedBlockNumber(uint _b) public {
        mock_blockNumber = _b;
    }

    uint mock_blockNumber = 1;
}


================================================
FILE: migrations/1_initial_migration.js
================================================
var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {
    deployer.deploy(Migrations);
};


================================================
FILE: migrations/2_deploy_contracts.js
================================================
const randomBytes = require("random-bytes");

const MultiSigWallet = artifacts.require("MultiSigWallet");
const MiniMeTokenFactory = artifacts.require("MiniMeTokenFactory");
const SGT = artifacts.require("SGT");
const SNT = artifacts.require("SNT");
const StatusContribution= artifacts.require("StatusContribution");
const ContributionWallet = artifacts.require("ContributionWallet");
const DevTokensHolder = artifacts.require("DevTokensHolder");
const SGTExchanger = artifacts.require("SGTExchanger");
const DynamicCeiling = artifacts.require("DynamicCeiling");
const SNTPlaceHolder = artifacts.require("SNTPlaceHolder");


// Set hidden curves
const setHiddenCurves = async function(dynamicCeiling, curves, nHiddenCurves) {
    let hashes = [];
    let i = 0;
    for (let c of curves) {
        let salt = await randomBytes(32);
        console.log(`Curve ${i} has salt: ${salt.toString("hex")}`);
        let h = await dynamicCeiling.calculateHash(c[0], c[1], c[2], i === curves.length - 1, salt);
        hashes.push(h);
        i += 1;
    }
    for (; i < nHiddenCurves; i += 1) {
        let salt = randomBytes(32);
        hashes.push(web3.sha3(salt));
    }
    await dynamicCeiling.setHiddenCurves(hashes);
    console.log(`${i} curves set!`);
};


// All of these constants need to be configured before deploy
const addressOwner = "0xf93df8c288b9020e76583a6997362e89e0599e99";
const addressesStatus = [
    "0x2ca9d4d0fd9622b08de76c1d484e69a6311db765",
];
const multisigStatusReqs = 1
const addressesCommunity = [
    "0x166ddbcfe4d5849b0c62063747966a13706a4af7",
];
const multisigCommunityReqs = 1
const addressesReserve = [
    "0x4781fee94e7257ffb6e3a3dcc5f8571ddcc02109",
];
const multisigReserveReqs = 1
const addressesDevs = [
    "0xcee9f54a23324867d8537589ba8dc6c8a6e9d0b9",
];
const multisigDevsReqs = 1
const addressSGT = "";

const startBlock = 3800000;
const endBlock = 3900000;

const maxSGTSupply = 500000000;

const curves = [
    [web3.toWei(1000), 30, 10**12],
    [web3.toWei(21000), 30, 10**12],
    [web3.toWei(61000), 30, 10**12],
];
const nHiddenCurves = 7;


module.exports = async function(deployer, network, accounts) {
    if (network === "development") return;  // Don't deploy on tests

    // MultiSigWallet send
    let multisigStatusFuture = MultiSigWallet.new(addressesStatus, multisigStatusReqs);
    let multisigCommunityFuture = MultiSigWallet.new(addressesCommunity, multisigCommunityReqs);
    let multisigReserveFuture = MultiSigWallet.new(addressesReserve, multisigReserveReqs);
    let multisigDevsFuture = MultiSigWallet.new(addressesDevs, multisigDevsReqs);
    // MiniMeTokenFactory send
    let miniMeTokenFactoryFuture = MiniMeTokenFactory.new();

    // MultiSigWallet wait
    let multisigStatus = await multisigStatusFuture;
    console.log("\nMultiSigWallet Status: " + multisigStatus.address);
    let multisigCommunity = await multisigCommunityFuture;
    console.log("MultiSigWallet Community: " + multisigCommunity.address);
    let multisigReserve = await multisigReserveFuture;
    console.log("MultiSigWallet Reserve: " + multisigReserve.address);
    let multisigDevs = await multisigDevsFuture;
    console.log("MultiSigWallet Devs: " + multisigDevs.address);
    // MiniMeTokenFactory wait
    let miniMeTokenFactory = await miniMeTokenFactoryFuture;
    console.log("MiniMeTokenFactory: " + miniMeTokenFactory.address);
    console.log();

    // SGT send
    let sgtFuture;
    if (addressSGT.length === 0) {  // Testnet
        sgtFuture = SGT.new(miniMeTokenFactory.address);
    } else {
        sgtFuture = SGT.at(addressSGT);
    }
    // SNT send
    let sntFuture = SNT.new(miniMeTokenFactory.address);
    // StatusContribution send
    let statusContributionFuture = StatusContribution.new();

    // SGT wait
    let sgt = await sgtFuture;
    console.log("SGT: " + sgt.address);
    // SNT wait
    let snt = await sntFuture;
    console.log("SNT: " + snt.address);
    // StatusContribution wait
    let statusContribution = await statusContributionFuture;
    console.log("StatusContribution: " + statusContribution.address);
    console.log();

    // SNT initialize checkpoints for 0th TX gas savings
    await snt.generateTokens('0x0', 1);
    await snt.destroyTokens('0x0', 1);

    // SNT changeController send
    let sntChangeControllerFuture = snt.changeController(statusContribution.address);
    // ContributionWallet send
    let contributionWalletFuture = ContributionWallet.new(
        multisigStatus.address,
        endBlock,
        statusContribution.address);
    // DevTokensHolder send
    let devTokensHolderFuture = DevTokensHolder.new(
        multisigDevs.address,
        statusContribution.address,
        snt.address);
    // SGTExchanger send
    let sgtExchangerFuture = SGTExchanger.new(sgt.address, snt.address, statusContribution.address);
    // DynamicCeiling send
    let dynamicCeilingFuture = DynamicCeiling.new(addressOwner, statusContribution.address);

    // SNT changeController wait
    await sntChangeControllerFuture;
    console.log("SNT changed controller!");
    // ContributionWallet wait
    let contributionWallet = await contributionWalletFuture;
    console.log("ContributionWallet: " + contributionWallet.address);
    // DevTokensHolder wait
    let devTokensHolder = await devTokensHolderFuture;
    console.log("DevTokensHolder: " + devTokensHolder.address);
    // SGTExchanger wait
    let sgtExchanger = await sgtExchangerFuture;
    console.log("SGTExchanger: " + sgtExchanger.address);
    // DynamicCeiling wait
    let dynamicCeiling = await dynamicCeilingFuture;
    console.log("DynamicCeiling: " + dynamicCeiling.address);
    console.log();

    // DynamicCeiling setHiddenCurves send
    let dynamicCeilingSetHiddenCurvesFuture = setHiddenCurves(dynamicCeiling, curves, nHiddenCurves);
    console.log();
    // SNTPlaceHolder send
    let sntPlaceHolderFuture = SNTPlaceHolder.new(
        multisigCommunity.address,
        snt.address,
        statusContribution.address,
        sgtExchanger.address);

    // DynamicCeiling setHiddenCurves wait
    await dynamicCeilingSetHiddenCurvesFuture;
    console.log("DynamicCeiling hidden curves set!");
    // SNTPlaceHolder wait
    let sntPlaceHolder = await sntPlaceHolderFuture;
    console.log("SNTPlaceHolder: " + sntPlaceHolder.address);
    console.log();

    // StatusContribution initialize send/wait
    await statusContribution.initialize(
        snt.address,
        sntPlaceHolder.address,

        startBlock,
        endBlock,

        dynamicCeiling.address,

        contributionWallet.address,

        multisigReserve.address,
        sgtExchanger.address,
        devTokensHolder.address,

        sgt.address,
        maxSGTSupply);
    console.log("StatusContribution initialized!");
};


================================================
FILE: mypy.ini
================================================
[mypy]
warn_redundant_casts = True
warn_unused_ignores = True
strict_optional = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_subclassing_any = True
check_untyped_defs = True
warn_return_any = True


================================================
FILE: package.json
================================================
{
    "name": "status-network-token",
    "version": "0.1.0",
    "description": "Status network token",
    "repository": {
        "type": "git",
        "url": "git+https://github.com/status-im/status-network-token.git"
    },
    "license": "GPL-3.0",
    "bugs": {
        "url": "https://github.com/status-im/status-network-token/issues"
    },
    "homepage": "https://github.com/status-im/status-network-token",
    "devDependencies": {
        "async": "^2.4.0",
        "bignumber.js": "^4.0.2",
        "ethereumjs-testrpc": "^3.0.5",
        "random-bytes": "^1.0.0",
        "truffle": "3.2.4",
        "truffle-hdwallet-provider": "0.0.3",
        "web3": "^0.18.4"
    },
    "dependencies": {},
    "main": "truffle.js",
    "directories": {
        "test": "test"
    },
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "author": "Status Research & Development"
}


================================================
FILE: scripts/ceiling_curve_calc.py
================================================
#!/usr/bin/env python3
''' Calculate ceiling characteristics based on curve parameters '''


import argparse
import decimal
from decimal import Decimal
import math
import statistics
import sys
from typing import List, Sequence


decimal.getcontext().rounding = decimal.ROUND_DOWN


def args_parse(arguments: Sequence[str] = None) -> argparse.Namespace:
    ''' Parse arguments '''
    par0 = argparse.ArgumentParser(
        description='Calculate ceiling characteristics based on curve parameters')

    # Required
    par0.add_argument('--limit', metavar='LIMIT', required=True, type=Decimal,
                      help='Ceiling limit')
    par0.add_argument('--curve-factor', metavar='FACTOR', required=True, type=Decimal,
                      help='Curve factor')
    # Optional
    par0.add_argument('--collected-start', metavar='WEI', type=Decimal,
                      default=Decimal('0'), help='Amount collected at start of curve')
    par0.add_argument('--gas-per-tx-1st', metavar='AMOUNT', type=Decimal,
                      default=Decimal('151070'), help='Gas used per 1st transaction')
    par0.add_argument('--gas-per-tx-2nd', metavar='AMOUNT', type=Decimal,
                      default=Decimal('123765'), help='Gas used for all subsequent transactions')
    par0.add_argument('--gas-price', metavar='WEI', type=Decimal,
                      default=Decimal('50000000000'), help='Gas price')
    par0.add_argument('--fee-token', metavar='FRACTION', type=Decimal,
                      default=Decimal('0.1'), help='Max fee cost as fraction of token value')
    par0.add_argument('--collect-min', metavar='WEI', type=Decimal,
                      help='Minimum collection amount')
    par0.add_argument('--gas-limit', metavar='AMOUNT', type=Decimal,
                      default=Decimal('4700000'), help='Gas limit per block')
    par0.add_argument('--secs-per-block', metavar='SECONDS', type=Decimal,
                      default=Decimal('16.07'), help='Average seconds per block')
    par0.add_argument('--print-txs', action='store_true',
                      default=False, help='Print every individual transaction')
    par0.add_argument('--txs-per-address', metavar='NUMBER', type=Decimal,
                      default=Decimal('1'), help='Average number of TXs per address')
    par0.add_argument(
        '--congestion', metavar='FRACTION', type=Decimal,
        default=Decimal('0.8'),
        help='Chance of contribution TXs being confirmed due to network congestion'
    )
    par0.add_argument('--collect-mean', metavar='FRACTION', type=Decimal,
                      default=Decimal('0.9'), help='Collected of TX from amount possible')

    args0 = par0.parse_args(arguments)

    if args0.txs_per_address < 1:
        print('--txs-per-address can\'t be less than 1', file=sys.stderr)
        sys.exit(1)

    return args0


def transactions_calc(
        limit: Decimal,
        curve_factor: Decimal,
        collect_minimum: Decimal,
        collect_mean: Decimal,
        collected_start: Decimal = Decimal(0),
) -> List[Decimal]:
    ''' Calculate transactions '''
    collected = collected_start
    transactions = []
    while True:
        difference = limit - collected
        to_collect = difference / curve_factor

        if to_collect <= collect_minimum:
            if difference > collect_minimum:
                to_collect = collect_minimum
                to_collect *= collect_mean
            else:
                to_collect = difference
        else:
            to_collect *= collect_mean

        collected += to_collect
        transactions.append(to_collect)

        if collected >= limit:
            break

    return transactions


def fmt_wei(value: Decimal, shift: bool = True) -> str:
    ''' Format wei value '''
    fmt_val = f'{value:.0f}'
    if shift:
        return f'{"w" + fmt_val: >26}'  # type: ignore
    return f'{"w" + fmt_val}'  # type: ignore


def fmt_eth(value: Decimal, shift: bool = True) -> str:
    ''' Format wei value into ether '''
    fmt_val = f'{value / 10**18:.18f}'
    if shift:
        return f'{"Ξ" + fmt_val: >26}'  # type: ignore
    return f'{"Ξ" + fmt_val}'  # type: ignore


def main() -> None:  # pylint: disable=too-many-locals
    ''' Main '''
    if ARGS.txs_per_address == 1:
        gas_per_tx = ARGS.gas_per_tx_1st
    else:
        gas_per_tx = ((ARGS.gas_per_tx_1st + (ARGS.gas_per_tx_2nd * (ARGS.txs_per_address - 1)))
                      / ARGS.txs_per_address).to_integral_value(rounding=decimal.ROUND_HALF_EVEN)
    tx_fee = gas_per_tx * ARGS.gas_price
    tx_fee_token_limit = tx_fee / ARGS.fee_token
    collect_min = ARGS.collect_min if ARGS.collect_min is not None else tx_fee_token_limit

    transactions = transactions_calc(
        ARGS.limit,
        ARGS.curve_factor,
        collect_min,
        ARGS.collect_mean,
        collected_start=ARGS.collected_start,
    )

    collect_fee_total = 0
    collect_minimum_total = 0
    for n, transaction in enumerate(transactions):
        if transaction <= collect_min:
            collect_minimum_total += 1

        if transaction < tx_fee_token_limit:
            collect_fee_total += 1

        if ARGS.print_txs:
            print(f'{(n + 1): >4}: {fmt_wei(transaction, shift=True)} '
                  f' {fmt_eth(transaction, shift=True)}')
    print()

    print(
        f'Average gas per TX: {gas_per_tx}\n'
        f'Average TX fee:  {fmt_wei(tx_fee)} {fmt_eth(tx_fee)}\n'
        f'Token fee limit: {fmt_wei(tx_fee_token_limit)} {fmt_eth(tx_fee_token_limit)}\n'
        f'Minimum collect: {fmt_wei(collect_min)} {fmt_eth(collect_min)}'
    )

    print()

    transactions_len = len(transactions)
    print(
        f'Number of TXs: {transactions_len}\n'
        f'Number of TXs <= minimum collect: {collect_minimum_total}\n'
        f'Number of TXs < token fee limit: {collect_fee_total}\n'
        f'Number of addresses: {transactions_len / ARGS.txs_per_address:.0f}'
    )
    decimal.getcontext().rounding = decimal.ROUND_HALF_EVEN
    blocks = math.ceil((transactions_len * gas_per_tx) / (ARGS.gas_limit * ARGS.congestion))
    print(
        f'Minimum blocks: {blocks}\n'
        f'Minimum time: {blocks * ARGS.secs_per_block:.2f}s'
    )
    decimal.getcontext().rounding = decimal.ROUND_DOWN

    print()

    max_ = max(transactions)
    min_ = min(transactions)
    mean = statistics.mean(transactions)
    median = statistics.median(transactions)
    print(
        'Collected:\n'
        f'Max:      {fmt_wei(max_)} {fmt_eth(max_)}\n'
        f'Min:      {fmt_wei(min_)} {fmt_eth(min_)}\n'
        f'Mean:     {fmt_wei(mean)} {fmt_eth(mean)}\n'
        f'Median:   {fmt_wei(median)} {fmt_eth(median)}'
    )
    if transactions_len >= 2:
        stdev = statistics.stdev(transactions)
        print(
            f'Stdev:    {fmt_wei(stdev)} {fmt_eth(stdev)}\n'
        )


if __name__ == '__main__':
    ARGS = args_parse()
    main()


================================================
FILE: scripts/sgtGeneration/deploy.js
================================================
var minimeFactoryAbi = [{"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,"type":"function"}];
var minimeFactoryContract = web3.eth.contract(minimeFactoryAbi);
var minimeFactory = minimeFactoryContract.new(
    {
        from: web3.eth.accounts[0],
        data: '0x6060604052341561000c57fe5b5b611e968061001c6000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416635b7b72c1811461003a575bfe5b341561004257fe5b604080516020600460443581810135601f81018490048402850184019095528484526100e6948235600160a060020a031694602480359560649492939190920191819084018382808284375050604080516020601f818a01358b0180359182018390048302840183018552818452989a60ff8b35169a9099940197509195509182019350915081908401838280828437509496505050509135151591506101029050565b60408051600160a060020a039092168252519081900360200190f35b60006000308888888888886101156102db565b600160a060020a03808916825287166020808301919091526040820187905260ff8516608083015282151560c083015260e0606083018181528751918401919091528651909160a08401916101008501918901908083838215610193575b80518252602083111561019357601f199092019160209182019101610173565b505050905090810190601f1680156101bf5780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838382156101fe575b8051825260208311156101fe57601f1990920191602091820191016101de565b505050905090810190601f16801561022a5780820380516001836020036101000a031916815260200191505b509950505050505050505050604051809103906000f080151561024957fe5b905080600160a060020a0316633cebb823336040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082600160a060020a0316600160a060020a03168152602001915050600060405180830381600087803b15156102bb57fe5b6102c65a03f115156102c957fe5b5050508091505b509695505050505050565b604051611b7f806102ec83390190560060a0604052600760608190527f4d4d545f302e3100000000000000000000000000000000000000000000000000608090815262000040916004919062000146565b5034156200004a57fe5b60405162001b7f38038062001b7f83398101604090815281516020830151918301516060840151608085015160a086015160c0870151949693949284019391929101905b5b60008054600160a060020a03191633600160a060020a03161790555b600b805461010060a860020a031916610100600160a060020a038a16021790558351620000e090600190602087019062000146565b506002805460ff191660ff851617905581516200010590600390602085019062000146565b5060058054600160a060020a031916600160a060020a0388161790556006859055600b805460ff1916821515179055436007555b50505050505050620001f0565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200018957805160ff1916838001178555620001b9565b82800160010185558215620001b9579182015b82811115620001b95782518255916020019190600101906200019c565b5b50620001c8929150620001cc565b5090565b620001ed91905b80821115620001c85760008155600101620001d3565b5090565b90565b61197f80620002006000396000f300606060405236156101225763ffffffff60e060020a60003504166306fdde0381146101e1578063095ea7b31461027157806317634514146102a457806318160ddd146102c657806323b872dd146102e8578063313ce567146103215780633cebb823146103475780634ee2cd7e1461036557806354fd4d50146103965780636638c0871461042657806370a08231146104e657806380a5400114610514578063827f32c01461054057806395d89b4114610573578063981b24d014610603578063a9059cbb14610628578063bef97c871461065b578063c5bcc4f11461067f578063cae9ca51146106a1578063d3ce77fe14610718578063dd62ed3e1461074b578063e77772fe1461077f578063f41e60c5146107ab578063f77c4791146107c2575b6101df5b60005461013b90600160a060020a03166107ee565b156101d657600080546040805160209081019390935280517ff48c3054000000000000000000000000000000000000000000000000000000008152600160a060020a0333811660048301529151919092169263f48c30549234926024808301939282900301818588803b15156101ad57fe5b6125ee5a03f115156101bb57fe5b505060405151151591506101d190505760006000fd5b6101dc565b60006000fd5b5b565b005b34156101e957fe5b6101f161081b565b604080516020808252835181830152835191928392908301918501908083838215610237575b80518252602083111561023757601f199092019160209182019101610217565b505050905090810190601f1680156102635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561027957fe5b610290600160a060020a03600435166024356108a8565b604080519115158252519081900360200190f35b34156102ac57fe5b6102b4610a1a565b60408051918252519081900360200190f35b34156102ce57fe5b6102b4610a20565b60408051918252519081900360200190f35b34156102f057fe5b610290600160a060020a0360043581169060243516604435610a31565b604080519115158252519081900360200190f35b341561032957fe5b610331610ad4565b6040805160ff9092168252519081900360200190f35b341561034f57fe5b6101df600160a060020a0360043516610add565b005b341561036d57fe5b6102b4600160a060020a0360043516602435610b26565b60408051918252519081900360200190f35b341561039e57fe5b6101f1610c72565b604080516020808252835181830152835191928392908301918501908083838215610237575b80518252602083111561023757601f199092019160209182019101610217565b505050905090810190601f1680156102635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561042e57fe5b6104ca600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375050604080516020601f818a01358b0180359182018390048302840183018552818452989a60ff8b35169a909994019750919550918201935091508190840183828082843750949650508435946020013515159350610d0092505050565b60408051600160a060020a039092168252519081900360200190f35b34156104ee57fe5b6102b4600160a060020a0360043516610f60565b60408051918252519081900360200190f35b341561051c57fe5b6104ca610f74565b60408051600160a060020a039092168252519081900360200190f35b341561054857fe5b610290600160a060020a0360043516602435610f83565b604080519115158252519081900360200190f35b341561057b57fe5b6101f161105c565b604080516020808252835181830152835191928392908301918501908083838215610237575b80518252602083111561023757601f199092019160209182019101610217565b505050905090810190601f1680156102635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561060b57fe5b6102b46004356110ea565b60408051918252519081900360200190f35b341561063057fe5b610290600160a060020a03600435166024356111dc565b604080519115158252519081900360200190f35b341561066357fe5b610290611205565b604080519115158252519081900360200190f35b341561068757fe5b6102b461120e565b60408051918252519081900360200190f35b34156106a957fe5b604080516020600460443581810135601f8101849004840285018401909552848452610290948235600160a060020a031694602480359560649492939190920191819084018382808284375094965061121495505050505050565b604080519115158252519081900360200190f35b341561072057fe5b610290600160a060020a0360043516602435611339565b604080519115158252519081900360200190f35b341561075357fe5b6102b4600160a060020a036004358116906024351661140e565b60408051918252519081900360200190f35b341561078757fe5b6104ca61143b565b60408051600160a060020a039092168252519081900360200190f35b34156107b357fe5b6101df600435151561144f565b005b34156107ca57fe5b6104ca61147e565b60408051600160a060020a039092168252519081900360200190f35b600080600160a060020a038316151561080a5760009150610815565b823b90506000811191505b50919050565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156108a05780601f10610875576101008083540402835291602001916108a0565b820191906000526020600020905b81548152906001019060200180831161088357829003601f168201915b505050505081565b600b5460009060ff1615156108bd5760006000fd5b81158015906108f05750600160a060020a0333811660009081526009602090815260408083209387168352929052205415155b156108fb5760006000fd5b60005461091090600160a060020a03166107ee565b156109b2576000805460408051602090810184905281517fda682aeb000000000000000000000000000000000000000000000000000000008152600160a060020a0333811660048301528881166024830152604482018890529251929093169363da682aeb9360648082019492918390030190829087803b151561099057fe5b6102c65a03f1151561099e57fe5b505060405151151590506109b25760006000fd5b5b600160a060020a03338116600081815260096020908152604080832094881680845294825291829020869055815186815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a35060015b92915050565b60075481565b6000610a2b436110ea565b90505b90565b6000805433600160a060020a03908116911614610abf57600b5460ff161515610a5a5760006000fd5b600160a060020a038085166000908152600960209081526040808320339094168352929052205482901015610a9157506000610acd565b600160a060020a03808516600090815260096020908152604080832033909416835292905220805483900390555b610aca84848461148d565b90505b9392505050565b60025460ff1681565b60005433600160a060020a03908116911614610af95760006000fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b50565b600160a060020a0382166000908152600860205260408120541580610b865750600160a060020a038316600090815260086020526040812080548492908110610b6b57fe5b906000526020600020900160005b50546001608060020a0316115b15610c4257600554600160a060020a031615610c3557600554600654600160a060020a0390911690634ee2cd7e908590610bc1908690611675565b6000604051602001526040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b1515610c1857fe5b6102c65a03f11515610c2657fe5b5050604051519150610a149050565b506000610a14565b610a14565b600160a060020a0383166000908152600860205260409020610c64908361168f565b9050610a14565b5b92915050565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156108a05780601f10610875576101008083540402835291602001916108a0565b820191906000526020600020905b81548152906001019060200180831161088357829003601f168201915b505050505081565b600080831515610d0e574393505b600b60019054906101000a9004600160a060020a0316600160a060020a0316635b7b72c130868a8a8a896000604051602001526040518763ffffffff1660e060020a0281526004018087600160a060020a0316600160a060020a03168152602001868152602001806020018560ff1660ff1681526020018060200184151515158152602001838103835287818151815260200191508051906020019080838360008314610dd6575b805182526020831115610dd657601f199092019160209182019101610db6565b505050905090810190601f168015610e025780820380516001836020036101000a031916815260200191505b5083810382528551815285516020918201918701908083838215610e41575b805182526020831115610e4157601f199092019160209182019101610e21565b505050905090810190601f168015610e6d5780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b1515610e8e57fe5b6102c65a03f11515610e9c57fe5b50506040805180517f3cebb823000000000000000000000000000000000000000000000000000000008252600160a060020a03338116600484015292519094509184169250633cebb82391602480830192600092919082900301818387803b1515610f0357fe5b6102c65a03f11515610f1157fe5b5050604080518681529051600160a060020a03841692507f086c875b377f900b07ce03575813022f05dd10ed7640b5282cf6d3c3fc352ade9181900360200190a28091505b5095945050505050565b6000610f6c8243610b26565b90505b919050565b600554600160a060020a031681565b600080548190819033600160a060020a03908116911614610fa45760006000fd5b610faf600a4361168f565b9150818483011015610fc15760006000fd5b610fce600a858401611805565b610fd785610f60565b9050808482011015610fe95760006000fd5b600160a060020a038516600090815260086020526040902061100d90828601611805565b604080518581529051600160a060020a038716916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3600192505b5b505092915050565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156108a05780601f10610875576101008083540402835291602001916108a0565b820191906000526020600020905b81548152906001019060200180831161088357829003601f168201915b505050505081565b600a546000901580611123575081600a600081548110151561110857fe5b906000526020600020900160005b50546001608060020a0316115b156111c457600554600160a060020a0316156111b757600554600654600160a060020a039091169063981b24d09061115c908590611675565b6000604051602001526040518263ffffffff1660e060020a02815260040180828152602001915050602060405180830381600087803b151561119a57fe5b6102c65a03f115156111a857fe5b5050604051519150610f6f9050565b506000610f6f565b610f6f565b6111cf600a8361168f565b9050610f6f565b5b919050565b600b5460009060ff1615156111f15760006000fd5b6111fc33848461148d565b90505b92915050565b600b5460ff1681565b60065481565b600061122084846108a8565b151561122c5760006000fd5b83600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383600083146112d2575b8051825260208311156112d257601f1990920191602091820191016112b2565b505050905090810190601f1680156112fe5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561131c57fe5b6102c65a03f1151561132a57fe5b505050600190505b9392505050565b600080548190819033600160a060020a0390811691161461135a5760006000fd5b611365600a4361168f565b9150838210156113755760006000fd5b611382600a858403611805565b61138b85610f60565b90508381101561139b5760006000fd5b600160a060020a03851660009081526008602052604090206113bf90858303611805565b604080518581529051600091600160a060020a038816917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3600192505b5b505092915050565b600160a060020a038083166000908152600960209081526040808320938516835292905220545b92915050565b600b546101009004600160a060020a031681565b60005433600160a060020a0390811691161461146b5760006000fd5b600b805460ff19168215151790555b5b50565b600054600160a060020a031681565b600080808315156114a1576001925061166c565b6006544390106114b15760006000fd5b600160a060020a03851615806114d8575030600160a060020a031685600160a060020a0316145b156114e35760006000fd5b6114ed8643610b26565b915083821015611500576000925061166c565b60005461151590600160a060020a03166107ee565b156115b7576000805460408051602090810184905281517f4a393149000000000000000000000000000000000000000000000000000000008152600160a060020a038b811660048301528a81166024830152604482018a905292519290931693634a3931499360648082019492918390030190829087803b151561159557fe5b6102c65a03f115156115a357fe5b505060405151151590506115b75760006000fd5b5b600160a060020a03861660009081526008602052604090206115dc90858403611805565b6115e68543610b26565b90508084820110156115f85760006000fd5b600160a060020a038516600090815260086020526040902061161c90828601611805565b84600160a060020a031686600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3600192505b50509392505050565b600081831061168457816111fc565b825b90505b92915050565b60006000600060008580549050600014156116ad57600093506117fc565b8554869060001981019081106116bf57fe5b906000526020600020900160005b50546001608060020a03168510611724578554869060001981019081106116f057fe5b906000526020600020900160005b505470010000000000000000000000000000000090046001608060020a031693506117fc565b85600081548110151561173357fe5b906000526020600020900160005b50546001608060020a031685101561175c57600093506117fc565b8554600093506000190191505b828211156117be5760026001838501015b04905084868281548110151561178c57fe5b906000526020600020900160005b50546001608060020a0316116117b2578092506117b9565b6001810391505b611769565b85838154811015156117cc57fe5b906000526020600020900160005b505470010000000000000000000000000000000090046001608060020a031693505b50505092915050565b8154600090819015806118425750835443908590600019810190811061182757fe5b906000526020600020900160005b50546001608060020a0316105b156118b857835484906118588260018301611908565b8154811061186257fe5b906000526020600020900160005b5080546001608060020a03858116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff1990931692909217161781559150611901565b8354849060001981019081106118ca57fe5b906000526020600020900160005b5080546001608060020a0380861670010000000000000000000000000000000002911617815590505b5b50505050565b81548183558181151161192c5760008381526020902061192c918101908301611932565b5b505050565b610a2e91905b8082111561194c5760008155600101611938565b5090565b905600a165627a7a7230582057348ca0297970bb01202ce8022511ab041096fc938e17a211f6de719789f54e0029a165627a7a723058207f08e59b3da88e7db6ae63182ac584f5a56ccbe53f3a10d2ca155d5729ede5540029',
        gas: '3900000',
        gasPrice: eth.gasPrice.mul(1.1).floor()
    }, function (e, contract){
        console.log(e, contract);
        if (typeof contract.address !== 'undefined') {
            console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
        }
    });


var _tokenFactory = minimeFactory.address ;
var sgtAbi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"creationBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"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,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeController","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_blockNumber","type":"uint256"}],"name":"balanceOfAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"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,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"parentToken","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"generateTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_blockNumber","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"data","type":"uint256[]"}],"name":"multiMint","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"transfersEnabled","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"parentSnapShotBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"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,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"destroyTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"tokenFactory","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_transfersEnabled","type":"bool"}],"name":"enableTransfers","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"inputs":[{"name":"_tokenFactory","type":"address"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"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"}];
var sgtContract = web3.eth.contract(sgtAbi);
var sgt = sgtContract.new(
    _tokenFactory,
    {
        from: web3.eth.accounts[0],
        data: '0x60a0604052600760608190527f4d4d545f302e310000000000000000000000000000000000000000000000000060809081526200004091600491906200018f565b5034156200004a57fe5b60405160208062001cdf83398101604052515b8060006000604060405190810160405280601481526020017f5374617475732047656e6573697320546f6b656e0000000000000000000000008152506001604060405190810160405280600381526020017f534754000000000000000000000000000000000000000000000000000000000081525060005b5b60008054600160a060020a03191633600160a060020a03161790555b600b805461010060a860020a031916610100600160a060020a038a16021790558351620001279060019060208701906200018f565b506002805460ff191660ff851617905581516200014c9060039060208501906200018f565b5060058054600160a060020a031916600160a060020a0388161790556006859055600b805460ff1916821515179055436007555b505050505050505b5062000239565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001d257805160ff191683800117855562000202565b8280016001018555821562000202579182015b8281111562000202578251825591602001919060010190620001e5565b5b506200021192915062000215565b5090565b6200023691905b808211156200021157600081556001016200021c565b5090565b90565b611a9680620002496000396000f3006060604052361561012d5763ffffffff60e060020a60003504166306fdde0381146101ec578063095ea7b31461027c57806317634514146102af57806318160ddd146102d157806323b872dd146102f3578063313ce5671461032c5780633cebb823146103525780634ee2cd7e1461037057806354fd4d50146103a15780636638c0871461043157806370a08231146104f157806380a540011461051f578063827f32c01461054b57806395d89b411461057e578063981b24d01461060e5780639a0e4ebb14610633578063a9059cbb14610688578063bef97c87146106bb578063c5bcc4f1146106df578063cae9ca5114610701578063d3ce77fe14610778578063dd62ed3e146107ab578063e77772fe146107df578063f41e60c51461080b578063f77c479114610822575b6101ea5b60005461014690600160a060020a031661084e565b156101e157600080546040805160209081019390935280517ff48c3054000000000000000000000000000000000000000000000000000000008152600160a060020a0333811660048301529151919092169263f48c30549234926024808301939282900301818588803b15156101b857fe5b6125ee5a03f115156101c657fe5b505060405151151591506101dc90505760006000fd5b6101e7565b60006000fd5b5b565b005b34156101f457fe5b6101fc61087b565b604080516020808252835181830152835191928392908301918501908083838215610242575b80518252602083111561024257601f199092019160209182019101610222565b505050905090810190601f16801561026e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561028457fe5b61029b600160a060020a0360043516602435610908565b604080519115158252519081900360200190f35b34156102b757fe5b6102bf610a7a565b60408051918252519081900360200190f35b34156102d957fe5b6102bf610a80565b60408051918252519081900360200190f35b34156102fb57fe5b61029b600160a060020a0360043581169060243516604435610a91565b604080519115158252519081900360200190f35b341561033457fe5b61033c610b34565b6040805160ff9092168252519081900360200190f35b341561035a57fe5b6101ea600160a060020a0360043516610b3d565b005b341561037857fe5b6102bf600160a060020a0360043516602435610b86565b60408051918252519081900360200190f35b34156103a957fe5b6101fc610cd2565b604080516020808252835181830152835191928392908301918501908083838215610242575b80518252602083111561024257601f199092019160209182019101610222565b505050905090810190601f16801561026e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561043957fe5b6104d5600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284375050604080516020601f818a01358b0180359182018390048302840183018552818452989a60ff8b35169a909994019750919550918201935091508190840183828082843750949650508435946020013515159350610d6092505050565b60408051600160a060020a039092168252519081900360200190f35b34156104f957fe5b6102bf600160a060020a0360043516610fc0565b60408051918252519081900360200190f35b341561052757fe5b6104d5610fd4565b60408051600160a060020a039092168252519081900360200190f35b341561055357fe5b61029b600160a060020a0360043516602435610fe3565b604080519115158252519081900360200190f35b341561058657fe5b6101fc6110bc565b604080516020808252835181830152835191928392908301918501908083838215610242575b80518252602083111561024257601f199092019160209182019101610222565b505050905090810190601f16801561026e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561061657fe5b6102bf60043561114a565b60408051918252519081900360200190f35b341561063b57fe5b6101ea60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284375094965061123c95505050505050565b005b341561069057fe5b61029b600160a060020a03600435166024356112f3565b604080519115158252519081900360200190f35b34156106c357fe5b61029b61131c565b604080519115158252519081900360200190f35b34156106e757fe5b6102bf611325565b60408051918252519081900360200190f35b341561070957fe5b604080516020600460443581810135601f810184900484028501840190955284845261029b948235600160a060020a031694602480359560649492939190920191819084018382808284375094965061132b95505050505050565b604080519115158252519081900360200190f35b341561078057fe5b61029b600160a060020a0360043516602435611450565b604080519115158252519081900360200190f35b34156107b357fe5b6102bf600160a060020a0360043581169060243516611525565b60408051918252519081900360200190f35b34156107e757fe5b6104d5611552565b60408051600160a060020a039092168252519081900360200190f35b341561081357fe5b6101ea6004351515611566565b005b341561082a57fe5b6104d5611595565b60408051600160a060020a039092168252519081900360200190f35b600080600160a060020a038316151561086a5760009150610875565b823b90506000811191505b50919050565b60018054604080516020600284861615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156109005780601f106108d557610100808354040283529160200191610900565b820191906000526020600020905b8154815290600101906020018083116108e357829003601f168201915b505050505081565b600b5460009060ff16151561091d5760006000fd5b81158015906109505750600160a060020a0333811660009081526009602090815260408083209387168352929052205415155b1561095b5760006000fd5b60005461097090600160a060020a031661084e565b15610a12576000805460408051602090810184905281517fda682aeb000000000000000000000000000000000000000000000000000000008152600160a060020a0333811660048301528881166024830152604482018890529251929093169363da682aeb9360648082019492918390030190829087803b15156109f057fe5b6102c65a03f115156109fe57fe5b50506040515115159050610a125760006000fd5b5b600160a060020a03338116600081815260096020908152604080832094881680845294825291829020869055815186815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a35060015b92915050565b60075481565b6000610a8b4361114a565b90505b90565b6000805433600160a060020a03908116911614610b1f57600b5460ff161515610aba5760006000fd5b600160a060020a038085166000908152600960209081526040808320339094168352929052205482901015610af157506000610b2d565b600160a060020a03808516600090815260096020908152604080832033909416835292905220805483900390555b610b2a8484846115a4565b90505b9392505050565b60025460ff1681565b60005433600160a060020a03908116911614610b595760006000fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b5b50565b600160a060020a0382166000908152600860205260408120541580610be65750600160a060020a038316600090815260086020526040812080548492908110610bcb57fe5b906000526020600020900160005b50546001608060020a0316115b15610ca257600554600160a060020a031615610c9557600554600654600160a060020a0390911690634ee2cd7e908590610c2190869061178c565b6000604051602001526040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b1515610c7857fe5b6102c65a03f11515610c8657fe5b5050604051519150610a749050565b506000610a74565b610a74565b600160a060020a0383166000908152600860205260409020610cc490836117a6565b9050610a74565b5b92915050565b6004805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156109005780601f106108d557610100808354040283529160200191610900565b820191906000526020600020905b8154815290600101906020018083116108e357829003601f168201915b505050505081565b600080831515610d6e574393505b600b60019054906101000a9004600160a060020a0316600160a060020a0316635b7b72c130868a8a8a896000604051602001526040518763ffffffff1660e060020a0281526004018087600160a060020a0316600160a060020a03168152602001868152602001806020018560ff1660ff1681526020018060200184151515158152602001838103835287818151815260200191508051906020019080838360008314610e36575b805182526020831115610e3657601f199092019160209182019101610e16565b505050905090810190601f168015610e625780820380516001836020036101000a031916815260200191505b5083810382528551815285516020918201918701908083838215610ea1575b805182526020831115610ea157601f199092019160209182019101610e81565b505050905090810190601f168015610ecd5780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b1515610eee57fe5b6102c65a03f11515610efc57fe5b50506040805180517f3cebb823000000000000000000000000000000000000000000000000000000008252600160a060020a03338116600484015292519094509184169250633cebb82391602480830192600092919082900301818387803b1515610f6357fe5b6102c65a03f11515610f7157fe5b5050604080518681529051600160a060020a03841692507f086c875b377f900b07ce03575813022f05dd10ed7640b5282cf6d3c3fc352ade9181900360200190a28091505b5095945050505050565b6000610fcc8243610b86565b90505b919050565b600554600160a060020a031681565b600080548190819033600160a060020a039081169116146110045760006000fd5b61100f600a436117a6565b91508184830110156110215760006000fd5b61102e600a85840161191c565b61103785610fc0565b90508084820110156110495760006000fd5b600160a060020a038516600090815260086020526040902061106d9082860161191c565b604080518581529051600160a060020a038716916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3600192505b5b505092915050565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156109005780601f106108d557610100808354040283529160200191610900565b820191906000526020600020905b8154815290600101906020018083116108e357829003601f168201915b505050505081565b600a546000901580611183575081600a600081548110151561116857fe5b906000526020600020900160005b50546001608060020a0316115b1561122457600554600160a060020a03161561121757600554600654600160a060020a039091169063981b24d0906111bc90859061178c565b6000604051602001526040518263ffffffff1660e060020a02815260040180828152602001915050602060405180830381600087803b15156111fa57fe5b6102c65a03f1151561120857fe5b5050604051519150610fcf9050565b506000610fcf565b610fcf565b61122f600a836117a6565b9050610fcf565b5b919050565b600080548190819033600160a060020a0390811691161461125d5760006000fd5b600092505b83518310156112eb578351600160a060020a039085908590811061128257fe5b906020019060200201511691507401000000000000000000000000000000000000000084848151811015156112b357fe5b906020019060200201518115156112c657fe5b0490506112d38282610fe3565b15156112df5760006000fd5b5b600190920191611262565b5b5b50505050565b600b5460009060ff1615156113085760006000fd5b6113133384846115a4565b90505b92915050565b600b5460ff1681565b60065481565b60006113378484610908565b15156113435760006000fd5b83600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383600083146113e9575b8051825260208311156113e957601f1990920191602091820191016113c9565b505050905090810190601f1680156114155780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561143357fe5b6102c65a03f1151561144157fe5b505050600190505b9392505050565b600080548190819033600160a060020a039081169116146114715760006000fd5b61147c600a436117a6565b91508382101561148c5760006000fd5b611499600a85840361191c565b6114a285610fc0565b9050838110156114b25760006000fd5b600160a060020a03851660009081526008602052604090206114d69085830361191c565b604080518581529051600091600160a060020a038816917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3600192505b5b505092915050565b600160a060020a038083166000908152600960209081526040808320938516835292905220545b92915050565b600b546101009004600160a060020a031681565b60005433600160a060020a039081169116146115825760006000fd5b600b805460ff19168215151790555b5b50565b600054600160a060020a031681565b600080808315156115b85760019250611783565b6006544390106115c85760006000fd5b600160a060020a03851615806115ef575030600160a060020a031685600160a060020a0316145b156115fa5760006000fd5b6116048643610b86565b9150838210156116175760009250611783565b60005461162c90600160a060020a031661084e565b156116ce576000805460408051602090810184905281517f4a393149000000000000000000000000000000000000000000000000000000008152600160a060020a038b811660048301528a81166024830152604482018a905292519290931693634a3931499360648082019492918390030190829087803b15156116ac57fe5b6102c65a03f115156116ba57fe5b505060405151151590506116ce5760006000fd5b5b600160a060020a03861660009081526008602052604090206116f39085840361191c565b6116fd8543610b86565b905080848201101561170f5760006000fd5b600160a060020a03851660009081526008602052604090206117339082860161191c565b84600160a060020a031686600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3600192505b50509392505050565b600081831061179b5781611313565b825b90505b92915050565b60006000600060008580549050600014156117c45760009350611913565b8554869060001981019081106117d657fe5b906000526020600020900160005b50546001608060020a0316851061183b5785548690600019810190811061180757fe5b906000526020600020900160005b505470010000000000000000000000000000000090046001608060020a03169350611913565b85600081548110151561184a57fe5b906000526020600020900160005b50546001608060020a03168510156118735760009350611913565b8554600093506000190191505b828211156118d55760026001838501015b0490508486828154811015156118a357fe5b906000526020600020900160005b50546001608060020a0316116118c9578092506118d0565b6001810391505b611880565b85838154811015156118e357fe5b906000526020600020900160005b505470010000000000000000000000000000000090046001608060020a031693505b50505092915050565b8154600090819015806119595750835443908590600019810190811061193e57fe5b906000526020600020900160005b50546001608060020a0316105b156119cf578354849061196f8260018301611a1f565b8154811061197957fe5b906000526020600020900160005b5080546001608060020a03858116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff19909316929092171617815591506112eb565b8354849060001981019081106119e157fe5b906000526020600020900160005b5080546001608060020a0380861670010000000000000000000000000000000002911617815590505b5b50505050565b815481835581811511611a4
Download .txt
gitextract_uyqsp8mt/

├── .babelrc
├── .eslintrc
├── .flake8
├── .gitignore
├── .pylintrc
├── .travis.yml
├── INSTRUCTIONS.md
├── LICENSE
├── MINIME_README.md
├── MULTISIG.md
├── README.md
├── SPEC.md
├── audits/
│   ├── BlockchainLabs-SNT-audit-report.md
│   └── prelim-smartcontractsolutions-ef163f1b6fd6fb0630a4b8c78d3b706f3fe1da33.md
├── contracts/
│   ├── ContributionWallet.sol
│   ├── DevTokensHolder.sol
│   ├── DynamicCeiling.sol
│   ├── ERC20Token.sol
│   ├── MiniMeToken.sol
│   ├── MultiSigWallet.sol
│   ├── Owned.sol
│   ├── SGT.sol
│   ├── SGTExchanger.sol
│   ├── SNT.sol
│   ├── SNTPlaceHolder.sol
│   ├── SafeMath.sol
│   ├── StatusContribution.sol
│   └── test/
│       ├── DevTokensHolderMock.sol
│       ├── ExternalToken.sol
│       ├── Migrations.sol
│       ├── SGTExchangerMock.sol
│       ├── SGTMock.sol
│       ├── SNTMock.sol
│       ├── SNTPlaceHolderMock.sol
│       └── StatusContributionMock.sol
├── migrations/
│   ├── 1_initial_migration.js
│   └── 2_deploy_contracts.js
├── mypy.ini
├── package.json
├── scripts/
│   ├── ceiling_curve_calc.py
│   └── sgtGeneration/
│       ├── deploy.js
│       ├── deploy_test.js
│       ├── initialBalance.csv
│       └── loadBalances.js
├── test/
│   ├── claimExternal.js
│   ├── contribution.js
│   ├── dynamicCeiling.js
│   └── helpers/
│       ├── assertFail.js
│       ├── assertGas.js
│       ├── assertJump.js
│       └── hiddenCurves.js
└── truffle.js
Download .txt
SYMBOL INDEX (13 symbols across 5 files)

FILE: migrations/2_deploy_contracts.js
  constant SGT (line 5) | const SGT = artifacts.require("SGT");
  constant SNT (line 6) | const SNT = artifacts.require("SNT");

FILE: scripts/ceiling_curve_calc.py
  function args_parse (line 17) | def args_parse(arguments: Sequence[str] = None) -> argparse.Namespace:
  function transactions_calc (line 65) | def transactions_calc(
  function fmt_wei (line 97) | def fmt_wei(value: Decimal, shift: bool = True) -> str:
  function fmt_eth (line 105) | def fmt_eth(value: Decimal, shift: bool = True) -> str:
  function main (line 113) | def main() -> None:  # pylint: disable=too-many-locals

FILE: scripts/sgtGeneration/loadBalances.js
  constant D160 (line 22) | const D160 = new BigNumber("10000000000000000000000000000000000000000", ...
  function pack (line 91) | function pack(address, amount) {

FILE: test/claimExternal.js
  constant SGT (line 5) | const SGT = artifacts.require("SGT");
  constant SNT (line 6) | const SNT = artifacts.require("SNT");

FILE: test/contribution.js
  constant SGT (line 5) | const SGT = artifacts.require("SGTMock");
  constant SNT (line 6) | const SNT = artifacts.require("SNTMock");
Condensed preview — 52 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (314K chars).
[
  {
    "path": ".babelrc",
    "chars": 50,
    "preview": "{\n  \"presets\": [\"es2015\", \"stage-2\", \"stage-3\"]\n}\n"
  },
  {
    "path": ".eslintrc",
    "chars": 1297,
    "preview": "{\n    \"env\": {\n        \"browser\": true,\n        \"es6\": true,\n        \"node\": true,\n        \"mocha\": true\n    },\n    \"ext"
  },
  {
    "path": ".flake8",
    "chars": 30,
    "preview": "[flake8]\nmax-line-length = 99\n"
  },
  {
    "path": ".gitignore",
    "chars": 56,
    "preview": "node_modules/\nbuild/\n.DS_Store\n\n.mypy_cache\n__pycache__\n"
  },
  {
    "path": ".pylintrc",
    "chars": 108,
    "preview": "[BASIC]\ngood-names=i,j,k,n,ex,Run,_\n\n[FORMAT]\nmax-line-length = 99\ndisable=locally-disabled,locally-enabled\n"
  },
  {
    "path": ".travis.yml",
    "chars": 389,
    "preview": "dist: 'trusty'\ngroup: 'beta'\n\nlanguage: 'node_js'\nsudo: false\nnode_js:\n  - '8'\n\ncache:\n    yarn: true\n\nscript:\n  - 'truf"
  },
  {
    "path": "INSTRUCTIONS.md",
    "chars": 1267,
    "preview": "## Before starting\n\n* Install `yarn` and `npm`.\n* Run `yarn` at the repo root.\n* Use the same BIP39 compatible mnemonic "
  },
  {
    "path": "LICENSE",
    "chars": 35329,
    "preview": "Jarrad Hope (Status Research & Development) Copyright (C) 2017\nJorge Izquierdo (Aragon Foundation) Copyright (C) 2017\nJo"
  },
  {
    "path": "MINIME_README.md",
    "chars": 4059,
    "preview": "# Status Network Token\n\nThe MiniMeToken contract is a standard ERC20 token with extra functionality:\n\n### The token is e"
  },
  {
    "path": "MULTISIG.md",
    "chars": 2062,
    "preview": "# Status Community Multisig [0xbbf0cc1c63f509d48a4674e270d26d80ccaf6022](https://etherscan.io/address/0xbbf0cc1c63f509d4"
  },
  {
    "path": "README.md",
    "chars": 3136,
    "preview": "# Status Network Token\n[![Build Status](https://travis-ci.org/status-im/status-network-token.svg?branch=master)](https:/"
  },
  {
    "path": "SPEC.md",
    "chars": 1339,
    "preview": "# Status Network Contribution Period\n## Functional Specification\n\n### Distribution\n- 29% is for reserve (multisig)\n- 20%"
  },
  {
    "path": "audits/BlockchainLabs-SNT-audit-report.md",
    "chars": 5659,
    "preview": "# Status Network Token Audit\n\n## Preamble\nThis audit report was undertaken by BlockchainLabs.nz for the purpose of provi"
  },
  {
    "path": "audits/prelim-smartcontractsolutions-ef163f1b6fd6fb0630a4b8c78d3b706f3fe1da33.md",
    "chars": 3413,
    "preview": "Hi all!\n\nHere are the severe issues we've found so far:\n\n#### Cloning a MiniMeToken with snapshot block set to the curre"
  },
  {
    "path": "contracts/ContributionWallet.sol",
    "chars": 2626,
    "preview": "pragma solidity ^0.4.11;\n\n/*\n    Copyright 2017, Jordi Baylina\n\n    This program is free software: you can redistribute "
  },
  {
    "path": "contracts/DevTokensHolder.sol",
    "chars": 3730,
    "preview": "pragma solidity ^0.4.11;\n\n/*\n    Copyright 2017, Jordi Baylina\n\n    This program is free software: you can redistribute "
  },
  {
    "path": "contracts/DynamicCeiling.sol",
    "chars": 7050,
    "preview": "pragma solidity ^0.4.11;\n\n/*\n    Copyright 2017, Jordi Baylina\n\n    This program is free software: you can redistribute "
  },
  {
    "path": "contracts/ERC20Token.sol",
    "chars": 2368,
    "preview": "// Abstract contract for the full ERC 20 Token standard\n// https://github.com/ethereum/EIPs/issues/20\npragma solidity ^0"
  },
  {
    "path": "contracts/MiniMeToken.sol",
    "chars": 24877,
    "preview": "pragma solidity ^0.4.11;\n\n\nimport \"./ERC20Token.sol\";\n\n/*\n    Copyright 2016, Jordi Baylina\n\n    This program is free so"
  },
  {
    "path": "contracts/MultiSigWallet.sol",
    "chars": 11450,
    "preview": "pragma solidity ^0.4.11;\n\n\n/// @title Multisignature wallet - Allows multiple parties to agree on transactions before ex"
  },
  {
    "path": "contracts/Owned.sol",
    "chars": 946,
    "preview": "pragma solidity ^0.4.11;\n\n\n/// @dev `Owned` is a base level contract that assigns an `owner` that can be\n///  later chan"
  },
  {
    "path": "contracts/SGT.sol",
    "chars": 1216,
    "preview": "pragma solidity ^0.4.11;\n\n/*\n    Copyright 2017, Jarrad Hope (Status Research & Development GmbH)\n*/\n\n\nimport \"./MiniMeT"
  },
  {
    "path": "contracts/SGTExchanger.sol",
    "chars": 4142,
    "preview": "pragma solidity ^0.4.11;\n\n/*\n    Copyright 2017, Jordi Baylina\n\n    This program is free software: you can redistribute "
  },
  {
    "path": "contracts/SNT.sol",
    "chars": 730,
    "preview": "pragma solidity ^0.4.11;\n\n/*\n    Copyright 2017, Jarrad Hope (Status Research & Development GmbH)\n*/\n\n\nimport \"./MiniMeT"
  },
  {
    "path": "contracts/SNTPlaceHolder.sol",
    "chars": 4552,
    "preview": "pragma solidity ^0.4.11;\n\n/*\n    Copyright 2017, Jordi Baylina\n\n    This program is free software: you can redistribute "
  },
  {
    "path": "contracts/SafeMath.sol",
    "chars": 1121,
    "preview": "pragma solidity ^0.4.11;\n\n\n/**\n * Math operations with safety checks\n */\nlibrary SafeMath {\n  function mul(uint a, uint "
  },
  {
    "path": "contracts/StatusContribution.sol",
    "chars": 16299,
    "preview": "pragma solidity ^0.4.11;\n\n/*\n    Copyright 2017, Jordi Baylina\n\n    This program is free software: you can redistribute "
  },
  {
    "path": "contracts/test/DevTokensHolderMock.sol",
    "chars": 509,
    "preview": "pragma solidity ^0.4.11;\n\nimport '../DevTokensHolder.sol';\n\n// @dev DevTokensHolderMock mocks current block number\n\ncont"
  },
  {
    "path": "contracts/test/ExternalToken.sol",
    "chars": 619,
    "preview": "pragma solidity ^0.4.11;\n\nimport \"../MiniMeToken.sol\";\n\ncontract ExternalToken is MiniMeToken {\n\n    function ExternalTo"
  },
  {
    "path": "contracts/test/Migrations.sol",
    "chars": 494,
    "preview": "pragma solidity ^0.4.11;\n\ncontract Migrations {\n  address public owner;\n  uint public last_completed_migration;\n\n  modif"
  },
  {
    "path": "contracts/test/SGTExchangerMock.sol",
    "chars": 536,
    "preview": "pragma solidity ^0.4.11;\n\nimport '../SGTExchanger.sol';\n\n// @dev SGTExchangerMock mocks current block number\n\ncontract S"
  },
  {
    "path": "contracts/test/SGTMock.sol",
    "chars": 414,
    "preview": "pragma solidity ^0.4.11;\n\nimport '../SGT.sol';\n\n// @dev SGTMock mocks current block number\n\ncontract SGTMock is SGT {\n\n "
  },
  {
    "path": "contracts/test/SNTMock.sol",
    "chars": 414,
    "preview": "pragma solidity ^0.4.11;\n\nimport '../SNT.sol';\n\n// @dev SNTMock mocks current block number\n\ncontract SNTMock is SNT {\n\n "
  },
  {
    "path": "contracts/test/SNTPlaceHolderMock.sol",
    "chars": 556,
    "preview": "pragma solidity ^0.4.11;\n\nimport '../SNTPlaceHolder.sol';\n\n// @dev SNTPlaceHolderMock mocks current block number\n\ncontra"
  },
  {
    "path": "contracts/test/StatusContributionMock.sol",
    "chars": 470,
    "preview": "pragma solidity ^0.4.11;\n\nimport '../StatusContribution.sol';\n\n// @dev StatusContributionMock mocks current block number"
  },
  {
    "path": "migrations/1_initial_migration.js",
    "chars": 131,
    "preview": "var Migrations = artifacts.require(\"./Migrations.sol\");\n\nmodule.exports = function(deployer) {\n    deployer.deploy(Migra"
  },
  {
    "path": "migrations/2_deploy_contracts.js",
    "chars": 6817,
    "preview": "const randomBytes = require(\"random-bytes\");\n\nconst MultiSigWallet = artifacts.require(\"MultiSigWallet\");\nconst MiniMeTo"
  },
  {
    "path": "mypy.ini",
    "chars": 225,
    "preview": "[mypy]\nwarn_redundant_casts = True\nwarn_unused_ignores = True\nstrict_optional = True\ndisallow_untyped_calls = True\ndisal"
  },
  {
    "path": "package.json",
    "chars": 922,
    "preview": "{\n    \"name\": \"status-network-token\",\n    \"version\": \"0.1.0\",\n    \"description\": \"Status network token\",\n    \"repository"
  },
  {
    "path": "scripts/ceiling_curve_calc.py",
    "chars": 6938,
    "preview": "#!/usr/bin/env python3\n''' Calculate ceiling characteristics based on curve parameters '''\n\n\nimport argparse\nimport deci"
  },
  {
    "path": "scripts/sgtGeneration/deploy.js",
    "chars": 42341,
    "preview": "var minimeFactoryAbi = [{\"constant\":false,\"inputs\":[{\"name\":\"_parentToken\",\"type\":\"address\"},{\"name\":\"_snapshotBlock\",\"t"
  },
  {
    "path": "scripts/sgtGeneration/deploy_test.js",
    "chars": 42341,
    "preview": "var minimeFactoryAbi = [{\"constant\":false,\"inputs\":[{\"name\":\"_parentToken\",\"type\":\"address\"},{\"name\":\"_snapshotBlock\",\"t"
  },
  {
    "path": "scripts/sgtGeneration/initialBalance.csv",
    "chars": 16041,
    "preview": "0xeD33259a056F4fb449FFB7B7E2eCB43a9B5685Bf,4166666\n0x2962DE226076CCE421147b5268921eF88cF0069B,1666666\n0x74748d441d2cF255"
  },
  {
    "path": "scripts/sgtGeneration/loadBalances.js",
    "chars": 8466,
    "preview": "// GENERAL PARAMS\n\nconst sourceAccount = \"0x1dba1131000664b884a1ba238464159892252d3a\";\nconst tokenAddress = '0xd248b0d48"
  },
  {
    "path": "test/claimExternal.js",
    "chars": 4563,
    "preview": "// Simulate a an external claim\n\nconst MultiSigWallet = artifacts.require(\"MultiSigWallet\");\nconst MiniMeTokenFactory = "
  },
  {
    "path": "test/contribution.js",
    "chars": 15371,
    "preview": "// Simulate a full contribution\n\nconst MultiSigWallet = artifacts.require(\"MultiSigWallet\");\nconst MiniMeTokenFactory = "
  },
  {
    "path": "test/dynamicCeiling.js",
    "chars": 9960,
    "preview": "// Simulate dynamic ceilings\n\nconst DynamicCeiling = artifacts.require(\"DynamicCeiling\");\n\nconst setHiddenCurves = requi"
  },
  {
    "path": "test/helpers/assertFail.js",
    "chars": 285,
    "preview": "module.exports = async function(callback) {\n    let web3_error_thrown = false;\n    try {\n        await callback();\n    }"
  },
  {
    "path": "test/helpers/assertGas.js",
    "chars": 136,
    "preview": "module.exports = async function(error) {\n    assert.isAbove(error.message.search('of gas'), -1, 'Out of gas error must b"
  },
  {
    "path": "test/helpers/assertJump.js",
    "chars": 144,
    "preview": "module.exports = async function(error) {\n    assert.isAbove(error.message.search('invalid JUMP'), -1, 'Invalid JUMP erro"
  },
  {
    "path": "test/helpers/hiddenCurves.js",
    "chars": 494,
    "preview": "exports.setHiddenCurves = async function(dynamicCeiling, curves) {\n    const hashes = [];\n    let i = 0;\n    for (let c "
  },
  {
    "path": "truffle.js",
    "chars": 1368,
    "preview": "const HDWalletProvider = require('truffle-hdwallet-provider');\n\nconst mnemonic = process.env.TEST_MNEMONIC || 'status mn"
  }
]

About this extraction

This page contains the full source code of the status-im/status-network-token GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 52 files (292.8 KB), approximately 87.3k tokens, and a symbol index with 13 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!