Create your own Ethereum ERC20-Token

In this blog post we will create our own Ethereum ERC20-Token, which could be used for an ITO (Initial Token Offering) and could be traded on the Ethereum Blockchain.

Furthermore we will cover some core concepts (Blockchain, Ethereum, ...), terms (Security Token vs. Utility Token, Coin/Cryptocurrency...) and standards (e.g. ERC20).

1. Introduction

1.1 What is a blockchain?

A blockchain is an audit-proof digital general ledger of transactions which can record not only financial transactions, but virtually any type of transaction.

A blockchain is thus, in the simplest sense, a series of immutable records including time stamps, managed by a decentralized network of computers that do not belong to a single organization or person (compared to a central server under the full control of a single organization or person).

These data sets ("blocks") are linked by cryptographic principles ("chains").

A blockchain is therefore a basically simple, but potentially disruptive way of verifying transactions. A party to such a transaction initiates the process by creating a block. This block is checked and confirmed by the computers distributed in the network. The verified block is then added to the chain, which is stored throughout the network, creating not just a single unique record, but a unique record including a unique history - attempting to forge a single record would mean falsifying the entire chain in potentially millions of cases.

Such a blockchain network is therefore not subject to any central authority - since it is a decentralized and unchangeable general ledger, the information in it (i.e. the respective transactions) is visible to everyone, for example the entire transaction history of a physical or digital good or right.

The cryptocurreny Bitcoin uses this model for payment transactions, but it can also be used in many other ways and is basically potentially suitable for all those applications in which a neutral, timely and audit-proof confirmation of transactions - such as the signing of a contract or the change of ownership of physical or digital goods or rights - is required.

How does a Blockchain work?

In principle, transactions on such blockchains are free of charge - what usually does incur costs is infrastructure. This is usually covered by the fact that, for example, the initiator of a transaction promises so-called "gas" for those computers in the network that confirm the transaction, as motivation for the operators of those nodes to make their computing power available to the network. On the Ethereum Blockchain this gas is paid in the cryptocurrency ETH (Ether), so the costs in "common" currency (e.g. Euro) depend on the respective exchange rate of ETH. At the time of writing this article, such a transaction confirmation within about 2 minutes on the Ethereum Blockchain costs about € 0.012, a confirmation within about 5 minutes about € 0.0045. The more computers in the network confirm the transaction, the more secure (in the sense that it took place) it can be considered.

In comparison to offline processes - for example a notary who confirms a transaction - this results in the potential to significantly reduce costs and time expenditure for such sensitive transactions on the one hand, while on the other hand aspects of audit security and transparency are increased.

 A blockchain is an audit-proof decentralized digital general ledger of transactions that can record not only financial transactions, but virtually any type of transaction.

1.2 What is Ethereum?

The easiest way to describe Ethereum is as an open software platform based on blockchain technology that allows developers to create and deploy distributed applications.

Like Bitcoin, Ethereum is a distributed public blockchain network. Although there are some significant technical differences between the two, the most important difference is that Bitcoin and Ethereum differ significantly in purpose and capability. Bitcoin offers a specialized application of blockchain technology, a peer-to-peer e-payment system that enables online Bitcoin payments.

So while the Bitcoin blockchain is used to track the ownership of the digital currency (Bitcoins), the Ethereum blockchain focuses on the execution of program codes of any distributed application.

In the Ethereum blockchain, so-called Ether (ETH), a crypto token that drives the network, are earned for providing computing power ("mining"). In addition to its role as a tradable crypto currency, Ether is also used by application developers to pay transaction fees and services in the Ethereum network.

 The easiest way to describe Ethereum is as an open software platform based on blockchain technology that allows developers to create and deploy distributed applications.

1.3 What is the ERC20-Standard?

As described at the beginning of this article, the Ethereum blockchain enables the use of tokens which can be bought, sold and traded by users. These should not be confused with Ether (ETH), which is "only" the natural currency of the Ethereum Blockchain infrastructure as described above.

Tokens are digital assets or programs based on the blockchain. These tokens serve the purpose of attributing a value to them, such as promissory notes, profit participation rights, services or real objects. Hence tokens are generally not to be confused with crypto currencies (for example Bitcoin or Ether). Tokens are basically so-called "Smart Contracts", which in the case of ERC20 are executed on the Ethereum block chain.

Introducing the ERC20 standard, Ethereum first issued technical specifications for a token on its blockchain in 2015, where "ERC" stands for "Ethereum Request for Comments". ERC20 is therefore a standard protocol that defines the properties and functionality of an Ethereum blockchain token.

 ERC20 is a standard protocol that defines the properties and functionality of an Ethereum blockchain token.

1.4 Security Token vs. Utility Token

A token in general is basically simply a digital representation of potentially anything. For example, a token can represent a stock, a bond, an option, or a property etc. A token can also represent access rights to a blockchain or blockchain app, and tokens can also be used to automate "friction points" in various industries.

Utility tokens, are tokens that have a specific "use" on the blockchain or an app based on that. Utility tokens are also called "app coins" because they are explicitly designed for a certain app or blockchain.

For this reason, utility tokens are intended exclusively for such specific use and are not an investment instrument.

Security tokens, on the other hand, represent investments, such as securities such as shares, bonds, funds etc., digitally. Thus, securities of companies, fund houses or real estate funds, which are issued via the blockchain, are referred to as security tokens. As is the case with traditional "securities", security tokens thus represent profit participation, interest income or give voting rights or generate profits for the holders of those tokens.

While security tokens must therefore be subject to various regulations and legal frameworks to which the issuer must adhere, this does not apply to 100% utility tokens.

 While utility tokens are earmarked and explicitly designed for a specific app or blockchain, security tokens represent investments and are therefore subject to various regulations and legal frameworks.

