SolidityIn

How to Build and Deploy an ERC-20 Token in Under 20 Minutes

October 31, 2026 · admin · Uncategorized

Creating your own cryptocurrency sounds like a monumental task reserved for elite blockchain architects. However, with modern developer tools like OpenZeppelin and the browser-based Remix IDE, you can write, compile, and deploy a secure, industry-standard ERC-20 token to an Ethereum testnet in less time than it takes to brew a pot of coffee.

 

 

Prerequisites (Time: 2 Minutes)

 

Before writing code, make sure you have the following ready:

 

    • MetaMask Wallet: Installed as a browser extension.

 

    • Sepolia Testnet ETH: Testnet Ether is free. You can request it from faucets like Google Cloud Web3 Faucet, Alchemy Sepolia Faucet, or Infura.

 

    • A Web Browser: Chrome, Brave, or Firefox.

 

 

 

Step 1: Open Remix IDE (Time: 1 Minute)

 

Navigate to remix.ethereum.org.
Remix is an open-source Ethereum development environment that runs completely inside your browser—no local installations, Node.js setups, or CLI configurations required.

 

    1. In the left sidebar, click on the File Explorer icon.

 

    1. Under the contracts folder, click the New File icon.

 

    1. Name the file MyToken.sol.

 

 

 

Step 2: Write the Smart Contract (Time: 5 Minutes)

 

Never write token logic from scratch. Implementing custom math or transfer mechanics introduces dangerous attack vectors. Instead, inherit battle-tested contracts provided by OpenZeppelin.

 

Paste the following code into MyToken.sol:

 

<pre><code class="language-solidity">// SPDX-License-Identifier: MIT

 

pragma solidity ^0.8.20;

 

import “@openzeppelin/contracts/token/ERC20/ERC20.sol”;
import “@openzeppelin/contracts/access/Ownable.sol”;

 

contract MyToken is ERC20, Ownable {
/**

 

    • @dev Constructor that gives msg.sender all of existing tokens.
      /
      constructor(uint256 initialSupply) ERC20(“MyToken”, “MTK”) Ownable(msg.sender) {
      // Mints tokens with 18 decimal places standard
      _mint(msg.sender, initialSupply
      10 ** decimals());
      }

 

 

/**
 * @dev Function to mint more tokens, restricted to contract owner
 */
function mint(address to, uint256 amount) public onlyOwner {
    _mint(to, amount);
}

 

}

 

<div class="callout">
  <strong>Key Details:</strong>
  <ul>
    <li><code>ERC20("MyToken", "MTK")</code>: Defines the token name ("MyToken") and symbol ("MTK"). Change these to whatever you prefer.</li>
    <li><code>decimals()</code>: Defaults to <code>18</code> in OpenZeppelin, matching the divisibility of Ethereum.</li>
    <li><code>_mint()</code>: Automatically generates the initial supply and sends it directly to your wallet.</li>
  </ul>
</div>

 

 

Step 3: Compile the Contract (Time: 2 Minutes)

 

    1. Click on the Solidity Compiler icon in the left navigation panel (the icon resembles the Solidity ‘S’ logo).

 

    1. Ensure the compiler version matches your pragma directive (e.g., 0.8.20 or higher).

 

    1. Click Compile MyToken.sol.

 

    1. Wait for the green checkmark to appear next to the compiler icon, confirming error-free compilation.

 

 

 

Step 4: Deploy to Sepolia Testnet (Time: 5 Minutes)

 

    1. Switch your MetaMask wallet network from Ethereum Mainnet to Sepolia.

 

    1. In Remix, click the Deploy & Run Transactions icon (the Ethereum icon with an arrow).

 

    1. Under the Environment dropdown, select Injected Provider – MetaMask.

 

    1. A MetaMask prompt will appear. Approve the connection to Remix.

 

    1. Under the Contract dropdown, make sure MyToken - contracts/MyToken.sol is selected.

 

    1. Next to the orange Deploy button, enter your desired initial supply in the input field (e.g., 1000000 for 1 million tokens).

 

    1. Click Deploy (or transact).

 

    1. MetaMask will open requesting confirmation. Click Confirm to pay the test gas fee.

 

 

 

Step 5: View & Import Your Token (Time: 3 Minutes)

 

Once the transaction is mined (usually 10–15 seconds):

 

    1. Look at the bottom of the Remix deployment panel under Deployed Contracts.

 

    1. Click the copy icon next to your contract name to copy the deployed contract address.

 

    1. Open MetaMask, navigate to the Tokens tab, and click Import Tokens.

 

    1. Paste your copied contract address. MetaMask should automatically detect the token symbol (MTK) and decimals (18).

 

    1. Click Next → Import.

 

 

Congratulations! Your wallet balance should now reflect your freshly minted token supply.

 

 

Production Considerations (Before Going to Mainnet)

 

Deploying to a testnet is risk-free, but before launching on Ethereum Mainnet, Arbitrum, Base, or Polygon with real funds:

 

    • Contract Verification: Use the Etherscan plugin on Remix to verify your source code so the community can audit it on block explorers.

 

    • Access Control: Make sure sensitive functions (like mint() or pause()) are protected using OpenZeppelin’s Ownable or AccessControl.

 

    • Security Audits: If real capital is involved, hire professional auditors or leverage automated analysis tools like Slither and Mythril.

 

 

 

Summary

 

By utilizing Remix and OpenZeppelin, the barrier to deploying blockchain assets has dropped dramatically. In under 20 minutes, you have coded a secure smart contract, deployed it onto a public blockchain, and held the initial tokens in your Web3 wallet.

 

 

Tags: , , ,