Lesson 9: An unexpected error occurred: #4809
Answered
by
alymurtazamemon
fatihpehlvan
asked this question in
Q&A
-
I am at around 15:20:00
Here is my helper-hardhat-config.js const { ethers } = require("hardhat")
const networkConfig = {
5: {
name: "goerli",
vrfCoordinator: "0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D",
enteranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15",
subscriptionId: "0",
callbackGasLimit: "500000", // 500,000
interval: "30",
},
31337: {
name: "localhost",
enteranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15",
callbackGasLimit: "500000",
interval: "30",
},
}
const developmentChains = ["hardhat", "localhost"]
module.exports = {
networkConfig,
developmentChains,
} Here is 00-deploy-mock.js const { network, ethers } = require("hardhat")
const { developmentChains } = require("../helper-harhat-config")
const BASE_FEE = ethers.utils.parseEther("0.25")
const GAS_PRICE_LINK = 1e9
const args = [BASE_FEE, GAS_PRICE_LINK]
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
if (developmentChains.includes(network.name)) {
log("Local network detected! Deploying mocks...")
// deploy a mock vrfcoordinator...
await deploy("VRFCoordinatorV2Mock", {
from: deployer,
log: true,
args: args,
})
log("Mocks Deployed")
log("------------------------------------")
}
}
module.exports.tags = ["all", "mocks"] And here is 01-deploy-raffle.js const { network, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../helper-harhat-config")
const { verify } = require("../utils/verify")
const VRF_SUB_FUND_AMOUNT = hardhat.ethers.util.parseEther("2")
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
let vrfCoordinatorV2Address, subscriptionId
if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.adress
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait(1)
subscriptionId = transactionReceipt.events[0].args.subId
// Fund the subscription
// Usually, you'd need the link token on a real network
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId)
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinator"]
subscriptionId = networkConfig[chainId]["subscriptionId"]
}
const enteranceFee = 10000000000 //networkConfig[chainId]["enteranceFee"]
const gasLane = networkConfig[chainId]["gasLane"]
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"]
const interval = networkConfig[chainId]["interval"]
const args = [
vrfCoordinatorV2Address,
enteranceFee,
gasLane,
subscriptionId,
callbackGasLimit,
interval,
]
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
if (!developmentChains.includes(network.name) && process.env.ETHERSCAM_API_KEY) {
log("Verifying...")
await verify(raffle.address, args)
}
log("---------------------------------------")
}
module.exports.tags = ["all", "raffle"] Could you please help me? |
Beta Was this translation helpful? Give feedback.
Answered by
alymurtazamemon
Feb 13, 2023
Replies: 1 comment 5 replies
-
@fatihpehlvan Your mocks deploy script looks correct. Please leave your repo link so I can test it and let you know the reason. |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
fatihpehlvan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@fatihpehlvan Your mocks deploy script looks correct. Please leave your repo link so I can test it and let you know the reason.