How To Deploy ERC20 Token on Mainnet/Testnet Using Truffle,Infura and MetaMask

Shahzain Tariq

ERC stands for Ethereum Request For Comments. ERC20 is most Significant token on Ethereum Blockchain. ≤= click on this link where you can find a ERC20 Token standard for Creating ERC20 token.

Truffle is a Framework for building decentralized applications on Ethereum Blockchain. Truffle Gives you a development enviroment, Testing Framework,compilation etc. check =>

Infura is a backend infrastructure for building and running your DAPP. You can connect to a mainnet/testnet blockchain without running a full node blockchain on your PC. Infura Makes a Blockchain Developer’s easier . =>

This article will help you migrate your ERC20 token to an Ethereum network provided by infura.In this tutorial, I will help you deploying token to Ropsten Testnet Blockchain using infura, HD wallet-provider, and truffle.

  • MetaMask(should have some ether in ropsten testnet)
  • Infura
  • Truffle
  • HD wallet-provider

For Installing Hdwallet-Provider you need this command

npm install @truffle/hdwallet-provider

NOTE: if you get an MS BUILD type of error then follow this command then try installing HD wallet-provider again

npm install -g windows-build-tools

After installing HD wallet-provider. go to and register yourself. login into your infura account you should see a CREATE NEW PROJECT button which will create a PROJECT ID, PROJECT SECRET, ENDPOINT make sure to keep these keys private.

Now we have to Edit truffle-cong.js file to use Hdwallet-provider

  • initialized HDWallet-provider in your config file. add this statement in your config file
const HDWalletProvider = require("@truffle/hdwallet-provider");
  • now we need to provide a mnemonic to our config file. This is where we will connect our metemask with truffle. so getting a mnemonic is so easy just go to metamask then go to Setting > Security & Privacy and click on Reveal Seed Phrase and paste on mnemonic
const mnemonic = "example door key ... ";

NOTE: mnemonic is the most important key in production I would highly recommend you store mnemonic in a secret file because if someone got your mnemonic key then he/she can get access to your account & can withdrawal all of your coins.

  • then add/uncomment this in you truffle-config.js file
module.exports = {
networks: {
ropsten: {
provider: () => new HDWalletProvider(

things to notice:

  • make sure to replace this statement <infura_project_id> with your infura project id
  • The HDWallet-provider takes two arguments one is mnemonic which is your meta mask seed phrase and the 2nd is a ethereum network where you want to deploy your contract if you want to deploy on a mainet put your infura mainnet ENDPOINT<YOUR_PRJOECT_ID>it will deploy to a mainnet

SO, now we have everything set up the last we need to do is to get some ether on metamask (ropsten testnet) from the faucet. we will need some test ether to deploy the contract on a testnet

and boom you got your test ethereums now its time to deploy on a testnet

  • Compile your contract using this command
truffle compile
  • then deploy on a ropsten testnet using this following command
truffle migrate --network ropsten

if you are having a good day and everything goes well then you should see these following commands

Deploying 'Migrations'
> transaction hash: 0x166c1791caa73cca6a75fe4258866bd1f2d1bcf2cd4c3a2a1e03fab29c42829d
> Blocks: 0 Seconds: 0
> contract address: 0x5ccb4dc04600cffA8a67197d5b644ae71856aEE4


check out the erc20 token I deployed to use the following method

learn How to Create your own ERC-20 Token smart contract here:

if you got any problem then email me at


What do you think?


电子邮件地址不会被公开。 必填项已用*标注





對抗疫情金融危機,Steaker 如何增長客戶收益?

Tips for Vyper Beginners