How to create your ERC-20 Token in less than 10 minutes.

We are in the age of cryptocurrencies, cryptocurrency, sometimes called cryptocurrency or crypto, is any form of currency that exists digitally or virtually and uses cryptography to secure transactions. Cryptocurrencies don't have a central issuing or regulating authority, instead of using a decentralized system to record transactions and issue new units. And in this article I'll teach you to create your personal cryptocurrency and for you to be able to do this, you need to have basic knowledge of solidity, which is the programming used in writing smart contracts, if you have no idea what solidity and smart contracts mean, check out this article, however, there are other ways of creating cryptocurrencies that do not involve using any programming language just drag and drop. All that you'll need for this tutorial are: Remix Online IDE A metamask wallet account: if you don't have this, visit here to download.

Let's dive straight in, visit the remix IDE which is an online integrated development environment where you can write smart contracts, locate the new file icon as highlighted below and create a new file with the name of your token, I named mine MilkToken, and then add a .sol after the name. Remix IDE interface showing create a new file button and the created MilkToken file next time is to open the newly created file and start writing your smart contract, we don't want to write all the codes for a token from scratch we are going to make use of the openzeppelin library which has all the standards needed for our token, so can ahead and declare the version of the solidity you want to use and the license. For this tutorial, I'm making use of the 0.8.5 version and MIT license.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.5;

Now we import the openzeppelin and we will be needing the transfer, mint and burn function from this library, so import the library with the code below import 'github.com/OpenZeppelin/openzeppelin-contra..; Now create a new smart contract, name it MilkToken or whatever you named your token, and inherit the Erc20 library in your smart contract.

contract milkToken is ERC20{
}

We're almost there, now we need to create a state variable that is going to be for the admin of the contract. address public admin; Now, we create a constructor to initialize our admin state variable, Token Name, Token Symbol, and the number of tokens we want to mint using the format below.

constructor() ERC20('TokenName', 'TokenSymbol'){
_mint(msg.sender, amount_to_mint);
admin = msg.sender;
}
This is the format for my MilkTokens
constructor() ERC20('milkToken', 'MILK'){
_mint(msg.sender, 100000000 * 10 ** 18);
admin = msg.sender;
}

With the above codes, our tokens are now created but we need to allow our tokens to be transferable also the admin can add more tokens to the total supply and also burn tokens out of the total supply, this isn't compulsory it's based on preference.

function mint(address to, uint amount)external{
require(msg.sender == admin, 'only admin');
_mint(to, amount);
}
function burn(uint amount)external{
_burn(msg.sender, amount);
}
function transfer(address to, uint amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}

The transfer functions allow users to be able to transfer our tokens from the contract address to any other address, the burn function allows the admin of the contract address to be able to burn part of the tokens, and lastly, the mint function allows us to create more of the tokens. Now we're done with the smart contract for our token, the next step is to compile and deploy our codes and we're going to make use of our metamask wallet for this, this will be deployed on a rinkeby test net network and you'll certain amount of testnet ETH for this, you can claim some here. Smart contracts can easily be compiled by pressing Ctrl + s on your keyboard or by going to the compiler tab of the Remix IDE and pressing compile, after compiling, the next step is to deploy our smart contract to the blockchain. To deploy a smart contract go to the Deploy tab of the Remix IDE.

compile.PNG

Remix Compile Tab

To deploy our smart contract, we need to change the environment on the deploy tab to injected web3, a metamask window will pop up asking us to connect our wallet to Remix.

Remix Deploy Tab and Metamask PopupAfter connecting our wallet, then we proceed to deploy our smart contract and sign the transaction when the prompt from metamask and wait for a few seconds, after the transaction is executed, Bravo! our tokens have been created, you can check the transaction here.

Now that my tokens have been created I can add the tokens to my metamask account so I can easily transfer them to anyone, this can by done by visiting rinkeby.etherscan.io/address/YOUR_WALLET_AD.., checking the most recent transaction and copying its contract address and opening your metamask wallet, click on the add new tokens and the paste the contract address. Congratulations you are now Token owner, if you want mainnet token just switch to a mainnet network but bear in mind that you'll pay gas fees, you can try out polygon mainnet network, it charges very little gas fees. Getting the contract address for the newly created token

Importing Tokens on Metamask

Adding our newly created token to metamaskToken Information on MetamaskCongratulations! you're now a token owner, if it was created on a mainnet you can proceed to provide liquidity for your token so it can be tradeable on that dex. Find the complete code used for this tutorial check here.. gist.github.com/superwaih/cb3e82d9695de9bc8..