A use case for ERC-20 token advanced features (Part I)
By now almost everybody has an idea of what an ERC-20 token is. But sometimes is not clear all the features that this standard token implements. The use cases for this range from a basic coin to any certificate of property.
If you take a look to the ERC-20 token specification you may find some functionalities that are not intuitive at first, like approvals, allowance. Also some of the most ERC-20 well-known implementations, like Open Zepellin, has a lot of features like burn, mint or pause.
Let’s take a look at all these features creating a token that represents a license to use a fictional software called Terabyte Online Media (TOM).
To keep it simple, let’s assume that one token means a lifetime license to use the software and that the users or customers of this software can transfer the license to anyone just by transferring the token to them.
Also, we are going to show how to create and use some of these features on your own website.
For this you will need:
- A WordPress website
- Metamask installed in your browser
- Some Ether to deploy your contracts. If you don’t want to use real money you can always use an Ethereym test network, we will show you how.
Step 1: Setup your website
In this tutorial, we are going to use WPSmartContracts which is a WordPress plugin created to deploy ERC-20 contracts in Ethereum network.
To do that simply go to the site: https://wpsmartcontracts.com download the plugin, install it in your WordPress site, activate it and set up the basic parameters for your Block Explorer, like number format and separators, cache options, and if you are planning to have a really heavy traffic token, you can consider having your own Etherscan API key, this is completely optional and you can skip that for now if you like.
Here you can find a couple of videos that explain in more detail these steps:
Step 2: Setup your wallet
You will need an Ethereum wallet and some amount of Ether, as a first step we don’t recommend to the main Ethereum network, it is best to start few tests in any of the test networks like Ropsten, Rinkeby or any other network you like.
It is easy and totally free to find test-ethers that works in any Ethereum test network. In this way, you don’t need to spend real money (real Ethers) while you learn.
When you are ready you can jump into the main Ethereum network. The process of deploying a token is exactly the same for test and main net. So let’s take a look at how this will work using the Rinkeby test network.
You can safely store your Ethereum private keys using Metamask Chromium extension, in this way WordPress never touch your private keys. They are safely stored in Metamask, which is a very reputable wallet-tool in the market that allows you to safely interact with smart contracts.
Then you can get some free test network ethers that can be used to interact with a test Ethereum network. But don’t get too excited with this tokens, you cannot use them in any real Ethereum contract or exchange them anywhere, they are only useful to test and learn, which is what we are doing now ;-)
For more detailed steps take a quick look to:
Step 3: Create your token
Now you are ready to create your first ERC-20 token.
In WP Smart Contracts, there are different flavors for ERC-20 tokens. Vanilla, Pistachio, and Chocolate. All share the same features like balance, transfer and approve. But the main differences between them are:
Standard token flavors:
- The Vanilla token flavor is focused on gas saving, meaning that the users of your token will spend the minimum amount of ether in each transaction. This is recommended for personal or small projects.
- The Pistachio token flavor is focused on security. This is recommended for public, valuable or sensitive tokens.
Advanced token flavor:
- The Chocolate token flavor has some advanced features for token management like the ability to burn or mint tokens and pause/resume token activity.
Which is right for you? depends on many factors, but the bigger the project, more likely is that you will need to use a Pistachio or Chocolate token.
In this example, we are going to create a token that represents a license to use a fictional software called Terabyte Online Media (TOM). To keep it simple, let’s assume that one token means a lifetime license to use the software and that the users or customers of this software can transfer the license to anyone just by transferring the token to them.
For this, we are going to use a Chocolate token in Rinkeby test network.
You can create a token as easily as creating a WordPress post. Go to your wp-admin area, click on “Coins” and then “Add New”. Choose “Chocolate” in the token type and fill all the required fields.
Some of the fields like social networks are optional, but the most important are the “Definition” fields:
- Name: Terabyte Online Media token
- Symbol: TOM
- Decimals: 0 (because in our case one token is one license, we are not interested in decimals here)
- Total supply: 21.000.000 (the total number of licenses you like to distribute or sell)
When you are ready click on “Deploy” and confirm the transaction in Metamask.
For a full detailed explanation take a look at:
Congratulations!
At this point you already have your token live on the Ethereum network and you are ready to start interacting with your token.
In the next parts, we will see how to interact with your block explorer and how to use your wallet to transfer, approve, query the allowance, burn mint and more.