How to Create Your Own ERC-20 Token in 10 Minutes

The concept of “blockchain” is often associated with Bitcoin, the largest cryptocurrency from a market cap perspective. However, even though Bitcoin is the largest cryptocurrency by market capitalization, Ethereum trumps it in dApp development. Ethereum is undoubtedly the largest smart contract-enabled blockchain around, and hosts a vast ecosystem of dApps (decentralized applications). These dApps and DeFi projects generally run on Ethereum-based ERC-20 tokens. Furthermore, Ethereum is the origin of the EVM (Ethereum Virtual Machine), which is now extensively used by other popular chains such as Polygon. Because of this, many chains also apply the Ethereum ERC-20 token standard to their own networks. For this reason, we’re going to look closer at how to create your own ERC-20 token in just 10 minutes. 

Now you might be asking yourself “create your own ERC-20 token in just 10 minutes? What sorcery is this?”. In fact, it is neither sorcery nor magic – it’s just Moralis. Creating an ERC-20 token does not have to be difficult, not with the right tools. The best tool and platform for this job is Moralis, which does all the heavy backend lifting for you. You’ll quickly find out why Moralis is becoming the premier Web3 development platform, as it provides everything for developing and deploying your own dApps and tokens. As such, we’ll use Moralis for creating our ERC-20 token in this article.

Furthermore, Moralis also provides a great selection of other powerful tools to use throughout the development process. One example is Moralis Speedy Nodes, which we’ll use to develop our ERC-20 token. Moreover, Moralis provides a fully managed backend infrastructure, allowing you as a developer to focus on the frontend. So, whether you’re developing dApps or creating tokens, Moralis is here to help. Join Moralis for free, and get started utilizing the platform’s tools today!

What are ERC-20 Tokens? 

When it comes to the Ethereum blockchain and dApps, tokens are one of the most essential features. Within the Ethereum ecosystem, ERC-20 token have the ability to represent virtually anything. A few examples are lottery tickets, points on an online platform, skills for a character in a game, fiat currency, etc. This feature is quite powerful and needs to be regulated by a standard, and that’s why the ERC-20 exists. 

The ERC-20 standard ensures that tokens have the same identical properties. This further means that tokens share the same type and value, making them interchangeable. As such, ERC-20 are fungible tokens, enabling us to measure the value of a token and compare it to another. But what exactly does this mean for the tokens themselves? 

The ERC-20 standard implements an API for tokens with smart contracts. The API provides functionality, enabling developers to set a total token supply, get token balances from accounts, and transfer the tokens from one account to another. However, these are just some of the features of an ERC-20 token. For a token to be valid as an ERC-20, the token need to implement the following methods and events: 

Methods

Events

How to Create an ERC-20 Token

As we mentioned in the introduction, the ultimate way to become an Ethereum token developer is to use Moralis. As a Moralis user, it’s possible to cut the development time down to a minimum, and make the process effortless. However, before we go into how to develop your own ERC-20 token, there are a few preparations to be made: 

  1. MetaMask — First, we need to set up a MetaMask account. 
  2. Node — Second, we also need to get our hands on a fully functioning blockchain node for the network in question.
  3. Get Tokens — Third, we need to acquire tokens. Which tokens to obtain depends on the blockchain we are using to develop our ERC-20 token. We need to do so in order to pay the appropriate fees for deploying the tokens to the blockchain. 

So, let’s get started by going through the process of setting up our MetaMask account. 

Setting Up a MetaMask Account

MetaMask is one of the most popular cryptocurrency wallets on the market, with over 1,000,000 users. Along with being an extensively used wallet, the platform also acts as a gateway to the decentralized web providing users with a safe way to access the extensive Ethereum ecosystem of dApps. Furthermore, there are several other use cases for MetaMask, one of which is used to acquire and view the token that we are about to create in this article. Moreover, we also need a MetaMask account to hold the tokens that we’ll use to pay for the deployment fee of our token.

Creating a MetaMask account is simple and only takes a couple of minutes. To access MetaMask, we must either download the browser extension or the mobile application. What’s more, Moralis comes with native support for authenticating users with MetaMask when developing your dApps.

Acquire a Blockchain Node

The next step is to acquire a fully functioning blockchain node for the network we want to deploy our token. The node is essential since this is how our projects can interact and communicate with the blockchain. As such, the nodes are crucial since they allow us to deploy our tokens to the blockchain.

Moralis is one of the quickest blockchain node providers currently available. By signing up with Moralis, the process of accessing nodes is easy and straightforward. Moralis offers a service called Speedy Nodes, in which you can access some of the fastest, most reliable nodes on the market. Furthermore, Moralis’ Speedy Nodes currently support four different networks: Ethereum, Polygon, BSC, and Arbitrum. As such, you can also use Moralis to, e.g., create an Arbitrum token in 6 steps, or create a BSC token with lightning speed! 

