Hi, I am having trouble trying to compile a simple ERC20 token contract and the Crowdsale.sol doc. I had compiled my simple ERC20 token with the most current version of OpenZeppelin, however, I had to switch to OZ 2.5 to incorporate the Crowdsale.sol. Now I am getting the following errors:
I had to install @openzeppelin 2.5 locally instead of the latest version 3.x in order to run the crowdsale.sol contract. I also changed my pragmas on my two contracts to ^0.5.0 and truffle-config
However, i am getting a number of errors now which I didn’t have before:
@openzeppelin/contracts/utils/Address.sol:31:32: Warning: The "extcodehash" instruction is not supported by the VM version "byzantium" you are currently compiling for. It will be interpreted as an invalid instruction on this VM.
assembly { codehash := extcodehash(account) }
^------------------^
CompileError: /Users/me/Desktop/final-7/contracts/MyToken.sol:18:61: TypeError: Wrong argument count for modifier invocation: 2 arguments given but expected 0.
constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) public
@Skyge@abcoathup hi thank you for your help! That worked however, I was having some trouble compiling the contracts as my simpletoken ccontract is setup a bit different:
I managed to get the contracts to compile by making some adjustments to may contract to incorporate some of the items from Simple ERC20 Crowdsale. Most importantly, I included Context.sol, and ERC20Detailed under My Contract is...which seemed to work. However, I am not sure if these changes to my contracts are going to affect previous tests that I wrote on my original contract as I willl have to run them again on this new contract.
Your ERC20 above is using a constructor which names a name and symbol, this is in OpenZeppelin Contracts 3.x. In OpenZeppelin Contracts 2.x we use ERC20Detailed.
See: Simple ERC20 Crowdsale.
Hi @abcoathup thank your explanation. I will try and run my tests again however they worked on my original contract based on OpenZepp 3.x and ERC20.sol. Do you anticipate any problems?
I don’t see a reason for your tests not to pass. You are using standard ERC20 functionality. The only thing that may change is any constructor parameters when you create your token.
@abcoathup hi, in my contract which incorporates the Simple token example you provided, is the initial supply set to 1000 and do i have to include this in the 2_deploy_contracts.js file under migrations?
@abcoathup hi. I ran my tests again, had to make a few changes, but I got them to all pass! Thanks again for your help. Honestly, OpenZeppelin is unbelievably helpful.