I can't seem to deploy my "deploy-mocks.js" file using yarn hardhat deploy --tags mocks. Here's my code if you want to take a look. I have searched everywhere but can't find the answer. Any kind of help will be appreciated.

const { network } = require("hardhat");
const { developmentChains, DECIMALS, INITAL_ANSWER } = require("../helper-hardhat-config");

module.exports = async ({ getNamedAccounts, deployments }) => {
    const { deploy, log } = deployments;
    const deployer = await getNamedAccounts();
    const chainId = network.config.chainId;

    if (developmentChains.includes(chainId)) {
        log("Local Chain detected. Deploying Mocks...");
        const mockAggregator = await deploy("MockV3Aggregator", {
            contract: "MockV3Aggregator",
            from: deployer,
            log: true,
            args: [DECIMALS, INITAL_ANSWER],
        log("Mocks Deployed!");

        // You can perform additional deployment tasks here if needed

module.exports.tags = ["all", "mocks"];

Here's the output from my code.


  • 1
    try the same thing with npx once and see if that's working. May 28 at 12:08
  • is this line evaluating to true? if (developmentChains.includes(chainId)) {.....
    – ZeusLawyer
    May 30 at 3:15

1 Answer 1


It worked in developmentChains.includes(chainId) I was using chainId as a reference. However in my config.js file I defined the network properties as their names. so I changed the developmentChains.includes(chainId) to developmentChains.includes(network.name)

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.