Hello. I am trying to create a UI so users can create a token and define the name, symbol and supply. Everything works in remix but when I try to deploy using oz create I get this:
✓ Compiled contracts with solc 0.5.17 (commit.d19bba13)
? Pick a contract to instantiate TokenFactory
? Pick a network rinkeby
✓ Added contract TokenFactory
- Contract Token or an ancestor has a constructor. Change it to an initializer function. See https://docs.openzeppelin.com/upgrades/2.6//writing-upgradeable#initializers.
✖ Validating and deploying contract Token
✓ Contract TokenFactory deployed
Token deployment failed with error: Invalid number of parameters for "undefined". Got 0 expected 4!
I am using openzeppelin 2.5. This is my code:
pragma solidity ^0.5.0;
import "node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "node_modules/@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
import "node_modules/@openzeppelin/contracts/ownership/Ownable.sol";
contract TokenFactory {
address[] public deployedTokens;
function createToken(uint256 initialSupply, string memory name, string memory symbol) public {
address newToken = address(new Token(initialSupply, name, symbol, msg.sender));
deployedTokens.push(address(newToken));
}
function getDeployedTokens() public view returns(address[] memory) {
return deployedTokens;
}
}
contract Token is ERC20, ERC20Detailed, Ownable {
address public manager;
constructor(uint256 initialSupply, string memory name, string memory symbol, address creator ) ERC20Detailed(name, symbol, 18) public {
manager = creator;
_mint(manager, initialSupply);
transferOwnership(manager);
}
}