Developers 🔧
Standard
ERC-20: Fungible Tokens

Deploying an ERC-20 Token Using Remix and OpenZeppelin

This guide walks you through deploying an ERC-20 token using Remix, an online Solidity IDE, and OpenZeppelin, a library of secure and reusable smart contract templates.

Prerequisites

  1. Open the Remix IDE.
  2. Install the MetaMask extension and configure it to connect to the Xone testnet.
  3. Fund your MetaMask wallet with Test XOC from a Faucet.

Let’s get started

Step 1: Create the ERC-20 Contract.

  1. In Remix, create a new file in the contracts folder and name it example.sol.

  2. Add the following code to example.sol:

example.sol
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.22;
 
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
 
contract Test is ERC20, ERC20Permit {
    constructor() ERC20("example", "EXAMPLE") ERC20Permit("example") {
        _mint(msg.sender, 10000 * 10 ** decimals());
    }
}
 
Create ERC-20
ℹ️

Change the parameters in the constructor to customize the token:

name: The name of your token. example

symbol: The symbol of your token. EXAMPLE

initialSupply: The initial supply of your token 10000(in whole units, it will be multiplied by 10^decimals() within the contract).

In this example, the token name is "example", the symbol is "EXAMPLE", and the initial supply is 10,000 tokens.

Step 2: Compile the Contract.

  1. Click on the 【Solidity Compiler】 tab on the left sidebar.

  2. Select the appropriate compiler version (0.8.x).

  3. Click on 【Advanced Configuration】 to expand the advanced settings.

  4. Choose EVM Version 【paris】.

  5. Enable optimization (default 200)

  6. Click 【Compile example.sol】.

Create ERC-20_1

Step 3: Deploy the Contract.

  1. Click on the 【Deploy & Run Transactions】 tab on the left sidebar.

  2. Set the environment to Injected Provider - MetaMask if you are using MetaMask, or JavaScript VM for a simulated environment.

  3. Click 【Deploy】.

Create ERC-20_2

Step 4: Expand the Deployed Contract.

  1. In the Deployed Contracts section, find the contract you just deployed.

  2. Click on the contract name to expand it. This will show you a list of available functions and variables that you can interact with.

  3. Check smart contract address (e.g.: 0xb1a04485443d937e8eEbd260AE954BC3C006422F).

Create ERC-20_3

Step 5: Add the Token to MetaMask.

  1. Open MetaMask and click 【Import Tokens】.

  2. Paste the contract address (in this case 0xb1a04485443d937e8eEbd260AE954BC3C006422F) of your deployed token.

  3. MetaMask will auto-detect the token symbol and decimals. Click 【Add Custom Token】.

  4. Check your token balance.

Create ERC-20_4

Step 6: Congratulations! You have completed the ERC-20 contract creation.