Hardhat – How to Deploy Hardhat on Live Network

hardhathardhat-deploy

I have a react front end with a express back end to interact with the hardhat scripts.

If my config networks look like this:

networks: {
    hardhat: {
      forking: {
        url: process.env.FORKING_URL,
        blockNumber: 13195099
      }
    },
    rinkeby: {
      url: process.env.RINKEBY_URL
    }
  }

How does hardhat know which network is running to deploy. If were just running the script I would do --network networkName but since I have a running application how should I do it?

Best Answer

The answer is: Since is a React application it interacts with the front end and depends on the Metamask extension to do this kind of actions it will just execute the action on the users selected network. Check might be put in place to prevent a user to do an operation on a different chain than the desired one.

If you wish to do this from the back end you could use OpenZeppelin's Defender's Relayer to deploy from your application backend with your Relayer account.