error : Error: expected 6 constructor arguments, got 5 #1072
-
hi i am getting these errors as i copied 01-deply-raffle.js from the video. i have looked and cant find where my problem is why my code is not being read with 6 arguments although i have them all. Error: expected 6 constructor arguments, got 5 this is my 01-deploy-raffle.js sheet : // if its an address men barra u gna have to deploy mocks or it
// shuf lconstructors bel contract fishi eno aam nekhedon kelon
const { network, ethers } = require("hardhat")
const { networkConfig, developmentChains } = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")
const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("30")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
let vrfCoordinatorV2Address, subscriptionId
if (developmentChains.includes(network.name)) {
// create VRFV2 Subscription
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
// fund the subsription
//usually u need to link w real token on a real network
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 = [
entranceFee,
gasLane,
callbackGasLimit,
interval,
subscriptionId,
vrfCoordinatorV2Address,
]
const raffle = await deploy("Raffle", {
from: deployer,
args: arguments,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
// Verify the deployment
if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) {
log("Verifying...!!!!!!!!")
await verify(raffle.address, args)
log("-------------------------------")
}
module.exports.tags = ["all", "raffle"]
} and this is my helper hardhat : const { ethers } = require("hardhat")
const networkConfig = {
4: {
name: "rinkeby",
vrfCoordinatorV2: "0x271682DEB8C4E0901D1a1550aD2e64D568E69909",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
subscriptionId: "0",
callbackGasLimit: "500000",
interval: "30",
},
31337: {
name: "hardhat",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
callbackGasLimit: "500000",
interval: "30",
},
}
const developmentChains = ["hardhat", "localhost"]
module.exports = {
networkConfig,
developmentChains,
} i cant find the error please help and let me know if you need my raffle.sol file |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hi, 2 questions:
You can throw a console.log(vrfCoordinatorV2Address) to see if its undefined! If you can paste the mock deploy file and the raffle contract would help a lot! |
Beta Was this translation helpful? Give feedback.
-
Let me know if this solves your problem:
const args = [
entranceFee,
gasLane,
callbackGasLimit,
interval,
subscriptionId,
vrfCoordinatorV2Address,
]
|
Beta Was this translation helpful? Give feedback.
-
@chrismogab Make sure the order of these args should be same as define in the constructor. const args = [
entranceFee,
gasLane,
callbackGasLimit,
interval,
subscriptionId,
vrfCoordinatorV2Address,
] constructor(
address vrfCoordinatorV2,
uint64 subscriptionId,
bytes32 gasLane, // keyHash
uint256 interval,
uint256 entranceFee,
uint32 callbackGasLimit
) |
Beta Was this translation helpful? Give feedback.
Let me know if this solves your problem:
args
toarguments
in this snippet: