LCP

Cryptocurrency has revolutionized how we deal with transactions, making the conventional way of transacting money an obsolete one. Even though the government has been wary of cryptocurrency, quite a few cities and local authorities have started implementing cryptocurrency with salary in crypto. There is no doubt that cryptocurrency is the currency of the future and people are embracing it.

However, donundefinedt you wonder how the cryptocurrencies are made, or to be technical, coded? Well, techies of Seaflux are here for you, and we have made the following blog catering to the like minds wondering about creating their own cryptocurrency.

In the following blog, we have covered:

  • The basic understanding of cryptocurrency
  • How does crypto work?
  • What is a token, a coin, and their difference
  • Lastly, we have given step-by-step guidance for creating your own token with Ethereumundefineds ERC20.

CryptoCurrency 101

Cryptocurrency or crypto is any form of currency that exists digitally or virtually doesnundefinedt rely on banks to verify transactions and uses cryptography to secure transactions. Cryptocurrencies use a decentralized system to record transactions and issue new units.

It is a peer-to-peer system that can enable anyone anywhere to send and receive payments. Instead of being physical money carried around and exchanged in the real world, cryptocurrency payments exist purely as digital entries to an online database describing specific transactions, recorded in a public ledger. Cryptocurrencies are stored in digital wallets, involving advanced coding in storing and transmitting the data between the wallets and public ledgers. Encryption aims to provide security and safety.

How does CryptoCurrency work?

Cryptocurrencies run on a distributed public ledger called blockchain, a record of all transactions updated and held by currency holders.

Units of cryptocurrency are created through a process called mining. It involves using computation power to solve complicated mathematical problems that generate coins. Users can also buy the currencies from brokers, then store and spend them using cryptographic wallets.

If you own cryptocurrency, you donundefinedt own anything tangible. What you own is a key that allows you to move a record or a unit of measure from one person to another without a trusted third party.

Token vs Coin Comparison

cryptocurrency, token, coin, token vs coin, coin vs token, comparison, what is token?, what is
    coin?, dogecoin, ethereum

Coins and Tokens are very much alike on a fundamental level. They both represent value and can process payments. You can also swap coins for tokens and vice versa.

The main difference between these two comes down to utility. There are things you can do with tokens and not with coins. On the other hand, some marketplaces will accept only coins and not tokens.




Coin

Token

Operates on its blockchain

A coin has its own blockchain which keeps track of all transactions that involve its native crypto coin.

Tokens do not have their own blockchain. Instead, they operate on other cryptosundefined blockchains, such as Ethereum. It can be based on Ethereum and deployed on Bitcoin.

Acts as money

Bitcoin was created for the sole purpose of replacing traditional money. The paradoxical appeal of transparency and anonymity inspired the creation of other coins, including ETH, NEO, and Litecoin.

Tokens are an array of codes that facilitate trades or payments between users.

Some tokens can carry more value than any other token residing in the same blockchain.

Can be mined

You can earn crypto through traditional mining on the Proof of Work system or Proof of Stake system.

Tokens can also be mined through Proof of Work system or Proof of Stake system.

Spending

Coin is totally virtual currency, where only the spending amount is reflected at the receiving end, deducted from the spending account. Coins remain where they were mined

When a token is spent, its ownership moves from one account to another, similar to the NFTs.

Tokens can stand for deeds or assets, like gold/property.

Exchanging coins undefined tokens

Coins cannot be exchanged using tokens unless both the coin and token reside on the same blockchain. For example, Shiba Inu can be used to exchange with Ethereum but not with Bitcoin

Tokens can be bought using any coin irrespective of the blockchain they are based on.

Creation

Coins are created based on protocols.

Tokens are created based on the existing smart contracts of coins.

Example

Ethereum (ETH), Bitcoin (BTC)

Shiba Inu (SHIB), Dogecoin (DOGE)


Simply put, a token represents what you own, while a coin denotes what youundefinedre capable of owning.

Another interesting thing about tokens is how easy it is to create one. Some networks, like Ethereum, provide templates where you can brand your tokens, and start trading. So anyone with little to no technical knowledge can become a market maker. Letundefineds create our own token.


Creating your own Token

The token will be a standard ERC20 token, where youundefinedll set a fixed amount to be created and wonundefinedt have any fancy rules. Iundefinedll also show you how to get it verified so that itundefineds legitimate. Let us start creating your own token.

What is ERC20?

