Lesson 7: error in running command yarn hardhat deploy --tags mocks #1559
-
I am not able to get my compiler to run only the 00-deploy-mocks.js and is showing an error in my 01-deploy-fund-me.js file. While running the command :
I get this error:
which is clearly not what Patrick gets at timestamp 10:49:30 in the tutorial. This is my code for file 00-deploy-mocks.js: const { network } = require("hardhat")
const {
developementChains,
DECIMALS,
INITIAL_ANSWER,
} = require("../helper-hardhat-config")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
//const chainId = network.config.chainId
if (developementChains.includes(network.name)) {
log("Local network detected... deploying mocks...")
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMALS, INITIAL_ANSWER],
})
log("Mocks deployed!")
log("-----------------------------------------------------------")
}
}
module.exports.tags = ["all", "mocks"] and helper-hardhat-config.js: const networkConfig = {
4: {
name: "rinkeby",
ethUSDPriceFeed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e",
},
137: {
name: "polygon",
ethUSDPriceFeed: "0xF9680D99D6C9589e2a93a78A04A279e509205945",
},
}
const developmentChain = ["hardhat", "localhost"]
const DECIMALS = 8
const INITIAL_ANSWER = 200000000000
module.exports = {
networkConfig,
developmentChain,
DECIMALS,
INITIAL_ANSWER,
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
@Varshacs004 issue is in |
Beta Was this translation helpful? Give feedback.
-
For those who are facing the issue I faced, here is the code that worked for me...
const { network } = require("hardhat")
const {
developementChain,
DECIMALS,
INITIAL_ANSWER,
} = require("../helper-hardhat-config")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
if (chainId == "31337") {
log("Local network detected... deploying mocks...")
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMALS, INITIAL_ANSWER],
})
log("Mocks deployed!")
log("-----------------------------------------------------------")
}
}
module.exports.tags = ["all", "mocks"]
const { network } = require("hardhat")
const { networkConfig } = require("../helper-hardhat-config")
// (or)
// const helperConfig = require("../helper-hardhat-config")
// const networkConfig = helperConfig.networkConfig
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
const ethUSDPriceFeedAddress = networkConfig[chainId]["ethUSDPriceFeed"]
const fundMe = await deploy("FundMe", {
from: deployer,
args: [
/*address*/
], //put price feed address.
log: true,
})
}
const networkConfig = {
4: {
name: "rinkeby",
ethUSDPriceFeed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e",
},
137: {
name: "polygon",
ethUSDPriceFeed: "0xF9680D99D6C9589e2a93a78A04A279e509205945",
},
31337: {
name: "localhost",
},
}
const developmentChain = ["hardhat", "localhost"]
const DECIMALS = 8
const INITIAL_ANSWER = 200000000000
module.exports = {
networkConfig,
developmentChain,
DECIMALS,
INITIAL_ANSWER,
} and require("@nomicfoundation/hardhat-toolbox")
require("hardhat-deploy")
require("hardhat-gas-reporter")
require("solidity-coverage")
require("dotenv").config()
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
networks: {
hardhat: {
chainId: 31337,
},
},
solidity: {
compilers: [
{ version: "0.8.7" },
{ version: "0.8.8" },
{ version: "0.6.0" },
],
},
namedAccounts: {
deployer: {
default: 0,
},
player: {
default: 1,
},
},
} Thank you @alymurtazamemon @othaime-en for your help. |
Beta Was this translation helpful? Give feedback.
@Varshacs004 issue is in
01-deploy-fundMe.js
file make sure the function isasync