Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.7.0) #5192
-
Error: ERROR processing C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\deploy\01-deploy-raffle.js:
Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.7.0) Hi Team, I am working on smart contract project. When I am deploying the contract. I get the below issue at line No : 19. Error: ERROR processing C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\deploy\01-deploy-raffle.js:
Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.7.0)
at Logger.makeError (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)
at Logger.throwArgumentError (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\@ethersproject\logger\src.ts\index.ts:285:21)
at Contract.BaseContract (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\@ethersproject\contracts\src.ts\index.ts:712:20)
at new Contract (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\@ethersproject\contracts\lib\index.js:1053:42)
at Function.ContractFactory.getContract (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\@ethersproject\contracts\src.ts\index.ts:1297:16)
at ContractFactory.attach (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\@ethersproject\contracts\src.ts\index.ts:1260:42)
at getContractAtFromArtifact (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:381:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Object.module.exports [as func] (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\deploy\01-deploy-raffle.js:14:38)
at DeploymentsManager.executeDeployScripts (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1222:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at DeploymentsManager.runDeploy (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1052:5)
at SimpleTaskDefinition.action (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\hardhat-deploy\src\index.ts:438:5)
at Environment._runTaskDefinition (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\hardhat\src\internal\core\runtime-environment.ts:330:14)
at Environment.run (C:\Shahzad\NFT My practice\hardhat-smartcontract-lottery-me\node_modules\hardhat\src\internal\core\runtime-environment.ts:163:14) 01-deploy.js const {network,ethers} = require("hardhat");
const {developmentChains, networkConfig} = require("../helper-hardhat-config");
const {verify} = require("../utils/verify");
const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("2");
module.exports = async function ({getNamedAccounts, deployments}) {
const {deploy, log} = deployments;
const {deployer} = await getNamedAccounts();
const chainId = network.config.chainId;
let vrfCoordinatorV2Address;
let subscriptionId;
console.log("inside the 01-deploy-raffle.js");
if(developmentChains.includes(network.name)){
const vrfCoordinatorV2Mock = await ethers.getContractAt("VRFCoordinatorV2Mock");
console.log("after mock");
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address;
console.log(`Address ${vrfCoordinatorV2Address}`)
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription();
const transactionReceipt = await transactionResponse.wait(1);
subscriptionId = transactionReceipt.event[0].args.subId;
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, VRF_SUB_FUND_AMOUNT);
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"];
subscriptionId = networkConfig[chainId]["subscriptionId"];
}
const entranceFee = networkConfig[chainId]["entranceFee"];
const gasLane = networkConfig[chainId]["gasLane"];
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"];
const interval = networkConfig[chainId]["interval"];
const args = [vrfCoordinatorV2Address, subscriptionId, interval, entranceFee, gasLane, callbackGasLimit];
const raffle = await deploy("Raffle", {
from : deployer,
args : args,
log : true,
waitConfirmations: network.config.blockConfirmations || 1,
})
if(!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) {
log("verifying....");
await verify(raffle.address, args);
}
log("----------------------------");
}
module.exports.tags=["all", "raffle"]; ------helper-hardhat.config.js const networkConfig = {
11155111 : {
name : "sepolia",
vrfCoordinatorV2:"0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c", // 30 gwei
subscriptionId: "0",
callbackGasLimit: "50000",
interval: "30",
},
1337 : {
name: "hardhat",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c", // 30 gwei
callbackGasLimit: "50000",
interval: "30",
}
}
const developmentChains = ["hardhat", "localhost"]
module.exports = {
networkConfig,
developmentChains
} ---------00-deploy.js const {developmentChains} = require("../helper-hardhat-config");
const {ethers} = require("hardhat");
const BASE_FEE = ethers.utils.parseEther("0.25");
const GAS_PRICE_LINK = 1e9;
module.exports = async function ({getNamedAccounts, deployments}) {
const {deploy, log} = deployments;
const {deployer} = await getNamedAccounts()
const chainId = network.config.chainId;
const args = [BASE_FEE, GAS_PRICE_LINK];
if(developmentChains.includes(network.name)){
log("Local network detected! Deploying mocks....");
await deploy("VRFCoordinatorV2Mock", {
from : deployer,
log: true,
args: args
});
log("Mocks deployed!!!");
log("--------------------------");
}
}
module.exports.tags = ["all", "mocks"] |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
@mshahzadmalik1995 Console log the args you pass to deploy function, it looks like a value in this list is undefined console log to check which one is undefined. If you feel difficulty then please leave your repo link so I can test it locally. |
Beta Was this translation helpful? Give feedback.
-
@alymurtazamemon bro i am getting the same error. Can you help me please. You can find all the files here |
Beta Was this translation helpful? Give feedback.
@mshahzadmalik1995 Console log the args you pass to deploy function, it looks like a value in this list is undefined console log to check which one is undefined.
If you feel difficulty then please leave your repo link so I can test it locally.