A token can be a digital currency, an ounce of gold, a lottery ticket, or even a piece of art. You can develop all kinds of tokens on the Ethereum blockchain, but in this tutorial, we will focus on how to create an ERC20 token and deploy it on the Ethereum blockchain.
The launch of the Ethereum network in 2015 caused a lot of buzz in the developer community and generated many tokens on the network. Initially, there were no templates or guidelines for token development.
This resulted in a variety of tokens that are wildly different from each other. To put this diversity in order, the community created an ERC20 standard to make all tokens more or less uniform.
Despite the fact that Bitcoin is the most valuable cryptocurrency in terms of market capitalization, Ethereum outperforms it in terms of dApp development.
Ethereum is the world’s largest smart contract-enabled blockchain, with a thriving ecosystem of dApps (decentralized applications).
The ERC20 tokens used by these dApps and DeFi applications are based on the Ethereum blockchain.
Ethereum also gave birth to the EVM (Ethereum Virtual Machine), which is currently widely used by other prominent chains like Polygon.
As a result, numerous blockchains have adopted the Ethereum ERC20 token standard for their own networks.
That being said, we’ll take a deeper look at how to create an ERC20 token in just 10 minutes.
Now you might be thinking; “how can I create an ERC20 Token in less than 15 minutes? What kind of sorcery is that?”,
The Moralis tool we would be using for this tutorial isn’t sorcery or magic; it’s just Moralis.
By using the correct tools, creating an ERC20 Token does not have to be complicated.
This free online software is the finest tool for this purpose because it takes care of all the heavy lifting on the backend.
Moralis is quickly becoming the best Web3 development platform, as it includes everything you need to create and deploy your own dApps and tokens.
As a result, in this tutorial, we’ll use Moralis to create an ERC20 token in just 10 minutes.
Moralis also includes a number of other useful tools that can be used throughout the development process.
One example is the Moralis Speedy Node, which we will employ to create an ERC20 Token.
Moralis also provides a completely managed backend architecture, allowing you to focus on the frontend as a developer.
Moralis is here to assist you, whether you’re developing dApps or producing tokens. Join Moralis for free and start using the platform’s features right away!
What are ERC20 Tokens?
The term “ERC20” refers to the Ethereum blockchain’s scripting standard. This technical standard specifies a set of rules and activities that an Ethereum token or smart contract must adhere to, as well as the processes necessary to put them in place.
Tokens are one of the most important characteristics of the Ethereum blockchain and decentralized applications (dApps).
ERC20 tokens can be used to represent almost anything in the Ethereum ecosystem.
Lottery tickets, points on an online platform, game character skills, fiat currency, and so forth are some examples.
This function is highly powerful and requires regulation, which is why the ERC20 was created.
The ERC20 standard guarantees that all coins have the same characteristics. This also means that tokens are interchangeable because they are of the same kind and value.
As a result, ERC20 tokens are fungible, allowing us to quantify a token’s worth and compare it to another. But what does this signify in terms of the tokens themselves?
The ERC20 standard defines a smart contract API for tokens. Developers can use the API to specify a total token supply, retrieve token balances from accounts, and move tokens from one account to another.
These are only a few of the characteristics of an ERC20 token. To be considered an ERC20 token, a token must implement the following methods and events:
Methods:
Events:
How Do I Create an ERC20 Token?
The easiest way to create an ERC20 Token is by using the Moralis tool, just as we mentioned in the beginning.
As a Moralis user, you may reduce development time to a bare minimum and make the process painless. Before we go into how to create your own ERC20 token, there are a few things to consider:
- MetaMask: First and foremost, we must create a MetaMask account.
- Node: Secondly, we’ll need to get our hands on a fully functional blockchain node for the network we’re working with.
- Obtain Tokens: The third step is to obtain tokens. The tokens we need to collect are determined by the blockchain we’re using to create our ERC20 token. We must do so in order to pay the fees associated with deploying the tokens to the blockchain.
So, let’s get this party started by creating a MetaMask account.
How to Setup a MetaMask Account
The whole detailed step-by-step instructions for setting up your MetaMask Wallet on your browser may be found below.
- Install the MetaMask wallet on your Chrome browser.
- Select the Metamask Extension from the drop-down menu.
- Get started now.
- Make Your Own Wallet
- After reading all of the Terms and Conditions, click “I Agree.”
- Make a password
- Keep a copy of your backup phrase.
- Double-check your backup phrase.
- MetaMask should be used right away.
With over 1,000,000 users, MetaMask is one of the most popular cryptocurrency wallets on the market.
Along with being a widely used wallet, the platform also serves as a decentralized web gateway, giving users a secure means to access the Ethereum ecosystem of dApps.
Furthermore, MetaMask has a variety of other applications, one of which is the acquisition and viewing of the token that we are about to produce in this post.
We’ll also need a MetaMask account to store the tokens we’ll use to pay for our token’s deployment cost.
It’s easy to set up a MetaMask account, and it only takes a few minutes. We must either download the browser extension or the mobile application to use MetaMask.
Furthermore, when designing your dApps, Moralis has native support for authenticating users with MetaMask.
Acquire a Blockchain Node
The next step is to purchase a fully functional blockchain node for the network where our token will be deployed.
The node is crucial because it is via it that our projects will be able to interact and communicate with the blockchain.
As a result, nodes are critical since they enable us to send our tokens to the blockchain.
Moralis is now one of the fastest blockchain node providers available. The method of gaining access to nodes is simple and straightforward after signing up with Moralis.
Moralis provides a service called Speedy Nodes, which allows you to connect to some of the quickest and most dependable nodes available.
Moralis’ Speedy Nodes also handle four alternative networks at the moment: Ethereum, Polygon, BSC, and Arbitrum.
As a result, you may utilize Moralis to create an Arbitrum token in six steps or a BSC token in a matter of seconds.
Once you’ve created an account, all you have to do is go to the “Speedy Nodes” tab in the column on the left-hand side of the Moralis interface.
By selecting this option, you will be presented with four different networks. The “Endpoints” button is available on all networks.
You’ll be given different URLs if you click one of the Endpoints buttons.
These URLs are essentially blockchain nodes, which we can use to connect our projects to different blockchains.
Obtain Tokens
Before we begin constructing our token, we must first obtain the native token of the blockchain we intend to employ.
So, if we want to make a Polygon token, we’ll need MATIC tokens first. However, because we’ll be producing an ERC20 token, we’ll need to get our hands on Ether, Ethereum’s native coin.
We can obtain Ethereum in a number of different methods. One option is to purchase it using fiat currency through a platform like Coinbase.
Another option is to swap one coin for another via a decentralized exchange (DEX) like Uniswap.
There are, however, various options for obtaining tokens. We don’t want to get actual MATIC if we’re aiming to deploy a token on the Polygon Mumbai Testnet, for example.
Instead, we’d like to buy tokens for the Testnet, which will allow us to use the ERC20 token on that blockchain.
This may be done by going to https://faucet.matic.network and entering our crypto wallet address.
However, we must first switch our MetaMask network to the Mumbai Testnet by using the Moralis Speedy Nodes.
We can continue on to the main content of this post, “How to Create Your Own ERC20 Token in 10 Minutes,” now that we have a MetaMask account, a Speedy Node, and the native token of the blockchain we’ve chosen.
How to create your own ERC20 Token in just 15 minutes
Moralis may be used to create an ERC20 token in four distinct ways:
- Setting up the Speedy Node
- Importing an OpenZeppelin package/adding a pragma line
- Create a token contract.
- Check to see if the contract is working properly.
The entire procedure is basic; nevertheless, we’ll walk you through these four steps to make it even simpler.
In addition, we’ll construct our Ethereum token using the Brownie development environment in this example.
The core ideas stay the same whether you use another IDE, such as Remix; the only difference is in the token’s build and deployment process.
STEP ONE: Setting Up a Speedy Node
Connect the framework to the network of our choosing first. The Ropsten Ethereum Testnet will be used in this scenario.
To use moralis.io, you must be logged in. Then, on the Moralis interface, go to the Speedy Nodes tab.
The four networks can be accessed by clicking this tab. We’ll press the “Endpoints” button for the Ethereum network because we’ll be using Ropsten. Then we’ll copy the Testnet URL and save it for later use.
With the URL in hand, we can return to Brownie and use the following line of code to set up the network:
As you can see, we’ll need to supply a few items. The network name, host, Chain ID, and explorer are all required.
The network’s name is “ropsten_test,” the host is equivalent to the Speedy Node URL, the Chain ID is 3, and the explorer is your EtherScan, as seen in the figure above.
Using the “brownie networks list” command, we can verify that the connection between Brownie and Ropsten was properly created.
The Ropsten network should appear in the list if we followed the steps correctly.
STEP TWO: Importing OpenZeppelin Package and Adding Pragma Line
We can start laying the groundwork for our contract now that we have a way for our project to communicate with the Ropsten blockchain.
We need to do three things: add a licensing identification first, then the pragma line, and finally, import the right OpenZeppelin package.
- License Identifier: Our token’s licensing status will be determined and signalled by the license identifier. We’ll utilize the MIT license, which is open source and free, in this example. We may use the following line of code in our project file to identify our license:
- Pragma Line: The pragma line can be added below the license identifier. This will indicate which version of the token contract we’ll use while constructing it. This is pretty basic, and in the example below, we indicate that any version of Solidity greater than 0.8.0 will work:
- Importing OpenZeppelin Package: Finally, before moving on to the contract, we must import the correct OpenZeppelin package to complete the preparations. If this isn’t your first time working with Brownie, use the command “brownie pm list” to see if the package has already been installed. This command displays a list of all the packages that have been installed. If the package isn’t already installed, type “brownie pm install xxx,” replacing the x:es with the appropriate OpenZeppelin version.
All we have to do now is import OpenZeppelin into our code once the package has been installed. This could resemble the following:
STEP THREE: Creating the Ethereum Token Contract
We may proceed to create the token now that we’ve inserted the licensing identification, pragma line, and imported the OpenZeppelin package.
As previously said, we will establish an Ethereum contract, which we will refer to as “DanielToken” in this example. As a result, our token appears to be as follows:
Creating a token like this is simple and requires no prior programming experience. The OpenZeppelin website has templates for various types of tokens, allowing us to generate tokens quickly and easily.
The contract’s name is set to “DanielToken” in the example above, which is something we may alter.
In addition, the constructor specifies the token’s name as well as the currency symbol.
As a result, the name is “Daniel,” and the symbol is “Dan.” There is also a variable called “initialSupply” within the constructor’s curly braces.
When we deploy the token, the value of “initialSupply” is calculated.
Congratulations! That’s all you’ll need to make your own ERC-20 token. All that’s left is to see if the token is functioning properly.
STEP FOUR: Testing the Ethereum Token Contract
All we have to do now is build the token to see if the contract is working. This must be done before it can be deployed on the Ropsten network. Input the following command to compile the contract: “brownie console.” Everything is in order if Brownie successfully compiles the contract.
So, now that the contract is completely functional, we can deploy it on the blockchain of our choice.
How to Create Your Own ERC-20 Token: Deploying the Ethereum Token
Now that we have our token, we can go on to deploying the contract on the blockchain. Because we’ll be using Brownie, the first step in the deployment is to create a Brownie account.
To establish an account, simply type “brownie accounts new xxx,” replacing the x:es with the name you want for your account.
Brownie will ask us for our account’s private key once the command has been run.
By clicking the “Account details” button in the MetaMask interface, we can get this key from our MetaMask account.
All we have to do now is type the key into Brownie, hit enter, and follow the prompts to complete our account creation.
Once we’ve created an account, we’ll need to join the network by typing “brownie -network ropsten_test.” The project will be launched on the Ropsten Testnet after the command is run.
After the project has been launched, we must log in to our account by typing “account = accounts.load(’accountName’)” with the name of the account we just created substituted with “accountName.” Brownie will then ask you for the password you set previously.
When we’re signed in to our Brownie account, we can use the command “tokenName.deploy(initialSupply, {’from’:account})” to deploy the contract.
The name of our contract should be substituted for “tokenName” below. In addition, “initialSupply” should be substituted with whatever the initial supply should be.
After that, we can press enter. We’ll be given an address for our tokens in addition to the contract being deployed.
This address will be required in the future to view our tokens. You’re almost finished with this guide on how to make your own ERC-20 token at this point!
How to Create Your Own ERC-20 Token: Viewing the Ethereum Token
We can now add our token to our MetaMask wallet after it has been launched on the blockchain. To do so, we’ll need to copy the address provided to us when the contract was deployed.
Then we must switch our MetaMask accounts to the correct blockchain by going to the “Networks” option at the top of our MetaMask screen.
If you wanted to deploy your token on the Mumbai Testnet, for example, you’d have to add the network because it won’t show up in the list by default.
All you have to do is install MetaMask in your browser, go to the Speedy Nodes tab on Moralis, select the “Endpoints” button of the desired network, and then click “Add to MetaMask,” which should show beside the URLs.
After we’ve selected the suitable network, we can go to the Assets tab and click “Add Token.”
We’ll need to enter the contract address first, then MetaMask should fill in the other two entries automatically. Finally, we may add the token by pressing “Next.”
The entire process of writing, building, testing, and deploying your contract to the blockchain was covered in this article.
If someone asks, you now know how to generate your own ERC-20 token in 10 minutes using Moralis in four simple steps! If you have any additional queries, we recommend watching this video from the Moralis YouTube channel:
Summary of How to Create ERC20 Token
It is not difficult to create your own ERC-20 token, especially when using Moralis. By following this “how-to” instruction, you will learn how to create ERC20 Token in only 15 minutes with Moralis.
All you have to do now is make a few preparations and then follow the four simple procedures below:
- Set up a Speedy Node using the Moralis tool
- Add a pragma line along with importing the proper OpenZeppelin package
- Create the Ethereum Token contract
- Test the contract
All that’s left is to deploy the contract and add the freshly minted tokens to our MetaMask wallet once we’ve completed these procedures.
This procedure is quick and simple with Moralis because the platform handles the majority of the heavy lifting for you.
Moralis is, in a nutshell, the answer to the question “how to create ERC20 Token step by step.”
In addition, Coinscreed offers a large number of great guides. “How to trade NFTs without gas fees” and “How much does a crypto mining rig cost?” are just two of many examples.