0

I writed ERC20 contract and ICO contract for a test , but I meet a lot problem with compile problem.

My ERC20 contract have own constructor

enter image description here but,I also need a ICO contract(a control)for passing variables.

this is ICO contract part , the first trying is by "constructor()public"

second trying is by "function"

enter image description here

but final test , I got the Error report

i

Got 0 expected 4! so , I think the problem is that ...

『 mTokenAddress = address(new ERC20(name, decimals, symbol, totalSupply)); 』

mTokenAddress in ICO contract is address type , i reference the solution

(How to Call contract inside another contarct in solidity version 0.5.2?)

(https://stackoverflow.com/questions/54320320/how-to-call-contract-inside-another-contarct-in-solidity-version-0-5-2?fbclid=IwAR1_2fR0-j_WRJtSgyuOPVzacJBy929eWmUh0omoTN_MZovEE2GlwIilvaE)

I don't know what else I can fix now ,hope someone give some advice

  • What do you do in your deploy scripts? The error seems to be there. Also please include your code as text is hard to test from screenshots. – Ismael May 12 at 4:04
  • const Migrations = artifacts.require("Migrations"); module.exports = function(deployer) { deployer.deploy(Migrations); }; the file name is "1_initial_migration.js" "2_deploy_contracts.js" , "3_deploy_contracts.js" , "4_deploy_contracts.js" – Cheng Kao May 16 at 10:13
  • What's the content of those files? You can edit your own question to add more details. – Ismael May 16 at 13:27
0

You don't have a compilation problem, you have a runtime problem.

The statement mTokenAddress = address(new ERC20(name, decimals, symbol, totalSupply)); is compiled successfully.

The runtime problem takes place when you execute the script 2_deploy_contracts.js.

Although you haven't posted the contents of this script, I am inclined to guess that you pass 4 arguments when deploying the second contract (whose name you haven't posted either).

Note that although the ERC20 contract's constructor takes 4 arguments, the other contract's constructor takes 0 arguments. In your script, you are most likely deploying the second contract, which deploys the first contract internally. If that is indeed the case, then you shouldn't be passing any parameters when deploying that other contract.

Please note that your question is hard to answer because of all the relevant pieces of information which you haven't bothered to post, as well as because of all those un-editable screenshots.

So please post all the relevant information and only the relevant information, and please do so using plain text (no screenshots, images, links, etc)!

  • Sorry, these days is busy for something , it's too late to reply to you ; _ ; I upload my code at github , and... I still don't sure what do you mean... Do you mean ..., the constructor I use that only appear once time , and then ,next following contract can't use the constructor ? and...finally , i really grateful your advice , really ..! github.com/KazekoToHaloers/ERC20 – Cheng Kao May 8 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.