1

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?

1 Answer 1

1

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.

3
  • I want to call the ethers js functions which in turn call my smart contract using an express API. I created the APIs but I'm unabl;e to run the server and get the response for the API request. When I run the express app using command node app.js I'm not able to connect with deployed smart contract in hardhat local env. And When I run it using npx hardhat run app.js --network localhost I am able to call the API along with the smart contract using postman, but the response doesn't go back to postman and it keeps waiting. Please help me with this. Thanks in advance! Mar 15, 2023 at 11:56
  • 1
    You need to create a question @PrashantNagawade
    – Julissa DC
    Mar 15, 2023 at 15:16
  • I have created one. Can you please check it and provide some pointers? ethereum.stackexchange.com/q/147447/30236 Mar 15, 2023 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.