ERC20 is an official protocol for proposing improvements to the Ethereum (ETH) network. ERC stands for Ethereum Request for Comment, and 20 is the proposal identifier. This is a common standard for creating tokens on the Ethereum blockchain.

This token standard defines a set of rules that apply to all ERC20 tokens that allow them to interact seamlessly with one another.

Wallets and exchanges use the standard to integrate various ERC20 tokens onto their platforms and facilitate the exchanges between ERC20 tokens and other cryptocurrencies.


Steps to creating the token

Step 1: Decide what you want your token to be

In order to create an ERC20 token, you need the following:

  • The Tokenundefineds Name
  • The Tokenundefineds Symbol
  • The Tokenundefineds Decimal Places
  • The Number of Tokens in Circulation

For The Most Private Coin Ever , I chose:

  • Name: Seaflux
  • Symbol: SFT
  • Decimal Places: 18
  • Amount of Tokens in Circulation: 100,000

The decimal places are where things can get tricky. Most tokens have 18 decimal places, meaning that you can have up to .0000000000000000001 tokens.

While creating the token, you need to know how many decimal places you would like and how it fits into the larger picture of your project.

I kept it simple and wanted people to either have a token or not, nothing in between. So I chose 0. However, you could choose 1, if you want people to have half a token, or 18 to be undefinedstandardundefined.

Step 2: Code the Contract

Here is a contract you can undefinedCopy/Pasteundefined to create your ERC20 token. Shoutout to TokenFactory for the source code.


pragma solidity ^0.8.11;
Import “https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol”;

contract Seaflux_Token is ERC20 {
    address public admin;
    constructor () ERC20('SeaFlux','SFT'){
        _mint(msg.sender,100000 * 10 ** 18);
        admin = msg.sender;
    }

    function mint(address to, uint amount) external{
        require(msg.sender == admin, 'Only admin allow');
        _mint(to, amount);
    }
}

Throw this into your favorite text editor (Remix is my personal favorite).remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    solidity

Now go to settings on the right, and select the latest release compiler version (NOT nightly), as well as check undefinedAuto Compilerundefined.

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    compiling in solidity

Edit the code according to the following particulars:

  • The token name
  • The token symbol (Iundefinedd go no more than 3 characters here)
  • The token decimal places. How much do you as the owner want to start with?
  • The number of tokens in circulation (to keep things simple, letundefineds make this the same amount as the owner supply)

Some things to keep in mind:

  1. The supply set for the tokens correlates with the number of decimal places set.

For example, if you have a token with 0 decimal places to want 100 tokens, then the supply would be 100.

However, if you have a token with 18 decimal places and want 100 of them, then the supply would be 100000000000000000000 (18 zeros added to the amount).

  1. You set the number of tokens you receive as the creator of the contract.

Thatundefineds what this line of code is:

balances[msg.sender] = NUMBER_OF_TOKENS_HERE;

Whatever you set here will be sent to the ETH wallet of the owner wherever you deploy the contract. Weundefinedll get to that in a few minutes.

For now, just set this equal to the supply so that you receive all the tokens. If youundefinedre wanting to be more advanced with the token logic, you could set it with different rules, like different founders of your projects would receive different amounts or something like that.

Once you have all the variables in, itundefineds now time to deploy it to the blockchain and test it.

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    solidity

Step 3: Test The Token on The TestNet

Next, weundefinedre going to deploy the contract to the test network to see if it works. It is frustrating to deploy the contract to the MainNet, pay for it, and then watch it fail.

First, if you donundefinedt have it already, download MetaMask. They have an easy-to-use interface to test this.

Once youundefinedve installed MetaMask, make sure to log in and set up on the Ropsten test network. If you click in the top left where it says undefinedMain Ethereum Networkundefined you can change it to Ropsten.

To confirm, the top of your MetaMask window should look like this:

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    MetaMask, MetaMask integration, MetaMask wallet

Go to advanced settings option and enable show test networks

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    MetaMask, MetaMask integration, MetaMask wallet


remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    MetaMask, MetaMask integration, MetaMask wallet, Ropsten test network, Ropsten

This wallet will be the undefinedOwnerundefined of the contract, so donundefinedt lose this wallet! If you donundefinedt like MetaMask, you can use Mist or MyEtherWallet instead, whichever seems to be best. I recommend using MM for simplicity, and you can always export your private key to MyEtherWallet for later usage.

