1
require("@nomiclabs/hardhat-ethers");
require ("dotenv").config();

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.10",
  networks:{
    mainnet: {
      url: `https://eth-mainnet.g.alchemy.com/v2/APIKEY`,
      accounts: [process.env.PRIVATE_KEY],
    }
  }
};

i want to know what is really wrong cos infura rpc url also return this error

2
  • How are you running the deployment script?
    – Jay Welsh
    Commented Apr 11, 2023 at 13:18
  • Are you using the url as https://eth-mainnet.g.alchemy.com/v2/APIKEY only or are you renaming APIKEY? Commented Apr 11, 2023 at 13:45

1 Answer 1

0

Please verify that you have this in your package.json:

{
  ...,
  "scripts": {
    ...,
    "deploy": "npx hardhat run scripts/deploy.js --network mainnet"
  }
}

Or use directly the command npx hardhat run scripts/deploy.js --network mainnet.

For more info, see: https://hardhat.org/tutorial/deploying-to-a-live-network

9
  • npx hardhat run scripts/deploy.js --network mainnet.
    – James Luiz
    Commented Apr 11, 2023 at 13:47
  • I renamed the API key to my infura API, but it kept on returning this same error
    – James Luiz
    Commented Apr 11, 2023 at 13:49
  • And it is returning this error, that I posted, { ..., "scripts": { ..., "deploy": "npx hardhat run scripts/deploy.js --network mainnet" } } It is not in my package.json
    – James Luiz
    Commented Apr 11, 2023 at 13:52
  • Do you store your APIKEY in your .env ?
    – vachmara
    Commented Apr 11, 2023 at 14:02
  • No I didn't just my private
    – James Luiz
    Commented Apr 11, 2023 at 14:02

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.