Unilock: Create your campaign token from within

How can I create a token during a campaign launch?

CREATE TOKEN.
TOKEN INFO

Technicalities:

tokenDeployer.sol : Line 22:function createTokenWithCampaign(string memory _name, string memory  _symbol, uint8 _decimals,uint _totalSupply,uint[] memory _data,uint _pool_rate,uint _lock_duration,uint _uniswap_rate) public returns(address token_address){    
bytes memory bytecode = type(ERC20).creationCode;
bytes32 salt = keccak256(abi.encodePacked(_name, msg.sender));
assembly {
token_address := create2(0, add(bytecode, 32), mload(bytecode), salt)
} ERC20(token_address).initialize(_name,_symbol,_decimals,_totalSupply); IERC20(token_address).approve(campaignFactory,IERC20(token_address).balanceOf(address(this))); IFactory(campaignFactory).createCampaign(_data,token_address,_pool_rate,_lock_duration,_uniswap_rate); IERC20(token_address).transfer(msg.sender,IERC20(token_address).balanceOf(address(this))); Tokens.push(token_address);
return token_address;
}

Sources:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store