Please Help(LESSON 9) : Error: invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.7.0) (argument="vrfCoordinatorV2", value=undefined, code=INVALID_ARGUMENT, version=abi/5.7.0) #4972
-
const { network, ethers } = require("hardhat");
const {
networkConfig,
developmentChains,
} = require("../helper-hardhat-config");
const FUND_AMOUNT = ethers.utils.parseEther("5"); // 1 Ether, or 1e18 (10^18) Wei
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
let vrfCoordinatorV2Address;
let subscriptionId;
if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract(
"VRFCoordinatorV2Mock"
);
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.getAddress;
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription();
const transactionReceipt = await transactionResponse.wait(1);
subscriptionId = transactionReceipt.events[0].args.subId;
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, FUND_AMOUNT);
} else {
vrfCoordinatorV2Address = "0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D";
subscriptionId = networkConfig[chainId]["subscriptionId"];
}
///////////
const entranceFee = ethers.utils.parseEther("0.01");
const gasLane =
"0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15";
const callbackGasLimit = "500000";
const interval = "30";
//////////////
const args = [
vrfCoordinatorV2Address,
entranceFee,
gasLane,
subscriptionId,
callbackGasLimit,
interval,
];
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
});
};
module.exports.tags = ["all", "raffle"]; It's been tow days and i have tried everything but i cant find the error or bug. Please help |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Mar 1, 2023
Replies: 2 comments 2 replies
-
const { network, ethers } = require("hardhat");
const {
networkConfig,
developmentChains,
} = require("../helper-hardhat-config");
const FUND_AMOUNT = ethers.utils.parseEther("5"); // 1 Ether, or 1e18 (10^18) Wei
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
let vrfCoordinatorV2Address;
let subscriptionId;
if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract(
"VRFCoordinatorV2Mock"
);
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address;
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription();
const transactionReceipt = await transactionResponse.wait(1);
subscriptionId = transactionReceipt.events[0].args.subId;
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, FUND_AMOUNT);
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinator"];
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,
gasLane,
interval,
entranceFee,
callbackGasLimit,
];
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
});
};
module.exports.tags = ["all", "raffle"]; this is the correct one |
Beta Was this translation helpful? Give feedback.
0 replies
-
@Red12-45 Leave your repository link, we need to check other things and test (if needed). |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
alymurtazamemon
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Red12-45 Leave your repository link, we need to check other things and test (if needed).