If you’re looking to make your own blockchain with Ethereum’s ERC-20 smart contracts, then here’s everything you need to know to do so.
Ether’s ERC-20 tokens take much of the hard work out of creating a blockchain. If you have a bright idea, ERC-20 tokens handle the heavy lifting. But what exactly are they?
How ERC-20 Tokens Work
Before looking at ERC-20, it may be helpful to learn about Ethereum itself. You can read our Ethereum coin study if you don’t already know.
ERC stands for Ethereum Request for Comment, and they are proposals for enhancements to Ethereum. ERC-20 is a standard for token design, and it ensures that every token and smart contract running on the network follows the rules. If every smart contract looked different, there would be mass confusion, and the whole thing would come crumbling down.
By strictly defining standards, exchanges, wallets, DApps, and more, can all consistently communicate effectively, regardless of the specific token in use. There are six main rules specified by ERC-20:
- Total supply: Specifies the total number of coins in circulation.
- Balance of: Outlines the total coins held by each individual address.
- Allowance: The total number of coins allowed for transfer from each individual address.
- Transfer: Transfers a balance from one account to another.
- Approve: Increases the allowance for a given address.
- Transfer from: Used to withdraw tokens from an address.
By creating an ERC-20 smart contract (and following the rules and regulations above), you can create your own token. Here’s how.
Creating Your New Token
While most token projects involve at least a little technical coding knowledge, we’ll cover the theory, and leave out the confusing coding jargon.
By writing code which follows the rules outlined above, you can run your token on the Ethereum network. The language of choice for ERC-20 is often Solidity, the smart contract language developed for Ethereum. At the very least, your code needs to store:
- Total Supply
The name, symbol, and total supply are all common attributes used by all blockchains. You may wish to consider a unique name and symbol for your new project. The total supply can be anything you like. Will you have a limited supply, which (like Bitcoin), provides value in the form of scarcity.
Or how about an almost unlimited supply, like many pre-mined coins launching recently. A few billion ought to suffice right? Whatever you choose, make sure you’re happy with it. While it’s possible to increase the total supply in the future, your loyal fanbase may not appreciate it!
The standard is the “technical name” for your code. Again, this can be anything you like, but something with a version number doesn’t hurt, in case you make changes in the future.
Once you’ve decided the basics, you can begin implementing the rest of the rules. You need to code the functionality to allow the transfer and approval process. This is where you can get creative with your own unique rules and requirements. Does every wallet on your network need a balance of 100 tokens? What about a specific transfer amount of 3.14159 (Pi)?
These are silly requirements, but hopefully, they serve to inspire you. It’s clichéd, but the world really is your oyster, and that’s what is so exciting about creating your own tokens. If you can imagine it, the process really is as simple as coding the rules into your smart contract. The minimum functionality you must put in place is:
- Transfer From
Whenever an appropriate event happens on your network, your smart contracts will automatically run the appropriate code for that action.
Finally, make sure you consider the appropriate software development processes and procedures such as code reviews, testing, and security analysis. As Dan’s piece on the worst cryptocurrency hacks shows, any bugs or unintentional features at this stage may have a drastic impact on your project.
Distributing Your Token
Once your token is ready, you can begin distribution. There are no rules saying you must use an Initial Coin Offering (ICO), but an ICO is by far the most common way to pre-sell your tokens.
If you don’t want to sell using an ICO, that’s ok. ICOs are one of the best ways to sell a lot of tokens, but here are some suggestions which may work for you (depending on your project and market):
- Friends and family: Sell your tokens to friends and family, in exchange for cash.
- Business loyalty points: If you run a business, give your tokens away with every sale.
- Word of mouth: Sell your tokens on a website, and advertise through forums, blogs, and word of mouth.
ICOs are the best way to sell your tokens, but they still need some serious marketing to have any real impact. Here’s how to launch one for your new token.
ICOs need a similar amount of software development to the token itself. Fortunately, Solidity handles much of this for you, and only requires a minimal amount of code. You need to store:
- Admin account: The account where all the sale proceeds go to.
- Token price: The price of your tokens during the ICO.
- Tokens sold: The total tokens sold so far.
You also need to develop the following behaviors:
- Buy: Functionality to buy tokens.
- Sell: Functionality to sell tokens.
- End sale: A condition or logic upon which the ICO ends.
By submitting your ICO code as a smart contract to the Ethereum network, it will begin executing, and (depending on your code and any conditions for starting), start the ICO.
As you’ve seen, creating your own token isn’t too difficult, thanks in part to Ether’s ERC-20 guidelines. We’ve avoided the specific technical implementation details so far, but if you’re interested in knowing exactly how this works, then take a look at these technical resources:
If you produce your own token coin, let us know in the comments below, and perhaps one day it will get discussed in its own article.