ICO Crowdsale

Hi, I am currently working on a crowd sale contract, But I am having an issue with a function as the list of the error and the code of the function is attached, I need someone to tell me that what is happening in the code and how can i resolve the error that I'm facing in the code.

 function _finalization() internal {
    if(goalReached()) {

      ERC20Mintable erc20Mintable = ERC20Mintable(token);
     //getting the total tokens that are been minted yet     
      uint256 alreadyMintedToken = erc20Mintable.totalSupply();
      //tokens of the final total supply
      uint256 finalTotalTokenSupply = alreadyMintedToken.div(tokenSalePercentage).mul(100);
        foundersTimelock = new TokenTimelock(token,foundersFund,releaseTime);
        partnersTimelock = new TokenTimelock(token,foundersFund,releaseTime);
        foundationTimelock = new TokenTimelock(token,foundersFund,releaseTime);
    //we will have the tokens that the founder will get 
      erc20Mintable.mint(address(foundersTimelock), finalTotalTokenSupply.mul(foundersPercentage).div(100));
      erc20Mintable.mint(address(partnersTimelock), finalTotalTokenSupply.mul(partnersPercentage).div(100));
      // Unpause the token

      ERC20Pausable erc20Pausable = new ERC20Pausable(token);


Error 1:

Explicit type conversion not allowed from "function () view returns (contract IERC20)" to "contract ERC20Mintable".
ERC20Mintable erc20Mintable = ERC20Mintable(token);

Error 2:

Crowdsale.sol:179:46: TypeError: Invalid type for argument in function call. Invalid implicit conversion from function () view returns (contract IERC20) to contract IERC20 requested.
foundersTimelock = new TokenTimelock(token,foundersFund,releaseTime);

Error 3:

Crowdsale.sol:179:28: TypeError: Type contract TokenTimelock is not implicitly convertible to expected type address.
foundersTimelock = new TokenTimelock(token,foundersFund,releaseTime);

In Error 1 you're missing the new keyword.

In Error 2 I think you have to write token() (as opposed to just token).

Error 3 is quite straightforward. Please take your best guess, you will learn better.

1 Like

Thank you @frangio i will try the suggested solution.

@frangio even though i applied the new keyword and the wrote the token in the correct form e.g. token() but still i got the error, the error is been listed below. My solidity version is ^0.5.0


Crowdsale.sol:173:37: TypeError: Wrong argument count for function call: 1 arguments given but expected 0.
ERC20Mintable erc20Mintable = new ERC20Mintable(token());

Please read the error message in detail. It's all explained there.