DEV Community

Abdullah Sheikh
Abdullah Sheikh

Posted on

How to Create an ERC-20 Token on Ethereum: A Complete Step‑by‑Step Guide

Follow this practical checklist and launch your own ERC‑20 token in under an hour

Before We Start: What You'll Walk Away With

By the end of this guide you’ll be able to spin up a custom ERC‑20 token the way you’d order a pizza—pick the toppings, confirm the size, and watch it arrive ready to eat.

You’ll know every piece that makes up an ERC‑20 contract, from the name tag to the balance ledger, so you can explain the code to anyone at a dinner table.

You’ll deploy a working token on a testnet or mainnet using either Remix’s web IDE or Hardhat’s command‑line toolkit, just like swapping a bike for a car when you need more power.

You’ll verify the contract on Etherscan, publish the source, and mint the first batch of coins, similar to checking your grocery receipt and then filling the pantry.

  • Component mastery – Identify name, symbol, decimals, and the core functions transfer, approve, transferFrom.

  • Deploy with confidence – Use Remix’s GUI or Hardhat scripts; both handle compilation, gas estimation, and network selection.

  • Verification & minting – Publish the flattened source on Etherscan, then call mint (or the constructor) to create your initial supply.

  • Tool tip: Keep a small amount of ETH in the deploying wallet—think of it as the tip you leave for the barista.

  • Security reminder: Never expose your private key; treat it like the only key to your house.

Cheat sheet:

  • npm install --save-dev hardhat

  • npx hardhat compile

  • npx hardhat run scripts/deploy.js --network goerli

Now you’re ready to start building—let’s get the basics down first.

What an ERC‑20 Token Actually Is (No Jargon)

ERC‑20 token is a set of rules baked into a smart‑contract on Ethereum that tells the network how many tokens exist, who owns them, and how they move from one address to another. Because every ERC‑20 contract follows the same interface, wallets, exchanges, and dApps can read and interact with any token without custom code.

Think of it like a digital prepaid card that anyone can print and give out. The card works only if it obeys the same three rules: it shows the balance, it lets the holder spend the balance, and it records every transaction. As long as the card follows those rules, a coffee shop, an online store, or a friend can accept it without asking for a new manual.

When you create ERC‑20 token you’re basically designing your own prepaid card—deciding the name, the ticker, the total supply, and then letting the Ethereum network enforce the rules for you.

The 3 Mistakes Everyone Makes With ERC‑20 Tokens

Let’s cut to the chase: most token launches stumble over the same three traps.

  • Skipping OpenZeppelin and coding from scratch. Writing your own ERC‑20 logic is like trying to bake a souffle without a recipe—you’ll end up with a flat mess or a burnt disaster. OpenZeppelin’s audited contracts are the pre‑made batter that guarantees a rise and protects you from overflow bugs, re‑entrancy attacks, and other hidden flaws.

  • Forgetting the correct decimals value. Imagine ordering pizza and the delivery driver thinks each slice is a whole pizza. Set decimals to 18 (or whatever your use case demands) or your token balances will appear off by a factor of 10ⁿ, confusing wallets and investors alike.

  • Deploying to the wrong network. Deploying to a testnet when you meant mainnet is like sending a package to the wrong address and watching it sit in a warehouse forever. Double‑check the chain ID in your deployment script; a simple typo can lock real funds on a network you never intended to use.

Cheat sheet:

  • Use @openzeppelin/contracts for the ERC‑20 base.
  • Set decimals = 18 unless you have a specific reason.
  • Verify network in hardhat.config.js or truffle-config.js before npm run deploy.

Keep these three gotchas out of the way and you’ll be on solid ground to create ERC-20 token without the usual headaches.

How to Create an ERC‑20 Token: Step‑By‑Step

Install Node.js and npm. Think of Node as the kitchen you’ll cook in; npm is the pantry that supplies the ingredients. Download the LTS version from nodejs.org and verify with

node -v
npm -v
Enter fullscreen mode Exit fullscreen mode

.

  • Create a project folder and run npm init -y. It’s like opening a new notebook and stamping the date on the first page. In your terminal:
