This guide will teach you how to create an ERC20 token on the Polygon network.
The first step is to get a polygon node. You can get a Polygon node through Moralis.io. Moralis is a leading Web3 development platform for building high-performance dapps.
Go to the speedy nodes tab and add both the mainnet endpoints and the Mumbai testnet to your Metamask.
The second step is to get some test tokens. Test token is needed to pay transaction fees on the network. You can get testnet token from this faucet: https://faucet.polygon.technology/
The third step is to program your own smart contract. Head to https://remix.ethereum.org. Remix is an open-source web and desktop application that has a rich set of plugins with intuitive GUIs.
An ERC20 token is also a standard for creating Smart Contracts and there are plenty of templates available for use on Remix.
On the left tab of Remix, right-click on contracts and then add a new file. For this tutorial can just name it Token.sol.
We will use the OpenZeppelin contracts in Remix because all the smart contracts from OpenZeppelin are secure and battle tested.
The fourth step is to paste the following code on the Token.sol file:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract EnratsToken is ERC20 {
uint256 constant _initial_supply = 100 * (10**18);
constructor() ERC20("Enrats Token", "ERT") {
_mint(msg.sender, _initial_supply);
}
}
Step five is to flatten and save the contract. Flattening the smart contract will combine all Solidity code into one file.
Step 6 is to copy the License to the flattened .sol file and then paste it onto the flattened file.
// SPDX-License-Identifier: MIT
Last but not least, it’s time to deploy the Smart Contract.
Once the Smart Contract has been successfully deployed, it can be verified on Remix itself and on Polygonscan.
It’s just that simple! Next up, let’s learn about Cross-Chain tokens.