KCC Documents
English
Search…
⌃K

Issue ERC20 Token

Overview

ERC-20 is the technical standard for fungible tokens created on the EVM-compatible blockchain. An ERC20 token contract keeps track of fungible tokens: any token is exactly equal to any other token; no tokens have special rights or behavior associated with them. This makes ERC20 tokens useful for things like a medium of exchange currency, voting rights, staking, and more.
As we know, both OpenZeppelin and ConsenSys maintain the standard library of ERC contract classes. Simply put, ERC20 is nothing more than a class with methods and members that run the logic of what we usually call cryptocurrency. However, it has a broader meaning because it also has applications in other use cases.
Having explained why we imported the OpenZeppelin library and what ERC20 means, let's move on to learning how to create and deploy an ERC20 token with the OpenZepplin library.
Note
Additionally, OpenZeppelin offers some ERC20 extension contracts. Please review the details if you are interested.

Pre-requisites

  • Install Metamask
  • Configure KuCoin Community Chain Testnet on Metamask
  • Get Testnet token

Compile and Deploy ERC20 Token

Open Remix IDE: https://remix.ethereum.org/

Create the contract

  • Create a new Token.sol contract and copy the below contract code to Token.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract KIP20Token is ERC20 {
constructor(uint256 totalSupply) ERC20("DemoToken", "DET") {
// create totalSupply of tokens for the deployer
_mint(msg.sender, totalSupply);
}
}

Compile the contract

  • switch to the compile page
  • Select proper compiler
  • Select KIP20Token(Token.sol) contract
  • And then click Compile Token.sol

Compile the contract

  • Click the button to switch to compile button
  • Select Injected Provider-MetaMask
  • Select KIP20Token-Token.sol
  • Fill in many tokens you want to mint and click Deploy button
  • Click Confirm button to sign and broadcast the transaction to KCC Testnet

Add custom token to MetaMask

  • Copy the deployed contract address
  • Click Import Tokens
  • Paste the contract address to the Token contract address
  • And the Token symbol and Token decimal will auto tilled by MetaMask
  • Finally, Click the Add custom token
  • Click the Import tokens button
  • When you reopen the MetaMask next time, you will see the token and amount

Conclusion

This tutorial guides you through the basics of creating and deploying an ERC20 token contract based on the OpenZepplin library using the Remix IDE on the KCC Testnet. It should be noted that the exact same instructions and sequence will also work on KCC Mainnet.