Unilock has brought a new feature to its users to help facilitate campaigns creation. We thought it’d be best to allow people who are willing to create a presale on our platform, to create their token from within, following an enhanced and secure smart contract.
Creating your ECR20 token in Unilock is optional, we are not forcing anyone to use this feature, since your token’s smart contract could require some customization, but we highly recommend using it.
We created a token model that is secure and fully functional, with no chance of scams. And here how:
- No mint function. Your total supply is fixed during the token’s creation. You will not be able to create more after.
- No authority over the token’s smart contract. No one, including the Unilock team, will have control over the token’s protocol.
- Public smart contract. Since all tokens created in the platform follow a certain model, that means your token smart contract is open source.
You can find the token model on our Github repository.
→ Thus, if you create your campaign’s token using Unilock, you’re unquestionably giving more credibility and likelihood of prosperity and growth to your project and campaign.
How can I create a token during a campaign launch?
If you’re willing to create a token for your campaign, there is a so-obvious button named “Create a token”, once clicked, new fields will be added to the form for your to fill, regarding your project’s token. The following image shows that:
Once clicked, you’ll have 4 fields to fill in concerning your token. These fields are the following:
- Token name
- Token symbol
- Decimals
- Total Supply
→ All fields are required.
If you decide not to create your token on Unilock, you can simply press “Already have a token” and the extra fields will disappear, that’s when you’ll be prompted to enter your existing token’s address to use for your campaign.
Technicalities:
The feature is currently under heavy testing. The update is composed of 2 new solidity smart contracts, they are already added to our Github repository.
tokenModel.sol defines the new token’s properties and available functions, while the tokenDeployer.sol is used to create the new token following the tokenModel.sol and executes functions from unilock’s smart contract to launch a presale using the newly created token.
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;
}
createTokenWithCampaign function is used to create a new token following tokenModel.sol smart contract ( Line 28 ), the deployer smart contract will receive the amount of token issued and create a new presale for it (Line 30) and transfer the remaining tokens to the token creator (Line 31)
Sources:
Platform: https://unilock.network/
Twitter: https://twitter.com/unilock_network
Telegram: https://t.me/unilock_network