2. Create your own ERC20-Token

 The creation of your own token is simple - but its emission can be potentially associated with legal implications. We therefore strongly advise against creating a token for fun-only and without prior legal advice.

2.1 Prerequisites

2.1.1 MetaMask

MetaMask ( is a browserextension (Chrome, Firefox, Opera) which makes it possible to run Ethereum dApps directly in the browser and without having to run a full Ethereum-Node.

MetaMask thus makes it possible to manage identities on different websites and sign blockchain transactions.

2.3.2 Remix - Ethereum IDE

Remix ( is an online-compiler which enables us to deploy our following Smart Contract directly onto the Ethereum-Blockchain.

2.3.3 ERC20-Token Smart Contract

The following is an exemplary (use at your own risk!) Smart-Contract, which can be adapted as described below in the next step to create your own ERC20 token. (Source: Token Factory and @maxnachamkin)

pragma solidity ^0.4.4;

contract Token {
    /// @return total amount of tokens
    function totalSupply() constant returns (uint256 supply) {}

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) constant returns (uint256 balance) {}

    /// @notice send `_value` token to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _value) returns (bool success) {}

    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}

    /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of wei to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _value) returns (bool success) {}

    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens allowed to spent
    function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}

    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

contract StandardToken is Token {

    function transfer(address _to, uint256 _value) returns (bool success) {
        //Default assumes totalSupply can't be over max (2^256 - 1).
        //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
        //Replace the if with this one instead.
        //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
        if (balances[msg.sender] >= _value && _value > 0) {
            balances[msg.sender] -= _value;
            balances[_to] += _value;
            Transfer(msg.sender, _to, _value);
            return true;
        } else { return false; }

    function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
        //same as above. Replace this line with the following if you want to protect against wrapping uints.
        //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
        if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
            balances[_to] += _value;
            balances[_from] -= _value;
            allowed[_from][msg.sender] -= _value;
            Transfer(_from, _to, _value);
            return true;
        } else { return false; }

    function balanceOf(address _owner) constant returns (uint256 balance) {
        return balances[_owner];

    function approve(address _spender, uint256 _value) returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
        return true;

    function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
        return allowed[_owner][_spender];

    mapping (address => uint256) balances;
    mapping (address => mapping (address => uint256)) allowed;
    uint256 public totalSupply;

contract ERC20Token is StandardToken {

    function () {
        //if ether is sent to this address, send it back.

    /* Public variables of the token */
    string public name;                   //Name of the token
    uint8 public decimals;                //How many decimals to show. ie. There could 1000 base units with 3 decimals
    string public symbol;                 //An identifier: eg AXM
    string public version = 'H1.0';       //human 0.1 standard. Just an arbitrary versioning scheme.


//make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token

    function ERC20Token(
        ) {
        balances[msg.sender] = NUMBER_OF_TOKENS;               // Give the creator all initial tokens (100000 for example)
        totalSupply = NUMBER_OF_TOKENS;                        // Update total supply (100000 for example)
        name = "NAME_OF_TOKEN";                                   // Set the name for display purposes
        decimals = DECIMALS;                            // Amount of decimals
        symbol = "SYM";                               // Set the symbol for display purposes

    /* Approves and then calls the receiving contract */
    function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);

        //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
        //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
        //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
        if(!"receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
        return true;

The following parameters should be adjusted:

  • NUMBER_OF_TOKENS The total number of tokens issued, for example 100 (and in this case also the number of tokens which the creator will initially hold in his wallet).
  • DECIMALS The number of decimal places and thus definition of the maximum divisibility of the token, for example 18
  • NAME_OF_TOKEN The display name of the token, for example "Axom Token".
  • SYM Abbreviation of the token, for example "AXM".

2.2 Deployment

The above Smart-Contract-Code can be copied and pasted into the main window of Remix ( after the individual adjustments described above.

 Attention: In the corresponding dropdown field Select new compiler version a compiler version should be selected which is compatible with the above mentioned Smart-Contract, e.g. 0.4.26+commit.4563c3fc.

In the tab "Run" the Smart-Contract can now be deployed to the Ethereum blockchain. The total number of tokens defined in the Smart-Contract-Code (e.g. 100) should be associated with and held in the MetaMask Wallet (from which they could be traded in the next step).

The following values should be considered in the corresponding fields before deployment:

  • Environment "Injected Web3"
  • Account Should match your MetaMask Wallet-Address

The screen should hence look as follows:

Create your own ERC20-Token with Remix Ethereum IDE

With a click on "Deploy" and subsequent confirmation, the Smart-Contract can be deployed; after the transaction has been confirmed by the Ethereum-Blockchain-Network (note: this can take a couple of minutes), the defined number (e.g. 100) of issued tokens should then appear in the MetaMask Wallet.

 Attention: The actual deployment of the Smart-Contract to the Ethereum-Blockchain (and also trading of the tokens) costs so-called "gas" (see above). The specified wallet must therefore be sufficiently covered by ETH in order to pay the corresponding infrastructure fees in the form of gas.

3. Trade your created Token

Our emitted tokens should now be found in our MetaMask Wallet, which should look like this (Note: in the screenshot below there are only 99 tokens left, because a token had already been traded when this article was created):

Trade your own ERC20-Token

By clicking on "Send", a definable number of the ERC20 token can now be sent to any ETH wallet; the screen for this should then look as follows:

Trade your own ERC20-Token

Note: As described at the beginning of this article, all transactions on a blockchain, in this case the Ethereum blockchain, are transparently visible. For the Ethereum-Blockchain there exists, an Ethereum-Blockchain-Explorer.

The transactions made by the author in the context of this tutorial can also be viewed: 1. deployment of the Smart-Contract and 2. trade of an AXM Token.


No comments yet

Feel free to comment!