mkdir my-token
cd my-token
npm init -y
Enter fullscreen mode Exit fullscreen mode
  • Install OpenZeppelin contracts. These are pre‑tested building blocks, similar to buying a ready‑made pizza crust. Run:
npm install @openzeppelin/contracts
Enter fullscreen mode Exit fullscreen mode
  • Write the token contract. Use OpenZeppelin’s ERC20.sol template as a base, then add your name, symbol, and supply. Create contracts/MyToken.sol with:
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("MyToken", "MTK") {
        _mint(msg.sender, initialSupply);
    }
}
Enter fullscreen mode Exit fullscreen mode
  • Compile with Hardhat or Remix. Imagine sending your recipe to a chef for a taste test. For a quick check, open Remix and paste the contract. Example: Alex, a product manager, drops the code into Remix, hits “Compile,” and sees a green check.

  • Deploy to a testnet. This step is like driving a new car on a closed track before hitting the highway. Connect MetaMask to Goerli, add an Infura/Alchemy RPC URL, then run a deployment script:

async function main() {
  const [deployer] = await ethers.getSigners();
  const Token = await ethers.getContractFactory("MyToken");
  const token = await Token.deploy(ethers.utils.parseUnits("1000000", 18));
  await token.deployed();
  console.log("Deployed at", token.address);
}
main();
Enter fullscreen mode Exit fullscreen mode
  • Verify the source code on Etherscan. Think of it as posting the recipe publicly so anyone can double‑check the ingredients. In Etherscan’s “Verify Contract” tab, paste the Solidity code and select the compiler version you used.

  • Mint the initial supply. The constructor already minted tokens to the deployer’s address, but you can add a public mint function for future rounds. Call it via Remix or a script:

await token.mint("0xYourAddress", ethers.utils.parseUnits("500000", 18));
Enter fullscreen mode Exit fullscreen mode
  • Cheat sheet: Node.js ✔️ | npm ✔️ | OpenZeppelin ✔️ | Hardhat/Remix ✔️ | MetaMask ✔️ | Infura/Alchemy ✔️

Follow these steps and you’ll have a working ERC‑20 token ready for testing.

A Real Example: Launching “EduCoin” for an Online Course Platform

Maya runs an e‑learning startup and needs a token that automatically rewards students when they finish a course.

  • She chose the name EduCoin and the symbol EDU, like picking a catchy restaurant name before opening the door.

  • She set 18 decimals, the standard “pizza‑slice” precision on Ethereum.

  • Using Remix, she pasted the contract, hit compile, and deployed to the Goerli testnet—just as you’d order a meal with a single click.

  • After deployment, Maya verified the source on Etherscan so anyone could read the recipe, similar to publishing a menu online.

  • She minted 1 000 000 EDU to her own wallet, filling the token “suitcase” with the exact amount she needs for the first semester.

  • She added the token address to her platform’s wallet integration, letting students see their balance instantly.

  • She wrote a simple script to reward 10 EDU per completed course, automating the giveaway like a vending machine.

  • Finally, she tested the whole flow on Goerli before switching to mainnet, ensuring no surprise ingredients.

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/// @title EduCoin – reward token for online courses
contract EduCoin is ERC20 {
    // creator gets the initial supply
    constructor() ERC20("EduCoin", "EDU") {
        // 1 million tokens with 18 decimals
        _mint(msg.sender, 1_000_000 * 10 ** decimals());
    }
}
Enter fullscreen mode Exit fullscreen mode

That’s how Maya used the step‑by‑step guide to create ERC-20 token ready for her platform.

The Tools That Make This Easier

Grab a coffee and fire up the toolkit that turns token ideas into live contracts.

  • Remix IDE – Think of it as a kitchen counter where you can toss dough (Solidity code) and see the loaf rise instantly. It compiles in the browser, so no local setup, and highlights errors before you bake.

  • Hardhat (2025) – This is your local test drive lane. Like a personal test track, it spins up a private Ethereum network, runs deployment scripts, and lets you fine‑tune gas usage before hitting the highway.

  • Alchemy (free tier) – Imagine Alchemy as the reliable Uber for blockchain data. It supplies fast, throttled‑free node access to Sepolia, Goerli, and mainnet, so your token never gets stuck in traffic.

  • MetaMask – Your digital wallet is the credit card you swipe to pay for gas. The browser extension signs transactions, confirms addresses, and keeps your private key under lock and key.

  • Etherscan Verify API – Think of it as Google Maps’ “Show route” button. One click uploads your source, matches it to the bytecode, and publishes a readable contract page for anyone to audit.

