Deploy a token with Hardhat

In this section we'll show how to deploy a simple ERC20 token for your DePIN project using Hardhat and OpenZeppelin (a library of community contributed smart contracts).

As mentioned in the Web3 Development section, the IoTeX Blockchain implements a full-featured Ethereum Virtual Machine (EVM), allowing you to use all your favorite Ethereum tools. The currently supported EVM version in Shanghai, which allows you to build using the Solidity compiler version v0.8.20.

Environment setup and writing your contract

Given that you can use your favorite Ethereum tools, all you have to do to deploy your own ERC20 token on the IoTeX Testnet or Mainnet, is to follow this detailed Hardhat guide on how to deploy your first token. The guide will walk you through the steps necessary to set up your own environment, write your token contract and finally deploy it.

As mentioned earlier you could also use the OpenZeppelin Library in your project, or the OpenZeppelin Wizard tool. More info can be found on the OpenZeppelin official site, here.

Deploying on the IoTeX Testnet

NOTE: In order to deploy on the IoTeX Testnet, all you have to do is to update the hardhat.config.js file from the guide above with the IoTeX Testnet configuration, which looks like below 👇

require("@nomicfoundation/hardhat-toolbox");

const IOTEX_PRIVATE_KEY = "<YOUR PRIVATE KEY HERE>";

module.exports = {
  solidity: "0.8.20",
  networks: {
    testnet: {
      // These are the official IoTeX endpoints to be used by Ethereum clients
      // Testnet https://babel-api.testnet.iotex.io
      // Mainnet https://babel-api.mainnet.iotex.io
      url: `https://babel-api.testnet.iotex.io`,

      // Input your Metamask testnet account private key here
      accounts: [`${IOTEX_PRIVATE_KEY}`],
    },
  },
};

Once updated, you can follow this section on how to deploy your token to a live network.

Remember: In order to deploy to the IoTeX Testnet, you'll need some Test $IOTX. Follow the link below in order to do so👇

pageTestnet Tokens

🎉 Congrats! You've deployed your first token on IoTeX!

Importing the IoTeX Testnet/Mainnet in your Ethereum wallet

In order to import the IoTeX Testnet and Mainnet to your Ethereum Wallet (like MetaMask), login to the IoTeX Developers Portal using your Github account, access the Developer Tools page, and simply connect your browser wallet.

Last updated