Once you have an account, all you need to do is navigate yourself to the column at the left-hand side of the Moralis interface, where you’ll find the ”Speedy Nodes” tab. Clicking this alternative will provide you with four different networks. All networks have an ”Endpoints” button. If you click on one of the Endpoints buttons, you’ll be provided with different URLs. These URLs are basically the blockchain nodes that we can use to enable our projects to communicate with the various blockchains. 

Acquire Tokens

The final part before actually developing our token is to acquire the native token of the blockchain we plan to use. So, if we want to create a Polygon token, we must first acquire MATIC tokens. However, since we will be creating an ERC-20 token, we need to acquire Ethereum’s native token, which is Ether.

There are several different ways in which we can acquire Ether. One example is to buy it with fiat currency through a platform such as Coinbase. Another example is to use a decentralized exchange or DEX such as Uniswap to swap one token for another. 

However, there are other ways we can acquire tokens. If we, for example, are planning on deploying a token to the Mumbai Testnet of Polygon, we don’t want to obtain real MATIC. Instead, we want to acquire tokens for the testnet, which enables us to deploy the ERC-20 token to that specific blockchain. This can be done by inputting our crypto wallet address into the following link: https://faucet.matic.network. However, before doing so, we also need to change our MetaMask network to the Mumbai Testnet through the Moralis Speedy Nodes. 

Now that we have a MetaMask account, a Speedy Node, and the native token of the blockchain we are opting for, we can move on to the main topic of this article: ”How to Create Your Own ERC-20 Token in 10 Minutes”. 

How to Create Your Own ERC-20 Token in just 10 Minutes 

Creating an ERC-20 token using Moralis can be accomplished in four different steps:

  1. Setting up the Speedy Node.
  2. Importing an OpenZeppelin package/adding a pragma line.
  3. Create a token contract.
  4. Test if the contract is working correctly.

The complete process is relatively easy; however, we’ll walk you through these four steps to make it as simple as possible. 

Furthermore, for this example, we’ll use the development environment Brownie to create our Ethereum token. However, if you are using another IDE such as Remix, the foundational principles remain the same; the main difference is in the compile and deployment process of the token. So, if you are unfamiliar with Brownie, we recommend our breakdown of Brownie for further information.

Step 1 — Setting Up a Speedy Node

First, connect the framework to the network of our choice. In this example, we are going to use the Ropsten Ethereum Testnet. You need to be logged in at moralis.io. Then, navigate to the Speedy Nodes tab on the Moralis interface. 

Clicking this tab will provide us with the four networks. Since we’ll use Ropsten, we want to press the ”Endpoints” button for the Ethereum network. Then we want to copy the URL for the testnet and save it for later. 

With the URL in hand, we can get back to Brownie and implement the network with the following line of code: 

As you can see, we need to provide a few things. We need the name of the network, the host, Chain ID, and explorer. From the image shown above, you can see that the network’s name is ”ropsten_test”, the host will be equal to the Speedy Node URL, the Chain ID is 3, and the explorer is your EtherScan. 

To ensure that we successfully established the connection between Brownie and Ropsten, we can check by using the ”brownie networks list” command. If we executed everything correctly, the Ropsten network should appear in the list provided. 

Step 2 — Adding Pragma Line and Importing OpenZeppelin Package

With the means for our project to communicate with the Ropsten blockchain established, we can lay the foundation for our contract. We need to do three things: first, we need to add a license identifier, then add the pragma line, and lastly, import the proper OpenZeppelin package. 

  1. License Identifier — The license identifier will determine and signal the licensing status of our token. In this example, we’ll use the MIT license, which is open source and free. To determine our license, we can input the following line of code into our project file:
  2. Pragma Line — Below the license identifier, we can add the pragma line. This will signal which version we’re going to use when compiling the token contract. This is very elementary, and in the example below, we signal that any Solidity version greater than 0.8.0 works:

  3. Importing OpenZeppelin Package — Lastly, to finish the preparations before getting to the contract itself, we must also import the proper OpenZeppelin package. If this isn’t your first time developing with Brownie, you can check if the package has already been installed by typing the following: ”brownie pm list”. This command lists all the installed packages. If the package isn’t installed, we can install it by typing ”brownie pm install xxx”,  where the x:es are replaced with the correct OpenZeppelin version. 

With the package installed, all we need to do is import OpenZeppelin into our code. This might look something like this: 

Step 3 — Creating the Ethereum Token Contract

Seeing as we’ve added the license identifier, pragma line and imported the OpenZeppelin package, we can move on to creating the token itself. As we mentioned previously, we will create an Ethereum contract, and for this example, we’ll call it ”DanielToken”. Consequently, our token looks something like this: 

Creating a token like this is quite simple and is possible with no prior development skill. Templates for all different types of tokens are available on the OpenZeppelin website, allowing us to create tokens effortlessly. 

