With the ICO craze, I have wondered the amount of effort required to launch my own ICO. This endeavor is for academic purposes only of course. It turns out creating a fully functional ERC20 token that can be sent around the network is pretty trivial. You can create your own within an hour and about 10 USD. Credit to the original author this post is based on. This walkthrough will highlight the import aspects of maxnachamkin tutorial and does not attempt to completely rewrite it.This is the start of a series where I will investigate the creation of assets on other networks, ie BitCoin and Ripple.
1. Contract Attributes
To create the token, we will be creating a smart contract that will be deployed to the ethereum network. The first step is to determine how you want your token to behave.
For first out, I am starting off with a simple token. The token will be completely premined with all tokens being sent to the contract creators address (me). No decimal points, so tokens must be transacted in whole units. The source for the smart contract that will achieve this is here.
FUTURE: Implement a mineable token
2. Deploy to Testnet
The hard part is done. We now will test out the token on the test net before deploying to the main net. Below is a high level of the steps required to deploy to the test net:
- Download and create a wallet using MetaMask
- Fund your new test wallet utilizing the MetaMask faucet
- Compile and publish the token smart contract to the Ropsten test network using browser-solidity
- Confirm contract creation on https://ropsten.etherscan.io
- Add contract to MetaMask to display newly created tokens
- Import MetaMask wallet private key into a wallet that supports sending tokens, such as myetherwallet
- Transfer tokens between addresses
Download MetaMask. MetaMask is an online wallet that allows the creation and publication of tokens easily to the network.
- Make up a password to create your first address
- Make sure to change the network to the Ropsten Test net
- Document the public and private key for this first address
NOTE: The address generated is valid on both the test and main net. Be careful with your private key from the test net in the event you use the same address to generate the tokens on the main net.
After creating the wallet, we need to fund the wallet so that we can create the contract and send tokens.
With the test net selected, click ‘Buy’ to get some either. You should be presented with a link to the MetaMask faucet. From there, you can request to have some ether sent to your wallet.
Compile and Publish
With your wallet funded, we just need to compile and publish the contract to the blockchain.
- Load the Solidity Remix Compiler
- Copy and paste smart contract code into editor
- If you have not already, update the contract details near the bottom the contract file
- On the right panel, disable auto compile
- Click ‘Settings’ menu item, change compiler to ‘v0.4.18+commit.9cf6e910’, deselect ‘Enable Optimization’
- Click ‘Compile’ menu item, click compile. Hopefully, the contract compiles with no errors
- Click ‘Run’ menu item, populate the ‘At Address’ with your MetaMask wallet address and click ‘Create’
- When presented with a popup to confirm the transaction, click ‘Submit’
Now you just wait for the test net to verify the contract creation.
Confirm Contract Creation
Search for your MetaMask address within ropsten.etherscan.io. You should have a ‘Contract Creation’ transaction. Clicking the ‘To’ link will take you to the contract information page. From here you can upload and verify your contract source code with etherscan. If you want the full experience, you can create a website and get your token added to exchanges and the etherscan registry.
Test Sending Tokens
The final step is to try to send some of these tokens to another address.
- Create a second wallet within MetaMask
- Export the private key of your first address (current owner of all tokens)
- Open myetherwallet
- Import your private key
- Click ‘Send Ether & Tokens’ menu item
- On the right panel, click ‘Add Custom Token’ button and enter the contract address
- Available tokens to send should now be viewable. Enter an amount to send and change the type from Ether to your token type
- Click ‘Generate Transaction’ and ‘Send Transaction’
The transaction should be broadcast to the network. You should be able to see your tokens appear in your send address within the MetaMask wallet.
3. Deploy to Mainnet
The steps to deploy to the main network are exactly the same as deploying to the test net. The only differences are the following:
- Must change the network to Main within MetaMask
- Transactions and contracts must be view on the main explorer
- You will need to actual ether (ie through Coinbase)
For those interested, here is a link to the Grimmjow8Token created during this exercise.
The process for creating an ERC20 token was incredibly easy. Within about an hour, I had the token deployed to the main net for only about 10 USD. Next steps will be to look at creating more complex smart contracts (including a mineable one) and attempt to create assets on other networks.
NOTE: The actual cost of create a token on the mainnet is the transaction fee.