ERC20 initial contract and crowdsale test check

:computer: Environment
Remix

:memo:Details
Incidently interface stop responding after deploy. All arguments have been given beforehand instead of using constructor arguments. It seems like code don’t have any issues while debagging.

(Most of the files have been reproduced with small changes, c.sol define contract that suppose to deployed).

Does anyone can review this case?

Thanks a lot in advance.

:1234: Code to reproduce

Summary

standard contract modified to create presale, crowdsale and proceed with emission with release date

1 Like

Hi @johnyyy-hash,

Welcome to the community :wave:

I noticed that you are importing the master branch of OpenZeppelin Contracts. We should only use an official release of OpenZeppelin Contracts, the master branch is subject to change at any time.
Remix now supports @ npm style imports, so I suggest using that.

I am not sure why you have your ERC20 token also extends Crowdsale and TokenTimelock.

I recommend a contract only have functionality required for the life of the token, so would have a separate contract for the token, a separate contract for any crowdsale and a separate contract for any timelock.

You could have a look at the following example: Simple ERC20 Crowdsale

I also suggest looking at: Points to consider when creating a fungible token (ERC20, ERC777)

1 Like

Hi @abcoathup,

Thanks for suggestions, I will review it. Just to clarify, I’ve tried to combine contracts related to presale crowdsale and final emission into single one, and as the initial contract defines name etc already, I thought it would be recognised as well. Anyway, the first attempt was successful although return indicated wrong price. Moreover, that’s second draft and I’ve moved arguments inside code instead of set up during deploy.

1 Like

hi @abcoathup,

I’ve looked into your examples, but they seem to be outdated. (file doesn’t exist) Would you mind to provide another link to crowdsale.sol?

Relating to my draft, please ignore download erc20 link master branch in main contract sol. It has been adjusted as separate file erc20.sol and has been included in gist for easy check.

To sum up, would you recommend creating initial contract and entire crowdsale contract as two files or all separate? (I’ve tested it partly as 2 files and seem successfully respond)

Additionally, I’m curious about price rate, as during deploy cannot add numbers after dot, as it return wrong value during. It works fine if its hardcoded, but respond gives different value. example: trying to set value 0.001e3 but receive response 1.

Thanks a lot in advance

1 Like

Hi @johnyyy-hash,

Crowdsale contracts were last included in OpenZeppelin Contracts 2.x. If you want to migrate to a later version of Solidity then you would need to do this yourself.

I would separate concerns, so only have functionality in a contract required for the life of the contract, so I would have a contract for a token a contract for any sale functionality and a contract for any locking.

1 Like