However, in the example above, the name of the contract is set to “DanielToken”, which is something we can change. Furthermore, the name of the token is specified within the constructor along with the currency symbol. As such, the name is set to ”Daniel” and the symbol is set to ”Dan”. Moreover, within the curly brackets of the constructor, there is a variable called ”initialSupply”. The value of “initialSupply” is determined when we deploy the token. 

Congratulations! That’s all you need to create your own ERC-20 compliant token. All that remains is to check if the token is working correctly. 

Step 4 — Test the Ethereum Token Contract

To check if the contract is working, all we need to do is compile the token. It is essential that we do this before deploying it to the Ropsten network. To compile the contract, input the following command: ”brownie console”. If Brownie compiles the contract successfully, everything is working properly. 

So, with the contract fully functioning, we can deploy the contract onto the desired blockchain. 

How to Create Your Own ERC-20 Token – Deploying the Ethereum Token

So, now that our token is complete, we can move on and deploy the contract to the blockchain. Since we’re using Brownie, the first part of the deployment process involves creating a Brownie account. To create an account, we simply need to input ”brownie accounts new xxx” with the x:es replaced with what you want your account to be called. 

Once the command is executed, Brownie will query us for the private key of our account. We can acquire this key from our MetaMask account by clicking the ”Account details” button in the MetaMask interface. To finalize creating our account, all we need to do is input the key into Brownie, hit enter, and follow the instructions.

Once we have an account, we need to connect to the network by writing the following command: ”brownie -network ropsten_test”. Once the command is executed, the project will launch on the Ropsten Testnet. 

When the project is launched, we need to log in to our account by inputting the following command: ”account = accounts.load(’accountName’)” with the ”accountName” replaced with the name of the account we just created. After this, Brownie will ask for the password that you set earlier. 

When we’re logged in to our Brownie account, we can go ahead and deploy the contract with the following command: ”tokenName.deploy(initialSupply, {’from’:account})”. Here, ”tokenName” should be replaced with the name of our contract. Furthermore, ”initialSupply” should be replaced with whatever we want the initial supply to be.

Once done, we can hit enter. Along with deploying the contract, we’ll also be provided with an address for our tokens. This address is important for viewing our tokens in the future. At this point, you are essentially already done with this guide for how to create your own ERC-20 token!

How to Create Your Own ERC-20 Token – Viewing the Ethereum Token

With our token deployed on the blockchain, we can also add the token to our MetaMask wallet. To do this, we need to copy the address provided to us when deploying the contract. Then we need to change our MetaMask accounts to the correct blockchain, which can be done by clicking the ”Networks” tab at the top of our MetaMask interface.

If you, for example, decided to launch your token on the Mumbai Testnet, you would need to add the network as it won’t appear in the list by default. This is quite simple, all you need to do is have MetaMask installed into your browser, move to the Speedy Nodes tab on Moralis, click the ”Endpoints” button of the desired network, and click ”Add to MetaMask”, which should appear beside the URLs. 

With the correct network chosen, we can move on to the assets tab and hit ”Add Token”. We’ll need to input the contract address, and then MetaMask should auto-fill the other two fields. And finally, we can hit ”Next” to add the token. 

This was the complete process of creating, compiling, testing, and deploying your contract to the blockchain. If anyone asks you, you will now know the four simple steps for how to create your own ERC-20 token in 10 minutes using Moralis! If you still have questions regarding the process, we recommend checking out this video from the Moralis YouTube channel:

How to Create Your Own ERC-20 Token in 10 Minutes — Summary

Creating your own ERC-20 token does not have to be difficult, especially when using Moralis. With Moralis, it is possible to create your own ERC-20 token in just 10 minutes by following this “how to” guide. All you need is to make a few preparations and then follow the following four simple steps: 

  1. Set up a Moralis Speedy Node.
  2. Add a pragma line along with importing the proper OpenZeppelin package.
  3. Create the Ethereum token contract itself.
  4. Test the contract.

Once we complete these steps, all that remains is to deploy the contract and add the newly created tokens to our MetaMask wallet. With Moralis, this process is quick and easy as the platform does most of the heavy lifting for you. In short, the answer to the question “how to create your own ERC-20 token in 10 minutes” is simply Moralis.

Furthermore, the Moralis platform does not only help with creating Ethereum tokens. With a fully managed backend infrastructure from Moralis, it’s possible to shorten the time to market all your blockchain projects. Along with this, the website provides a vast selection of excellent guides. Here are just two of many examples: ”How to Build an NFT Game App in Minutes” or “How to Authenticate Users with WalletConnect”.

So, if you are looking to increase the efficiency when developing your blockchain projects, we highly recommend signing up with Moralis today! You can do so for free, and this will give you access to all the platform’s services, such as the Speedy Nodes used in this article. 

 

Share on facebook
Share on twitter
Share on linkedin
Moralis Blog
Moralis Blog

Related Articles

The latest in Blockchain
Development

Subscribe to the Moralis Magazine, and be the first to find out about the latest Web3 tech!