How to Create Your Own Cryptocurrency Token
A practical guide to creating and deploying your own token on Ethereum using the ERC-20 standard, from writing the smart contract to deployment.
In this guide
Token vs. Coin
Before creating a token, it's important to understand the distinction:
Coin โ A cryptocurrency that runs on its own blockchain (e.g., Bitcoin on the Bitcoin blockchain, ETH on Ethereum). Creating a coin requires building or forking an entire blockchain.
Token โ A digital asset that runs on an existing blockchain (e.g., USDT and UNI run on Ethereum). Tokens are created via smart contracts and leverage the host blockchain's infrastructure.
This guide focuses on creating a token, which is far more accessible and practical for most use cases.
Understanding ERC-20
ERC-20 is the most widely adopted token standard on Ethereum. It defines a set of functions that every compliant token contract must implement:
// Core ERC-20 interface
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
This standardization is critical โ it means wallets, exchanges, and DeFi protocols can automatically support any ERC-20 token without custom integrations.
Writing the Smart Contract
Here's a complete ERC-20 token contract using OpenZeppelin (the industry-standard library):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC20, ERC20Burnable, Ownable { constructor( string memory name, string memory symbol, uint256 initialSupply ) ERC20(name, symbol) Ownable(msg.sender) { _mint(msg.sender, initialSupply * 10 ** decimals()); }
function mint(address to, uint256 amount) public onlyOwner { _mint(to, amount); } } ```
This contract gives you: - A named token with a symbol (e.g., "My Token" / "MTK") - An initial supply minted to the deployer - The ability to burn tokens (permanently remove from circulation) - Owner-restricted minting of new tokens
Setting Up Your Development Environment
You'll need these tools:
1. Node.js โ Runtime for JavaScript tooling (v18+)
2. Hardhat โ Development framework for Ethereum:
``bash
mkdir my-token && cd my-token
npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init
``
3. OpenZeppelin Contracts:
``bash
npm install @openzeppelin/contracts
``
4. MetaMask โ Browser wallet for deploying and interacting with your contract.
5. Test ETH โ Get free test ETH from a Sepolia faucet to deploy without spending real money.
Deploying Your Token
Create a deployment script in scripts/deploy.js:
const { ethers } = require("hardhat");async function main() { const Token = await ethers.getContractFactory("MyToken"); const token = await Token.deploy("My Token", "MTK", 1000000); await token.waitForDeployment(); console.log("Token deployed to:", await token.getAddress()); }
main().catch(console.error); ```
Deploy to a testnet first:
``bash
npx hardhat run scripts/deploy.js --network sepolia
``
After testing thoroughly, you can deploy to Ethereum mainnet by changing the network parameter and using real ETH for gas fees.
Important: Once deployed on mainnet, the contract is permanent. Ensure it's been thoroughly tested and ideally audited before mainnet deployment.
After Deployment
Once your token is live:
- Verify the contract on Etherscan so anyone can read the source code:
``bash
npx hardhat verify --network sepolia CONTRACT_ADDRESS "My Token" "MTK" "1000000"
``
- Add to wallets โ Share the contract address so users can add your token to MetaMask.
- Create liquidity โ List on a decentralized exchange like Uniswap by creating a liquidity pool.
- Consider tokenomics โ Plan your token distribution, vesting schedules, and burn mechanisms.
- Legal compliance โ Depending on your jurisdiction, your token may be classified as a security. Consult legal counsel.
Costs: Deploying an ERC-20 token on Ethereum mainnet typically costs $50-$200 in gas fees, depending on network congestion.
Practice in a risk-free environment
Apply the concepts using virtual funds and live market data. NexChange is an educational simulation, not a real-money exchange.
Continue learning
Related guides
Smart Contracts 101
Learn what smart contracts are, how they work, and why they are the foundation of decentralized applications.
Understanding the ERC-20 Token Standard
A technical overview of the ERC-20 standard โ the specification that defines how fungible tokens work on Ethereum.
How Blockchain Technology Works
A deep dive into the technology that powers cryptocurrencies โ blocks, chains, consensus mechanisms, and decentralized networks.