How to Deploy Your Own ERC-20 Token with Ankr & Hardhat on ETH Goerli Testnet

·

Creating your own cryptocurrency token might sound like a task reserved for elite blockchain developers — but it’s more accessible than you think. With the right tools and a step-by-step approach, anyone with basic coding knowledge can deploy their very own ERC-20 token on the Ethereum network. In this guide, we’ll walk you through how to build and launch a functional ERC-20 token using Ankr, Hardhat, and the Goerli testnet — all without touching the main Ethereum network or risking real funds.

Whether you're exploring blockchain development as a hobby, testing decentralized applications (dApps), or preparing for a real-world token launch, this tutorial gives you hands-on experience in a safe, simulated environment.

Understanding ERC-20 Tokens

Before diving into deployment, let’s clarify what an ERC-20 token is. ERC-20 is a technical standard used for smart contracts on the Ethereum blockchain for implementing tokens. These tokens are:

This makes ERC-20 ideal for creating utility tokens, governance tokens, or even digital representations of real-world assets.

In contrast, NFTs (non-fungible tokens) represent unique items — think digital art or collectibles — and aren't interchangeable.

Now that you understand the basics, let’s get started.


👉 Discover how blockchain developers are accelerating dApp deployment with powerful Web3 tools.


Step 1: Set Up MetaMask for Goerli Testnet

To interact with Ethereum testnets, you’ll need a crypto wallet. MetaMask is the most popular choice.

  1. Visit metamask.io and install the browser extension.
  2. Create or import a wallet.
  3. Switch your network to Goerli Test Network:

    • Click the network dropdown in MetaMask.
    • Select “Goerli” from the list. If it’s not visible, enable test networks in Settings > Advanced.
⚠️ Remember: Goerli ETH has no monetary value. It's used solely for testing.

Step 2: Get Free Goerli ETH from a Faucet

You’ll need test ETH to cover gas fees when deploying your smart contract.

  1. Go to the Chainlink Goerli Faucet.
  2. Connect your MetaMask wallet.
  3. Request test ETH — usually delivered within seconds.

Once confirmed, check your MetaMask balance to ensure funds arrived.

Step 3: Configure Your Development Environment

We’ll use Hardhat, a powerful Ethereum development environment, to write, test, and deploy our smart contract.

Initialize the Project

Open your terminal and run:

mkdir erc20-token-ankr
cd erc20-token-ankr
npm init -y
npm install --save-dev hardhat

Then initialize Hardhat:

npx hardhat

Select “Create a JavaScript project”, accept defaults, and wait for installation.

After setup completes, remove sample files:

rm scripts/sample-script.js
rm contracts/Greeter.sol

Install Required Dependencies

Install OpenZeppelin Contracts and ethers.js plugin:

npm install @openzeppelin/contracts
npm install --save-dev @nomicfoundation/hardhat-toolbox dotenv

Create a .env file in your project root:

PRIVATE_KEY=your_metamask_private_key_here
🔐 Never commit this file to version control. Add .env to .gitignore.

👉 See how top developers streamline contract deployment using secure infrastructure.


Step 4: Configure Hardhat with Ankr RPC

To connect to the Ethereum Goerli network, we need an RPC provider. Instead of running our own node, we’ll use Ankr’s public RPC endpoints, which are free and reliable.

  1. Get the Goerli RPC URL from Ankr Public RPCs.
  2. Update hardhat.config.js:
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();

module.exports = {
  solidity: "0.8.20",
  networks: {
    goerli: {
      url: "https://rpc.ankr.com/eth_goerli",
      accounts: [`0x${process.env.PRIVATE_KEY}`],
    },
  },
};

This configuration tells Hardhat to use Ankr’s Goerli endpoint and sign transactions with your MetaMask private key.

Step 5: Write Your ERC-20 Smart Contract

We’ll use OpenZeppelin’s ERC20 implementation — battle-tested and secure.

  1. Inside the contracts folder, create a new file: MyToken.sol.
  2. Paste the following code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

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

contract MyToken is ERC20 {
    constructor() ERC20("MyToken", "MTK") {
        _mint(msg.sender, 1000 * 10 ** decimals());
    }
}

Replace "MyToken" and "MTK" with your desired token name and symbol (e.g., Buildoooor, BDR).

  1. Compile the contract:
npx hardhat compile

If you’re on Windows and encounter errors, run:

npm install [email protected]

Then recompile.

Step 6: Deploy Your Token to Goerli

Create a deployment script in the scripts folder:

touch scripts/deploy.js

Add this code:

const hre = require("hardhat");

async function main() {
  const MyToken = await hre.ethers.getContractFactory("MyToken");
  const myToken = await MyToken.deploy();

  await myToken.waitForDeployment();
  console.log("MyToken deployed to:", await myToken.getAddress());
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Now deploy:

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

Wait a few seconds — once confirmed, you’ll see your contract address in the console.


👉 Learn how to verify contracts and explore advanced deployment strategies today.


Verify Deployment on Etherscan

Go to goerli.etherscan.io and paste your contract address.

You should see:

Congratulations! You’ve officially launched your own ERC-20 token.

Core Keywords for SEO

These terms naturally appear throughout this guide to align with user search intent while maintaining readability.

Frequently Asked Questions

Can I deploy an ERC-20 token without coding?

While no-code platforms exist, understanding Solidity and deployment tools like Hardhat ensures full control and security over your token.

Is deploying on Goerli free?

Yes — test ETH is free via faucets, and Goerli transactions don’t cost real money. However, during high network congestion, some faucets may limit requests.

Why use Ankr’s RPC instead of Infura or Alchemy?

Ankr offers free, high-performance public RPCs with no signup required — perfect for quick prototyping and learning.

How do I turn my testnet token into a mainnet token?

Once tested, redeploy the same contract on Ethereum Mainnet using the same process — but ensure you have real ETH for gas fees.

Can I customize my token further?

Absolutely! You can add features like:

What if I lose my private key?

Losing access to your private key means losing control of the deployed contract. Always store keys securely using environment variables or hardware wallets.


With this foundation, you're ready to explore more advanced use cases — from launching governance tokens to integrating tokens into dApps. The skills you’ve gained here are directly transferable to real-world blockchain projects.

Remember: every major DeFi project started with a simple token deployment — now you’ve taken that first step.