π How To Deploy An Erc 20 Token
Details
Do you want to launch your own cryptocurrency like USDT or SHIBA? This guide will show you how to create and deploy your own ERC-20 token using Remix IDE and MetaMask, without any deep coding background. This tutorial uses testnet so itβs 100% risk-free. You can later repeat the steps on the Ethereum mainnet with real ETH.
π¦ What Is an ERC-20 Token?
An ERC-20 token is a smart contract on Ethereum that defines a set of rules and functions (like transfer
, balanceOf
, etc.) that every compatible token must implement. This makes ERC-20 tokens widely accepted in wallets and exchanges.
π§° Prerequisites Checklist
Make sure you have the following ready:
β A browser with MetaMask extension installed β Access to Remix IDE β Some test ETH from a faucet (e.g., Goerli testnet) β A basic understanding of Ethereum & Solidity
π Step 1: Set Up MetaMask
- Go to https://metamask.io and install the browser extension.
- Create a new wallet and backup the recovery phrase.
- Switch the network from βEthereum Mainnetβ to a test network like:
- Goerli Testnet
- Sepolia Testnet
- Get free test ETH from a faucet:
- Goerli Faucet: https://goerlifaucet.com
- Sepolia Faucet: https://sepoliafaucet.com
π» Step 2: Open Remix IDE and Create Your Contract
- Go to https://remix.ethereum.org
- In the File Explorer, create a new file called
MyToken.sol
- Paste the following ERC-20 code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("MyToken", "MTK") {
_mint(msg.sender, initialSupply * (10 ** decimals()));
}
}
π This contract uses OpenZeppelin β a secure, audited contract library.
MyToken
= token nameMTK
= token symbolinitialSupply
is passed in during deploymentdecimals()
defaults to 18
π§ͺ Step 3: Compile the Contract
- On the left sidebar, click the Solidity Compiler tab.
- Choose compiler version
0.8.20
or newer. - Click Compile MyToken.sol. You should see a green checkmark.
π Step 4: Connect MetaMask and Deploy
- Click the Deploy & Run Transactions tab.
- Under βEnvironmentβ, select Injected Provider - MetaMask
- Remix will ask MetaMask to connect. Approve it.
- Select the contract
MyToken
from the dropdown. - In the constructor input, enter an initial supply (e.g.,
1000000
) - Click Deploy
- MetaMask will pop up β approve the transaction.
β Your contract is now deployed on testnet!
π¬ Step 5: Add Token to MetaMask
- In MetaMask, go to the Assets tab.
- Click βImport tokensβ
- Paste the contract address Remix gives you.
- MetaMask should auto-fill token name and decimals.
- Confirm β your tokens will show up!
π§ Step 6: Optional Advanced Features
If you want to add more advanced capabilities to your token contract, consider:
burnable
: allow users to burn (destroy) tokensmintable
: allow owner to mint more tokens laterownable
: restrict admin actionspausable
: allow emergency stop
Example with burnable:
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
contract MyToken is ERC20, ERC20Burnable { ... }
π Step 7: Redeploy on Ethereum Mainnet (For Real)
Once you’re confident in your contract:
- Switch MetaMask to βEthereum Mainnetβ
- Buy some ETH from an exchange and transfer to your wallet
- Go back to Remix and repeat the same deployment process
- This time you’ll spend real ETH and deploy to mainnet
β οΈ Be very careful! Contracts on mainnet cannot be changed or undeployed.
β Common Errors & Solutions
Error | Solution |
---|---|
contract not found in MetaMask |
Make sure you selected the right contract and compiled |
insufficient funds |
Ensure testnet ETH is in MetaMask |
invalid constructor arguments |
Double-check you entered an integer (like 1000000 ) |
π Resources
- MetaMask: https://metamask.io
- Remix IDE: https://remix.ethereum.org
- OpenZeppelin Contracts: https://github.com/OpenZeppelin/openzeppelin-contracts
- Token explorer: https://goerli.etherscan.io or https://etherscan.io
β Summary
π Youβve successfully created and deployed an ERC-20 token! With this skill, you can:
- Launch your own cryptocurrency
- Reward users in dApps or games
- Learn blockchain development hands-on
Youβre one step closer to becoming a smart contract developer.
Want to go deeper? Try adding a token sale, staking, or governance system next!