With these five pieces you can create ERC-20 token without juggling dozens of scripts or chasing down node providers.

Next up, we’ll walk through the actual deployment steps.

Quick Reference: ERC‑20 Token Cheat Sheet

Grab this cheat sheet, print it, and you’ll have the whole create ERC‑20 token workflow on a single page.

  • ✅ Install Node & npm – think of it like setting up a kitchen. Run npm init -y to get a clean recipe book.

  • ✅ Add OpenZeppelin – the pre‑made ingredients. npm i @openzeppelin/contracts pulls in battle‑tested code.

  • ✅ Contract skeleton – define name, symbol, decimals, and totalSupply. It’s like labeling a suitcase before you pack.

  • ✅ Compile with Hardhat or Remix – the “Google Maps” that tells you if the route (code) is drivable.

  • ✅ Deploy via MetaMask + Alchemy RPC – picture Alice sending a parcel. She connects MetaMask, selects the Alchemy endpoint, and clicks “Send”.

  • ✅ Verify on Etherscan – attach a receipt. Provide your Etherscan API key so the contract appears publicly.

  • ✅ Mint or set initial supply in constructor – the “first batch” of tokens, similar to ordering the opening stock of a new café.

  • ✅ Test transfer with erc20.transfer(address, amount) – a quick “hand‑off” to confirm the token moves like a real cash tip.

  • Tools: Node, npm, Hardhat/Remix, MetaMask, Alchemy, Etherscan API.

  • Key Files: package.json, contracts/MyToken.sol, hardhat.config.js.

  • Common Pitfalls: forgetting pragma solidity version, mismatched decimals, not verifying on Etherscan.

  • Quick Test: after deployment, run erc20.balanceOf(yourAddress) to see your fresh tokens.

Keep this list handy; the next token you launch will feel as easy as ordering coffee.

What to Do Next

Ready to put your new ERC-20 token to work? Here are three practical next steps, from quick wins to bigger projects.

  • Mint more tokens instantly. Open Remix, switch to the JavaScript VM, and call the mint function with the amount you want. It’s like topping off a coffee cup—just a few clicks and you’ve got extra supply without leaving the page.

  • Add a pausable mechanism. Pull in OpenZeppelin’s Pausable contract and inherit it in your token. Then expose pause() and unpause() to the owner. Think of it as a “pause button” on a video player; you can stop all transfers if something looks fishy, then resume when it’s safe.

  • Integrate with DeFi or launch a liquidity pool. Deploy a staking contract that rewards holders, or create a pair on Uniswap and add initial liquidity. This step is like packing a suitcase for a trip—you need to balance tokens, ETH, and a little gas, then lock everything in a secure spot before you head out.

  • Tool tip: Use npm install @openzeppelin/contracts to fetch the latest contracts before you start.

  • Gas saver: Test all calls on Remix’s JavaScript VM first; it’s free and lets you catch errors early.

  • Cheat sheet: Keep a .env file with your private key and RPC URL—never paste them into public repos.

Got stuck or want to share your token launch story? Drop a comment below!



About the Author

Abdullah Sheikh is the Founder & CEO at Exteed, where he leads a team of skilled developers specializing in Web2 and Web3 applications, Custom Smart Contracts, and Blockchain solutions.

With 6+ years of experience, Abdullah has built CRMs, Crypto Wallets, DeFi Exchanges, E-Commerce Stores, HIPAA Compliant EMR Systems, and AI-powered systems that drive business efficiency and innovation.

His expertise spans Blockchain, Crypto & Tokenomics, Artificial Intelligence, and Web Applications; building reliable and smooth web apps that fit the client’s goals and requirements.

📧 info@abdullah-sheikh.com · 🔗 LinkedIn · 🌐 abdullah-sheikh.com

Top comments (0)