Keep note of the current Solidity version in the compiler. Weundefinedll need that later to verify the contract source.

Now go to the DEPLOY undefined RUN TRANSACTIONS tab and select the environment. The first two options are remix test network-based, the third one is wallet test network and the last one is used to deploy on the main network. After that, hit the deploy button to deploy the contract on the remix test network.

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    solidity, deploy and run crypto

After successfully deploying a contract on remix test net get the option below in deploy contract where it can show all the details of the token.

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    solidity, token deployed, cryptocurrency deployed

Above image is for successful deployment.

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    solidity, transferring the token, token from 1 account to another

To transfer the token, you need to select the receiver address. Go to the account, choose another one to copy the address where you want to send the token. Reselect the original account, from where you want to send the token. Now go to the transfer option, paste the receiver account that you copied previously along with the amount of token by separation of the comma, and click on the transfer option. The receiver will receive the number of tokens that the sender transferred.

After the receiver receives the token, it can use it to transfer to another account and receive it to the sender account.

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    solidity, transferring the token, token from 1 account to another


To connect with the MetaMask wallet, you need to change the environment. Go to DEPLOY undefined RUN TRANSACTIONS and change the environment to Injected web3. Now the MetaMask will give you a pop-up asking you to hit undefinedSubmitundefined to pay for the transaction.

remix, creating token, coding for token, coding for cryptocurrency, remix for cryptocurrency,
    solidity, transferring the token, token from 1 account to another, connecting MetaMask

Remember, this is the Ropsten test net, so itundefineds not real Ether. You can double-check to make sure youundefinedre on the test network in MetaMask before you hit submit.

Connecting MetaMask, MetaMask interface, Ethereum in MetaMask account




When you hit Submit, itundefinedll say undefinedContract Pendingundefined in MetaMask. When itundefineds ready, click the undefinedDateundefined, and itundefinedll bring up the transaction in EtherScan. Like this:

EtherScan, checking the transaction, token transaction check

If this process works, the next is to verify the source code. If not, you need to go back to the code and modify the source to get it to work.

I canundefinedt say what exactly it would look like, this is where having a undefinedprogrammerundefineds mindsetundefined comes in. Many a time, unexpected bugs would pop up that canundefinedt be predicted until you try.

Step 4. Get the token to wallet

Copy the contract address listed in the transaction information (see screenshot above). In this case itundefineds 0x5xxxxxxxxxxxxxxxx.

Iundefinedm going to add that to MetaMask undefinedTokensundefined tab:

Paste the token name and symbol and click on the import button. Refresh the wallet to see the token.

Step 5. Verify the source code

This is going to be important for various reasons, mainly verifying the validity of your token to the public.

It doesnundefinedt technically matter if you donundefinedt verify, and your token will still be usable. However, itundefineds a good practice to verify it, so people know that youundefinedre not doing anything shady.

When youundefinedre on the transaction screen from the previous step, there is an option undefinedContractundefined beside the undefinedTransfersundefined.

Select that contract and click on undefinedVerify your contract source codeundefined.

Verify undefined Publish Contract Source Code window will open where you need to provide information regarding the contract like contract address, compiler type, compiler version, and license type. Fill in all the fields as defined below.

After clicking on continue, it will ask you to upload the file, where you need to download all the file from the remix, upload it here and click on verify to publish.


Youundefinedll get something like this:

Step 6. Get it on The Main Net

Now that everything is working, itundefineds time to deploy it on the MainNet and let other people use it.

This part is simple.

Just do steps 3 undefined 4, with the network connected to the MainNet. Make sure your MetaMask account is in Mainnet mode. Youundefinedll need to fund your contract with real Ether to do this.

undefinedCongratulations! Youundefinedve successfully deployed your Token on the Main-Netundefined

So we understood what is cryptocurrency, how it works, and what cryptos are in the market. We also touched upon the concepts of coins, tokens, their difference, and how to create your own token. To summarize the whole process of creating the token: Name, Code, Test, Get, Verify, and Deploy.

Now you know how to create a token and deploy it. So try some hands-on experience, create your own tokens and roll them in the market. Reach out to us in case of any doubt or if youundefinedre stuck in the process.

We, at Seaflux, are Blockchain enthusiasts who are helping enterprises worldwide. Have a query or want to discuss Blockchain projects? Schedule a meeting with us here, weundefinedll be happy to talk to you!

Jay Mehta - Director of Engineering
Jay Mehta

Director of Engineering