-
Hello. Im getting an error from my 01-deploy-raffle.js script from lesson 9. When i try to deploy, it returns the error below, i've checked the addresses, but i can't seem to find a solution, anyone experienced this issues aswell, and any idea how to fix it? My repository: here The error:
My 01-deploy-raffle.js const { network } = require("hardhat")
const {
networkConfig,
developmentChains,
VERIFICATION_BLOCK_CONFIRMATIONS,
} = require("../helper-hardhat-config")
const { verify } = require("../utils/verify")
const FUND_AMOUNT = ethers.utils.parseEther("1") // 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, subscriptionId, vrfCoordinatorV2Mock
if (chainId == 31337) {
// create VRFV2 Subscription
log("local network detected, deploying mock!")
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 subscription
// Our mock makes it so we don't actually have to worry about sending fund
await vrfCoordinatorV2Mock.addConsumer(subscriptionId, FUND_AMOUNT) //// <-- i changed this
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"]
subscriptionId = networkConfig[chainId]["subscriptionId"]
}
const waitBlockConfirmations = developmentChains.includes(network.name)
? 1
: VERIFICATION_BLOCK_CONFIRMATIONS
log("----------------------------------------------------")
const arguments = [
vrfCoordinatorV2Address,
subscriptionId,
networkConfig[chainId]["gasLane"],
networkConfig[chainId]["keepersUpdateInterval"],
networkConfig[chainId]["raffleEntranceFee"],
networkConfig[chainId]["callbackGasLimit"],
]
const raffle = await deploy("Raffle", {
from: deployer,
args: arguments,
log: true,
waitConfirmations: waitBlockConfirmations || 1,
})
// Ensure the Raffle contract is a valid consumer of the VRFCoordinatorV2Mock contract.
if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
await vrfCoordinatorV2Mock.addConsumer(subscriptionId, raffle.address)
}
// Verify the deployment
if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_API_KEY) {
log("Verifying...")
await verify(raffle.address, arguments)
}
log("Enter lottery with command:")
const networkName = network.name == "hardhat" ? "localhost" : network.name
log(`yarn hardhat run scripts/enterRaffle.js --network ${networkName}`)
log("----------------------------------------------------")
}
module.exports.tags = ["all", "raffle"] Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
@Holger-ap can you send a screenshot of the entire error message? Usually at the end it says on which line the error was caught or check that the addresses of the |
Beta Was this translation helpful? Give feedback.
-
@pacelliv Me too i am getting the same problem. Can you help me?? You can find all the files here |
Beta Was this translation helpful? Give feedback.
@Holger-ap can you send a screenshot of the entire error message? Usually at the end it says on which line the error was caught or check that the addresses of the
VRFCoordinatorV2
in thehelper-hardhat-config
are strings.