Lesson 7: Error: invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.7.0) #6095
-
I'm stuck with this error while deploying on goerli... it's working fine on localhost or hardhat network.It's printing chainId and ethUsdPriceFeedAddress. Here are codes: const { getNamedAccounts, deployments } = require("hardhat");
const { networkConfig, developmentChain } = require("../helper-hardhat-config");
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
let ethUsdPriceFeedAddress;
console.log(`this is chain id: ${chainId}`);
if (developmentChain.includes(network.name)) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator");
ethUsdPriceFeedAddress = ethUsdAggregator.address;
}
else{
const ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"];
console.log(ethUsdPriceFeedAddress);
}
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress /* address of proce feed*/],
log: true,
// waitConfirmations: network.config.blockConfirmations || 1,
});
log(
"----------------------------------------------------------------------------",
);
};
module.exports.tags = ["all", "fundme"]; Here is the terminal output: Error: ERROR processing /root/blockchain_projects/hardhat-fund-me/deploy/01-deploy-fund-me.js: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@tusharr1411 use getAddresss instead of .address ethUsdPriceFeedAddress = ethUsdAggregator.address; ❌
ethUsdPriceFeedAddress = await ethUsdAggregator.getAddress(); ✅ |
Beta Was this translation helpful? Give feedback.
-
well that's not the problem because it's grabing the contract address correctly .... I have also log it in termianl.. you can see the contract addres below the chain Id in terminal output |
Beta Was this translation helpful? Give feedback.
@tusharr1411
Got the problem you are using const ethUsdPriceFeedAddress inside else block which is storing address in a constant variable which does not have scope outside the else block that's why it is working fine on localhost but not on test net
So remove the const
..
I hope this will solve your problem