[Ethereum] HardhatError: HH110: Invalid JSON-RPC response received: {“statusCode”:404,”error”:”Not Found”,”message”:”Not Found”}

hardhatpolygon

i am using hardhat to deploy my contract on matic testnet. its compiling successfully but then give me this error:

here is the code

    require("@nomiclabs/hardhat-waffle");
const fs = require('fs');
const privateKey = fs.readFileSync(".secret").toString().trim() || "01234567890123456789";

// infuraId is optional if you are using Infura RPC


module.exports = {
  defaultNetwork: "hardhat",
  networks: {
    hardhat: {
      chainId: 1337
    },
    mumbai: {
      // Infura
      // url: `https://polygon-mumbai.infura.io/v3/${infuraId}`
      url: "https://rpc-mumbai.matic.today",
      accounts: [privateKey]
    },
    matic: {
      // Infura
      // url: `https://polygon-mainnet.infura.io/v3/${infuraId}`,
      url: "https://rpc-mainnet.maticvigil.com",
      accounts: [privateKey]
    }
  },
  solidity: {
    version: "0.8.4",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  }
};

    
  

Best Answer

Use different RPC Endpoint:

For Example, https://rpc.maticvigil.com/

Code

mumbai: {
  url: "https://rpc-mumbai.maticvigil.com/v1/{App Id}",
  accounts: [privateKey]
},
mainnet: {
  url: "https://rpc-mainnet.maticvigil.com/v1/{App Id}",
  accounts: [privateKey]
}
Related Topic