DEV Community

Cover image for An Introduction to Cryptocurrency Tokens
Elegberun Olugbenga
Elegberun Olugbenga

Posted on • Updated on

An Introduction to Cryptocurrency Tokens

Hey👀!.Ever thought of creating your own currency?. With your name,identity and stuff?. Well you can(kinda🤫)One of the best ways to learn about the inner workings of the Cryptocurrency universe is to build your very own token. If you are new to cryptocurrency, you can check out my previous article where I demistify blockchain and cryptocurrency.

This is part 1 of a 3 part series on building our your token on the Binance Smart Blockchain with Solidity.

Before we proceed we must differentiate between a cyptocurrency and a token. The main difference being that a cryptocurrency is the native currency of a blockchain network whereas tokens are built ontop an existing blockchain.

Etherum and bitcoin like other crypto currencies allow you to transfer and trade digital currencies. Some cyptocurrencies like Etherum took it one step further. Ethereum introduced an Etherum Virtual Machine(EVM) which enables developers to create and launch code which runs on the etherum decentralized network. This code is often referred to as a Smart contract.

Etherum is not the only block chain that allows smart contracts just one of the most popular,other ones exist such as the Binance smart chain.
Etherum Virtual Machines allows nodes to store and process data in exchange for payment. This Payment is usually in the form of (Ether) which is the native currency of the Etherum Block Chain. The smart contract integration opened up blockchain to a myriad of opportunities and industries. Popular use cases are Decentralized finance, Logistics and Supply chain,Real-time IoT operating systems.

Example

Lets say, I have a voting App where users can vote for their favourite footballer using a token I created lets call it (vtokens). The more vtokens a player has the higher the rating. Users of my app can transfer vtokens with each other and also use vtokens to vote for their favourite player.

Daniel a user of my app wants to send 5,000 vTokens to Lionel Messi, Daniel calls a function inside my Voting App asking it to do so."Please transfer 5000vtokens from adress D to adress LM"

I want to to use the Etherums Blockchain to store and process the voting information (who voted for who and token transfer between users).

Even though Daniel isn’t sending ether, He must still pay a fee denominated in (ether) to have his transaction request included in the Etherums blockchain and utilize the blockchains resources to send that token. I dont want Daniel to go through the stress of also buying ether. I could peg my own vtokens to the ether i.e 20,000 vtokens = 1 Ether. So for every transaction that occurs in my app I could take a percentage of my vtoken convert it to ether which can be used as payment to the Etherum network to help me do work. The more users that want my token, the more my tokens value increases. All this interopability is made possible by "Smart Contracts" which is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code.

TOKEN STANDARDS

For two systems to work together they need a common agreement. To create your own token on an existing blockchain you need to follow the token standard. Popular token standards are ERC-20 & BEP-20.
You can think of it as a blueprint for tokens that defines how they can be spent, who can spend them, and other rules for their usage. By following the outline, developers don’t need to reinvent the wheel. Instead, they can build off a foundation already used across the industry.

For example, To be ERC-20-compliant, your contract needs to include six mandatory functions: totalSupply, balanceOf, transfer, transferFrom, approve, and allowance. In addition, you can specify optional functions, such as name, symbol, and decimal. From their names you might've already deduced what these functions do. Below are the functions as they appear in the Ethereums Solidity language. Dont worry if you do not understand the code syntax. The next article we will be an introduction into the Solidity Language.

  1. totalSupply function totalSupply() public view returns (uint256) Returns total coin supply in circulation
  2. balanceOf function balanceOf(address _owner) public view returns (uint256 balance) When called, it returns the balance of the specified address’s token holdings.
  3. transfer function transfer(address _to, uint256 _value) public returns (bool success) Transfers tokens from the person calling the smart contracts address to another.
  4. transferFrom function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) Unlike the regular transfer, in transferFrom you specify the sender address.It doesnt necesarrily have to be the address of the person calling the smart contract. A good use case is if you want to set up recurring payments using a smart contract. You could transfer the token to an "Admin user" that you created and then authourize that user to transfer the token at specific intervals.
  5. approve function approve(address _spender, uint256 _value) public returns (bool success) With this function, you can limit the number of tokens that a smart contract can withdraw from your balance.
  6. allowance function allowance(address _owner, address _spender) public view returns (uint256 remaining)

This is used together with the approve function. For example if your smart contract is permitted to withdraw 30tokens and it has withdrawn 20. Calling the allowance should return 10tokens. Basically how many tokens are left for the smart contract to call.

To create your own token there is an easy and a hard way. Easy way using the cointool app(Very Basic functionality). Hard way programming your smart contract in Solidity.(Endless possiblities). In this article we will be exploring this. But later on in this series we will create our tokens smart contract with solidity.

Creating your own token on Binance Smart Chain

  • Download trust wallet app Andriodios
  • Create a token using the coin tool app here Create Token -Specify the token name,symbol,initial supply(How many total tokens you want to create) and decimals. -Token decimals are an interesting concept. Basically this specifies the lowest unit of your token. Example. 1ETH = 1,000,000,000,000,000,000 wei. 1 Bitcoin = 100,000,000 Satoshis. This means I can own 0.000000000000000001 Eth, OR 0.0000001 BTC. It essentially helps to make our token very divisible. 1.Can Burn- This means the total circulating token can be reduced 2.Can Mint- Means an addtional amount of this token can be "minted"/"created". 3.Can Pause- This specifies whether your token and its associated functions can pause.Maybe due to hacking. -Click on Connect wallet --> Trust wallet --> BNB Network Chain. -Logon to your trust wallet --> settings --> Wallet Connect
  • Scan the QR code and Approve
  • Create token -The token will be created once you approve this transaction fee.Usually about (0.01)BNB. Token Confirmation Unfortunately i dont have suffiecient BNB to complete this token creation.😑

To make it show

  • Go to trust wallet
  • Click on the two sliders on the top right of the home page -Scroll down to --> add custom token
  • Select Network to Smart chain
  • Fill in your network address
  • Fill in the rest of the details
  • Log out and Login and see your token. Congratulations you are now own your token. Start collecting payments to your token address.🤝

In summary we have learnt

  1. A Cyptocurrency is the native currency of a blockchain whilst a token is build untop an existing block chains network.
  2. Smart contracts are codes used to execute functions for a given token.
  3. For a token to be created on a Block chains network it needs to follow the token standards by specifying certain mandatory functions.

In the part 2 of this article I will be expounding on the solidity language which is used to write smart contracts.

Follow me here and across my social media for more content like this Twitter Linkedin

Top comments (1)

Collapse
 
parth51199 profile image
parth51199

what is the difference between a cryptocurrency and a token?