Deploy and mint an ERC-20 token on Hedera testnet using Hardhat and OpenZeppelin.
This walks through deploying a standard ERC-20 token to Hedera testnet using Hardhat. The contract uses OpenZeppelin’s audited ERC-20 base, so most of the code is library calls. The workflow is the same one you’d use on any EVM chain; the only Hedera-specific bit is the network config.
Run in your browser: Skip local setup and try the same example in the Contract Builder: compile, deploy, and mint from your browser in seconds.
// SPDX-License-Identifier: MITpragma solidity ^0.8.22;import "@openzeppelin/contracts/token/ERC20/ERC20.sol";import "@openzeppelin/contracts/access/Ownable.sol";contract MyToken is ERC20, Ownable { constructor(address initialOwner) ERC20("MyToken", "MTK") Ownable(initialOwner) { // Mint 1,000,000 tokens (with 18 decimals) to the deployer. _mint(initialOwner, 1_000_000 * 10 ** decimals()); } function mint(address to, uint256 amount) public onlyOwner { _mint(to, amount); }}
The contract inherits OpenZeppelin’s ERC20 and Ownable, mints the initial 1,000,000 supply to the deployer in the constructor, and exposes a mint() function gated by onlyOwner for later minting.
Use a dedicated dev wallet. Don’t put a mainnet private key in a .env file you’re experimenting with. To get the testnet key from MetaMask: Account → ⋮ → Account details → Show private key.
Open https://hashscan.io/testnet/contract/<your-deployed-address>. HashScan picks the contract up automatically and shows its bytecode, the deployer account, and the deploy transaction.For source-code-level visibility, follow the contract verification guide.
In MetaMask: Tokens tab → Import tokens, paste your contract address. Symbol and decimals are auto-filled from the contract. You should now see your full supply in the wallet.