-
The contract worked on the localhost, but it seems to not work correctly on the rinkeby testnet. Here is my code: // import
// function
// main function
// function deployFunc(hre) {
// console.log("hello there!")
// }
// module.exports.default = deployFunc
//hre is same as hardhat
//nearly identical up there (but more anonymous)
// cosnt { getNamedAccounts, deployments } = hre
const { getNamedAccounts, deployments, network } = require("hardhat")
const { networkConfig, developmentChains } = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
// if chainId is x use address y
// if chainId is z use address a
// const ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
let ethUsdPriceFeedAddress
if (developmentChains.includes(network.name)) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
ethUsdPriceFeedAddress = ethUsdAggregator.address
} else {
const ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
}
const args = [ethUsdPriceFeedAddress]
const fundMe = await deploy("FundMe", {
from: deployer,
args: args, //put price feed address
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
//when going for localhost or hardhat network we want to use a mock
log("---------------------------------------")
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
await verify(fundMe.address, args)
}
}
module.exports.tags = ["all", "fundme"] This is the error code:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 13 replies
-
Hi! In your code replace: if (developmentChains.includes(network.name)) |
Beta Was this translation helpful? Give feedback.
-
You're getting
Could you do a |
Beta Was this translation helpful? Give feedback.
-
let ethUsdPriceFeedAddress // you declared ethUsdPriceFeedAddress with let keyword
if (developmentChains.includes(network.name)) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
ethUsdPriceFeedAddress = ethUsdAggregator.address
} else {
const ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"] //and here also you are trying to declare with const keyword
} here your are trying to declare a same variable with two different keywords which is already been declared i think that might be the problem. |
Beta Was this translation helpful? Give feedback.
-
Try pasting this in your deployment script and redeploying to see if it works. The issue might be somewhere else:
|
Beta Was this translation helpful? Give feedback.
here your are trying to declare a same variable with two different keywords which is already been declared i think that might be the problem.