Solidity – Resolving Deployment Errors on Hardhat Network with Mainnet Forking

ethers.jshardhatsolidity

I'm running some tests on Hardhat network with the following config:

const config = {
  networks: {
    hardhat: {
      chainId: 1337,
      forking: {
        enabled: true,
        url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`,
        blockNumber: 11873448,
      },
    },
  },
}

export default config;

I need to deploy a SimplePriceFeed contract, but when I have mainnet forking enabled I get this error:

Error: network does not support ENS (operation="ENS", network="unknown", code=UNSUPPORTED_OPERATION, version=providers/5.3.0)

This is the script I'm running to attempt deploying SimplePriceFeed:

const contract = await ethers.getContractFactory("SimplePriceFeed")
const SimplePriceFeed = await contract.deploy("WBTC / USD");

I tried the following script as well, but I encountered the same exact error:

const signer = (await ethers.getSigners())[0];
const artifact = await hre.artifacts.readArtifact("SimplePriceFeed");
const SimplePriceFeed = await deployContract(signer, artifact, ["WBTC / USD"])

Both scripts work just fine when mainnet forking is disabled, but I really need mainnet forking for my tests.

Best Answer

You get the error Error: network does not support ENS when the place where you need to pass in an address value, you're passing something else (in quite a lot of cases it's an undefined value because some address variable was not initialized before being passed in).

In the code snippets you've provided, I see only see the constructor on your contract, i.e. contract.deploy in which a UTF8 string is being passed. If that is correct, then something else in your code base must be throwing the error.

Related Topic