**Creating and Deploying a Token Contract**
To create a user-friendly and broadly accessible system for token creation, a set of standards called ERC 20 was created by the Ethereum developers. ERC 20 defines a set of six functions that other smart contracts within the Ethereum ecosystem will understand and recognize. These include how to transfer a token by the owner or on behalf of the owner, and how to access data like name, symbol, supply, and balance about the token. Together, these functions and events make Etherium tokens work in a way that is almost identical across the Ethereum ecosystem.
This interoperability is important to spur an ecosystem, and nearly all wallets that support Ethereum now also support ERC 20 compliant tokens. To create a standard ERC 20 token, a set amount will be created, and we won't have any fancy rules like Finance Skynet's. The first step in creating our token is to decide what we want our token to be. We'll decide on a name, symbol, number of decimal places, and the number of tokens, as well as the total amount of tokens.
Most tokens have 18 decimal places, which means that they can represent a wide range of values. To keep things simple, let's choose 0 as our token type, so people will either have a token or not. We won't have anything in between. Our next step is to actually code this token contract. Luckily for us, we can just copy and paste a standard ERC 20 token template contract written in Solidity, the Ethereum scripting language.
The standard ERC 20 token template defines the total amount of tokens, balance, and how to transfer funds and approve transactions. We can inherit from the initial token class and add the details of how our specific token will work using custom variables. We replace the filler words with the values we find to be best in our text editor. The supply of our token is correlated to the amount of decimal places we set, so if we had a token with zero decimal places and 100 tokens, the supply would be a hundred.
However, if we had 18 decimal places and 100 tokens, the supply would be a much bigger number. We also set the amount of tokens we receive as the creator of the contract for now, setting it equal to the supply so we receive all the tokens. We could set it with different rules, so different founders of our project could receive different amounts, but we're going lone-wolf right now.
**Deploying the Token Contract**
All right, now that we've written our token contract, we'll deploy it to the Ethereum test net just to see if it works. We can download MetaMask since it has an easy-to-use interface to test this out. Once installed, we set up the ROPS tin test network, and then we head to Solidity Remix Compiler, which is an online compiler that publishes smart contracts straight to the blockchain.
We copy and paste the source code of our contract into the main window, go to the settings, select the latest release compiler version, and uncheck enable optimization. We go back to the contract tab and hit create under the name of the token function. MetaMask will then pop up asking us to hit submit to pay for the transaction. Of course, we will, it's not real ether; it's a test net.
When we hit submit, it'll say "contract pending" in MetaMask. When we click on date, it brings up a screen that details the transaction. We can see if it actually created the tokens and sent them to our wallet. We copy the contract address and add it to the MetaMask tokens tab; it says we have 100 tokens, so it worked.
Now that we've verified the source code, we can deploy our token to the main net so people can actually use it. To do this, we'll basically do the same thing we just did, except instead of being connected to the ROPS tin test network, we'll be connected to the main net. We need to fund our contract with real ether, which can cost anywhere from $20 to $50 worth of ether as of now.
**Token Creation and Its Applications**
A token is a digital asset that can represent anything from loyalty points to vouchers to securities tokens. Our smart contracts are what make them workable. We can easily create them using the Ethereum blockchain's Turing-complete scripting language called Solidity. To create a token, we just fill in a smart contract template written in Solidity with our details and deploy it to the Ethereum blockchain via a tool called MetaMask.
Please subscribe for more programming videos.