Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move token creation outside of crowdsale contract #690

Merged

Conversation

spalladino
Copy link
Contributor

Fixes #358

  • πŸ“˜ I've reviewed the OpenZeppelin Contributor Guidelines
  • βœ… I've added tests where applicable to test my new functionality.
  • πŸ“– I've made sure that my contracts are well-documented.
  • 🎨 I've run the JS/Solidity linters (npm run lint:all:fix) and fixed any issues.

Fixes #358


πŸš€ Description

Remove the creation of the token contract from within the Crowdsale contract to save gas upon deployment. Note that crowdsale contracts compiled without optimisations were dangerously close to the block gas limit. See this comment for an analysis on gas cost savings via this PR.

This is a breaking change, since all usages of Crowdsale now require an extra parameter, and a manual setup of the token contract. I've noted this in the crowdsale contract documentation.

@frangio
Copy link
Contributor

frangio commented Jan 18, 2018

We should also remove Crowdsale#createTokenContract!

@spalladino spalladino force-pushed the feature/remove_token_from_crowdsale branch from 86fb1f4 to 70fd5e5 Compare January 18, 2018 21:23
@spalladino
Copy link
Contributor Author

Ouch, missed it in the PR, my bad. Fixed now!

* as they arrive.
* as they arrive. The contract requires a MintableToken that will be
* minted as contributions arrive, note that the crowdsale contract
* must be owner of the token in order to be able to mint it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could enforce this in the Crowdsale constructor as:

require(_token.owner() == this);

On the other hand, we have had a lot of requests to be able to use the crowdsale with a non-mintable token, for example in a model where the crowdsale can transfer pre-minted tokens. #554 proposed to solve this problem by having a "Mintable" interface with a possible implementation where mint doesn't create tokens but transfers from a pre-minted pool. In this case the crowdsale doesn't need to be the token owner.

Just throwing this out there because we might have to keep it in mind in the near future, to move forward towards something like #554 (which I personally want us to do).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm agree to not enforce it, to acommodate for non-ownable tokens in the future as you say.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we comfortable with the owner being able to mint tokens arbitrarily before the crowdsale starts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say yes, since it can be verified by anyone by looking at the total supply right before the sale starts. Besides, it's perfectly possible to do that now, simply by extending the crowdsale contract and spawning a mintable token that allows more than one owner to mint.

@frangio
Copy link
Contributor

frangio commented Jan 24, 2018

We forgot to merge this for 1.6.0. 😒

@medied
Copy link

medied commented Feb 13, 2018

We forgot to merge this for 1.6.0. 😒

@frangio any idea when will be the next release with this included?

@fiiiu
Copy link
Contributor

fiiiu commented Feb 14, 2018

@medied Next release scheduled for Feb 20th, should include this!

ProphetDaniel pushed a commit to classicdelta/Smart-Contracts that referenced this pull request Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revisit gas costs of having Crowdsale deploy the token itself
4 participants