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, don't 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 undefinedapp-link newTab='true' link='https://www.seaflux.tech/blockchain-development-services' title=' Blockchain 'undefinedundefined/app-linkundefined
  • 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 Ethereum's ERC20.

CryptoCurrency 101

Cryptocurrency or crypto is any form of currency that exists digitally or virtually doesn't 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 don’t 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

Illustration highlighting the differences between tokens and coins in the world of cryptocurrencies.

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.

CoinToken
Operates on its blockchainA 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 cryptos’ blockchains, such as Ethereum. It can be based on Ethereum and deployed on Bitcoin.
Acts as moneyBitcoin 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 minedYou 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.
SpendingCoin 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 tokensCoins 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 BitcoinTokens can be bought using any coin irrespective of the blockchain they are based on.
CreationCoins are created based on protocols.Tokens are created based on the existing smart contracts of coins.
ExampleEthereum (ETH), Bitcoin (BTC)Shiba Inu (SHIB), Dogecoin (DOGE)

Simply put, a token represents what you own, while a coin denotes what you're 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. Let’s create our own token.

Creating your own Token

The token will be a standard ERC20 token, where you’ll set a fixed amount to be created and won’t have any fancy rules. I'll also show you how to get it verified so that it's 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 Token’s Name
  • The Token’s Symbol
  • The Token’s 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 ‘standard’.

Step 2: Code the Contract

Here is a contract you can "Copy/Paste" 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 Text Editor Dashboard - A screenshot of the Remix text editor dashboard, showing the interface for coding and deploying smart contracts.

Now go to settings on the right, and select the latest release compiler version (NOT nightly), as well as check ‘Auto Compiler’.

Edit the code according to the following particulars:

  • The token name
  • The token symbol (I'd 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, let's 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.

That’s 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. We’ll get to that in a few minutes.

For now, just set this equal to the supply so that you receive all the tokens. If you’re 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, it’s now time to deploy it to the blockchain and test it.

Deploying and Testing on Blockchain - Smart contract deployment to test on a blockchain network.

Step 3: Test The Token on The TestNet

Next, we’re 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 don’t have it already, download MetaMask. They have an easy-to-use interface to test this.

Once you’ve 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 ‘Main Ethereum Network’ you can change it to Ropsten.

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

Verifying MetaMask settings for network selection in Remix.

Go to advanced settings option and enable show test networks

Test Networks in MetaMask - How to enable test network display in MetaMask settings

 Choosing Contract Owner Wallet - Advising to retain the wallet used for contract deployment, with alternative wallet options mentioned.

This wallet will be the ‘Owner’ of the contract, so don’t lose this wallet! If you don't 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. We’ll 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.

Contract Deployment on Remix - Steps for selecting environment and deploying contract on remix test network.

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.

Successful Contract Deployment Details - Visual representation of token details after successfully contract deployment on remix test network.

Above image is for successful deployment.

Guide on Token Transfer via Remix - Remix offers easy steps for moving tokens between accounts, including selecting an address, copying and pasting, and initiating transfer.

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.

Options of Token Recipients - Information regarding how the token recipients can utilize received tokens to transfer between accounts.

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 ‘Submit’ to pay for the transaction.

Connecting MetaMask to Remix - Steps for altering environment and connecting MetaMask wallet for transaction submission.

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

Ropsten Test Network Reminder - Note on using Ropsten's test net for transaction, with emphasis on testing network selection within MetaMask.

When you hit Submit, it’ll say ‘Contract Pending’ in MetaMask. When it’s ready, click the ‘Date’, and it’ll bring up the transaction in EtherScan. Like this:

Pending Contract Deployment - Description of contract deployment process, from hitting 'Submit' in MetaMask to checking transaction status on EtherScan.

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 can’t say what exactly it would look like, this is where having a “programmer's mindset” comes in. Many a time, unexpected bugs would pop up that can’t 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 it’s 0x5xxxxxxxxxxxxxxxx.

I’m going to add that to MetaMask ‘Tokens’ 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 doesn’t technically matter if you don't verify, and your token will still be usable. However, it’s a good practice to verify it, so people know that you’re not doing anything shady.

When you’re on the transaction screen from the previous step, there is an option ‘Contract’ beside the ‘Transfers’.

Select that contract and click on “Verify your contract source code”.

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.

You’ll get something like this:

Step 6. Get it on The Main Net

Now that everything is working, it’s 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. You’ll need to fund your contract with real Ether to do this.

“Congratulations! You’ve successfully deployed your Token on the Main-Net”

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 you're stuck in the process.

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

Jay Mehta - Director of Engineering
Jay Mehta

Director of Engineering

Claim Your No-Cost Consultation!

Let's Connect