Lesson 9 Error while deploying arround 15:19:00 #1776
-
Error processing 01-deploy-raffle.js 01-deploy-raffle.js const { network, ethers } = require("hardhat")
const {developmentChains, networkConfig, verify } = require("../helper-hardhat-config")
const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("0.01")
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.address
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait(1);
subscriptionId = transactionReceipt.events[0].args.subId
//fund the subscription
//usually you need the link 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 = [vrfCoordinatorV2Address, entranceFee, gasLane,subscriptionId,callBackGasLimit,interval]
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
logs: 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 = ["all", "raffle"] 00-deploy-mocks.js const { network } = require("hardhat")
const {developmentChains} = require("../helper-hardhat-config")
const BASE_FEE = ethers.utils.parseEther("0.25") //0.25 is the premium . It costs 0.25 link per request
const GAS_PRICE_LINK = 1e9; //link per gas. Calculated value based on the gas price of currnet gas price
//Chainlink pay the gas fees to give us randomness & do external execution
//so the price of request change based on price of gas
module.exports = async function ({getNamedAccounts, deployments}){
const { deploy, log} = deployments
const {deployer} = await getNamedAccounts()
const args = [BASE_FEE, GAS_PRICE_LINK]
if(developmentChains.includes(network.name)){
log("Local Network detected! Deploying mocks...")
//deploy a mock vrf coordinator ..
await deploy("VRFCoordinatorV2Mock", {
from: deployer,
log: true,
args: args,
})
log("Mocks Deployed..")
log("--------------------------------------------------------------")
}
}
module.exports.tags = ["all", "mocks"] helper-hardhat-config.js const { ethers } = require("hardhat")
const networkConfig = {
4: {
name: "rinkeby",
vrfCoordinatorV2: " 0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
subscriptionId : "0",
callBackGasLimit: "500000",
interval: "30",
},
31337:{
name: "hardhat",
//do not need vrfCoordinatorV2 as we are deploying a mock
vrfCoordinatorV2: " 0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
//in hardhat as we are using mock it doesnt mater on which gasLane we are wqorking on so can give anything
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
callBackGasLimit: "500000",
interval: "30",
}
}
const developmentChains = ["hardhat", "localhost"]
module.exports ={
networkConfig,
developmentChains,
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Possible fixes:
const args = [vrfCoordinatorV2Address, entranceFee, gasLane,subscriptionId,callBackGasLimit,interval]
4: {
name: "rinkeby",
vrfCoordinatorV2: " 0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
subscriptionId : "0",
callBackGasLimit: "500000",
interval: "30",
}, as it should not be zero.
4: {
name: "rinkeby",
vrfCoordinatorV2: " 0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
subscriptionId : "0",
callBackGasLimit: "500000",
interval: "30",
},
31337:{
name: "hardhat",
//do not need vrfCoordinatorV2 as we are deploying a mock
vrfCoordinatorV2: " 0x6168499c0cFfCaCD319c818142124B7A15E857ab",
entranceFee: ethers.utils.parseEther("0.01"),
//in hardhat as we are using mock it doesnt mater on which gasLane we are wqorking on so can give anything
gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
callBackGasLimit: "500000",
interval: "30",
} |
Beta Was this translation helpful? Give feedback.
-
@yash-2138 Update this inside - module.exports = ["all", "raffle"]
+ module.exports.tags = ["all", "raffle"] |
Beta Was this translation helpful? Give feedback.
-
👉 👉 Those blockchain developers who are done with the Lesson#15 repo, they can go to this thread #2107 : 🔥🔥🔥🔥🔥🔥 |
Beta Was this translation helpful? Give feedback.
@yash-2138 Update this inside
01-deploy-raffle.js
: