A cryptocurrency is basically a form of digital cash or a digital currency. A currency acts as a medium of exchange and a digital currency is a digital medium of exchange.
Cryptocurrencies are a digital medium of exchange. Bitcoin is the first-ever cryptocurrency created in 2009. Satoshi Nakamoto is the creator of Bitcoin.
Cryptocurrencies leverage blockchain technology. Blockchain is a decentralized network where no single authority controls the network. Blockchain is a kind of database that stores the data of the cryptocurrency. Computers participating in the network are called nodes of the network. These nodes are responsible for validating the data on the blockchain network.
Cryptocurrencies can have their own blockchain and they can also exist on other cryptocurrency's blockchain networks. For example, Bitcoin, Ethereum, Litecoin, Dogecoin, etc, have their own blockchain and the transaction data is stored on the respective blockchains. And cryptocurrencies like Basic Attention Token(BAT), LINK, UNI, SHIB are built on the Ethereum network, and cryptocurrencies like CAKE, BAKE are built on Binance Smart Chain.
Cryptocurrency Tokens
Cryptocurrencies that are built on top of other cryptocurrency blockchains are called Tokens/Cryptocurrency Tokens. All the data of a token whether it is transactional data or smart contract data exists on the blockchain on which they are built. All tokens are cryptocurrencies but all cryptocurrencies are not tokens.
We have discussed that we can create a cryptocurrency token on another cryptocurrency's blockchain network, but not all cryptocurrency networks support building tokens on them.
Ethereum is the first cryptocurrency network to support smart contracts which are helpful in creating cryptocurrency tokens. Ethereum based tokens are known as ERC-20 tokens. In this article, we are going to discuss how to create your own cryptocurrency on Ethereum (a simple ERC-20 token) using Solidity. Without any further ado, let's dive into the detailed contents.
- Installing Remix IDE via Docker
- Creating Metamask wallet
- Solidity Smart Contract for your very own Cryptocurrency Token.
- Deploying the Smart Contract to Ropsten test network (Ethereum blockchain) with Metamask and Remix IDE.
- Getting our Source Code Verified on Etherscan
- Testing our Cryptocurrency by transferring it to Random Users.
Installing Remix IDE via Docker
docker pull remixproject/remix-ide:latest
docker run -p 8080:80 remixproject/remix-ide:latest
Creating a Metamask Wallet
Solidity Smart Contract for your very own Cryptocurrency Token
A smart contract consists of both variables and functions. Variables hold the state of a smart contract and functions dictate the behavior of the contract.
In the above contract, totalSupply is the total supply of your cryptocurrency, and balances mapping stores a map of address to token balance.
When the contract is deployed, the constructor is called and the initial supply was set to 21 million. And all the tokens are by default provided to the creator of the smart contract.
The name provided in the constructor will be the name of cryptocurrency and the same goes for the symbol as well.
The balance of function provides the balance of the PBT tokens at a particular address. The transfer function lets users transfer PBT tokens from one ERC-20 address to another. Both of these functions are used by an injected web3 provider like Metamask.
Below, we will see how can we transfer our tokens from one address to another.
Compiling and Deploying the Smart Contract to Ropsten test network
- Copy the contract address which is the To address in the above image. (0x59dab2913703472b9572e1a81075521c20f4844e)
- Go to Metamask, click on assets. Click on add token. Paste the contract address in the Token contract address section and the symbol name will be auto-populated like below.
Getting our Source Code Verified on Etherscan
Testing our Cryptocurrency Token by transferring it to Random Users.
You will see a screen like below. Click on Pranay Bathini in the tokens transferred row.
ERC-20 Token Tracker Page
Contract Page
Getting your Token on the main Ethereum network
- Select Ethereum Mainnet in networks in Metamask.
- Follow the same procedure mentioned above.
- It will cost you actual ether to deploy the smart contract and make transactions instead of fake ether which we obtained from a test faucet.
Post a Comment