1

When i want to deploy my contract with this command:

npx hardhat run --network goerli scripts/deploy.js

I get this error:

ProviderError: HttpProviderError at HttpProvider.request (/Users/alirezamac/Documents/Token-dex/node_modules/hardhat/src/internal/core/providers/http.ts:78:19)

And here is my config file:

require("@nomicfoundation/hardhat-toolbox");
require ("dotenv").config()

module.exports = {
  solidity: "0.8.17",
  networks: {
    goerli: {
      url: process.env.INFURA_GOERLI_ENDPOINT,
      accounts: [process.env.PRIVATE_KEY],
      chainId: 5
    },
  },
};

and also this is my deploy file:

const hre = require("hardhat");

async function main() {
 const Token = await hre.ethers.getContractFactory("MyToken")
 const token = await Token.deploy();
 await token.deployed()
console.log("Congratulations!! Your token deployed, Here's token address:", token.address);

 const Dex = await hre.ethers.getContractFactory("Dex2")
 const myDex = await Dex.deploy(token.address)
 await token.deployed()

 console.log("Here's your dex contract address:", myDex.address);

}
main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
1
  • seems like it's an issue with your infura url make sure that is correct first, and then my second idea would be that it is not reading the url from the .env file correctly. To test that change the url to your actual url and if it works then there is an issue with your .env setup are you using vanilla js or a framework like react? Dec 5, 2022 at 13:58

3 Answers 3

0

You can add some lines to node_modules/hardhat/internal/core/providers/http.js to debug. After every isErrorResponse check add: console.log(response) or console.log(jsonRpcResponse).

Most likely it's an error inside your contracts or deploy script (or both).

0

Thre is a typo in await token.deployed() should be myDex.deployed()

That could be the reason the provider is reverting without any reason

0

Solved this error by looking the ganache's console and seeing that the tx was reverted due to an error caused by incorrect assignment of an account to a role.

Your Answer

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

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