The irresistible nature of winning with Bitsong as an artist and as a music lover

The emergence of blockchain technology has brought about a significant shift in the way the music industry operates. This shift has led to the intersection of music, cryptocurrency, and earnings…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




What is an Ethereum token and how can you create your own token

Cryptocurrency is something we hear and read everywhere over the internet nowadays. People are investing lots of money (more like trading because of fluctuation it offers to make quick money) because they believe in this thing. In this article, we will see how you can create your own cryptocurrency just by knowing the fundamentals of solidity (the official language of ethereum).

Before we start the implementation you should understand what is ethereum and how it works.

If you are an investor or trade in the crypto market you probably know what it is and how it works so you can definitely skip this part, however, I would suggest you stick around just in case you’ve missed anything important. Fundamentally ethereum is an application of Blockchain (Click here to know what is blockchain). More of there are many applications of this tech but the Cryptocurrency is the most successful among any of the other applications because of its more practicality sense.

Bitcoin is one of the most successful implementations of blockchain that made the biggest change in the finance sector. All the cryptocurrency comes under Defi (Decentralized finance) that is no mediator to handle your transaction but the entire network. Bitcoin uses peer-to-peer technology to operate and run the entire ecosystem without any central authority or banks; managing transactions and the issuing of bitcoins is carried out collectively by the network. It was invented by an anonymous person named Satoshi Nakamoto in 2011. All the bitcoins in the world are worth roughly $653 billion. The combined value of bitcoin is equivalent to just 1.7% of the world’s money.

Other than bitcoin all the coins are called altcoins. Among all the altcoins ethereum is the most popular currency with a total market capitalization of $225 billion. It was founded by Russian-Canadian computer engineer Vitalik Buterin in 2015. Ethereum runs on a completely different ecosystem other than how bitcoin works. Ethereum has its own EVM (ethereum virtual machine) that runs the entire network. Ethereum is not just a cryptocurrency but the entire ecosystem that runs on a smart contract (A Turing complete computer program with decentralized execution). All the cryptocurrencies that can use this network are called tokens. Ether is one of the tokens that is built on a smart contract. Let’s first understand what are tokens.

The token is nothing but a computer program that runs as per demand. A smart contract is not restricted just to run the token it can obviously run any computer program. But since we are only interested in creating a cryptocurrency we will stick with the token. In the Ethereum network, there are two types of tokens.

The simplest explanation I can give you is our fiat currency, the concept is the same here the fungible token is something that can have multiple copies with their own value. To understand it furthermore let’s take an example: Consider $1 as a 1 token, we all know $1 is not a single quantity but it can be distributed to millions of people and each of the tokens will have a value of $1. To summarize fungible tokens can have multiple copies with a specific value for all the copies. The value can be dynamic and can change over time but the change will be for all the existed copies of that token. Currently, their e is only one fungible token supported on the ethereum network that is the ERC-20 token.

In this article, we will only focus on Fungible tokens. Because all the cryptocurrencies should be fungible. This is probably the interesting part than the above theoretical one, so without spending more time let’s get on the implementation.

Solidity is an official language that leverages the ethereum network to create the smart contract. Creating the token that means we will have to write a smart contract in a solidity programming language. If you are thinking you will have to learn the new programming language to create your cryptocurrency you are partially right but for this implementation, you don’t need to. If you are a programmer which you should be as you are reading this article then you will probably notice the solidity is no different than the c language. So let’s get started with the coding part.

The ERC-20 introduces a standard for Fungible Tokens, in other words, they have a property that makes each Token be the same (in type and value) as another Token. There are many varieties of ERC-20 like mintable, pausable, etc. However, we will create the simplest one.

ERC20 standard defines a set of functions to be implemented by all ERC20 tokens to allow integration with other contracts, marketplaces, wallets, etc.

These functions allow other people to get the balance of their wallets, transfer tokens to other wallets, etc. Some important points to consider each function has a public, view, returns, etc. these are explained below

public: This is used when you want to make that function accessible publically in the network.

view: This defines that over the network people will have only read right of that function.

returns: This defines that the function is expected to return some specific value

We will need to trigger two events that are recommended by ERC 20 standards. These events will be invoked once a user is granted the right to withdraw a token from their wallet and when the transfer is done.

Additionally, you can specify more functions of your own to customize the behavior of your token, however, the above functions and events are necessary to create the simplest token.

You can specify your token name, symbol, decimals, etc.

Now, that we know all the required information let’s merge all the pieces. Let’s create a token step by step and call it a “Red Token”.

Step 1: Define the name, symbol, standard, total supply of our token

Step 2: Now let’s define the two important events

Step 3: Map the user address and their allowance to buy the token from your total supply, we can achieve this by using the below code.

We are done with all the definition and initialization there is just one thing we need to have that is the constructor

This is important because this chunk of code will be executed only once when your smart contract is deployed in the network.

Step 4: Now we only need to write three functions and we are done with the creation of a token.

Let’s understand each function one by one.

Finally, We have written our very first token. You can publish this token to a real ethereum network where people can buy and sell. We will use this token to create our very own marketplace where people can buy and sell their tokens in exchange for digital products. Stay tuned.

You can find the complete code below.

Add a comment

Related posts:

Carta pra um amigo

Pela primeira em muito tempo, não tenho vontade de contar pra ninguém o que eu sinto. Mas preciso compartilhar um pouco com você, já que você é a personificação de desejo pela liberdade e meu melhor…

STOP! Read this before you dehydrate food

So you just bought a brand new food dehydrator and now you’re off to stuff it with a whole bunch of food out of the fridge. Why not take a few minutes to learn about some of the things you should…

Bringing an Elderly Parent Home

We got the call eight days ago. The assisted living facility where my 102-year-old mother lives would be closed to visitors effective at midnight. We follow the news of the coronavirus closely and…