-
when i am trying to deploy my contract its showing error, I need help I am not able to where I am getting error :( github repo link: https://github.com/N-dcool/hardhat-smartcontract-lottery |
Beta Was this translation helpful? Give feedback.
Answered by
N-dcool
Mar 12, 2023
Replies: 1 comment 3 replies
-
here is my 00-deploy-mocks.js : const { network, ethers } = require("hardhat");
const { developmentChains } = require("../helper-hardhat-config");
const BASE_FEE = ethers.utils.parseEther("0.25"); // 0.25 is the premium. It cost 0.25 LINK per request.
const GAS_PRICE_LINK = 1e9; //link per gas or calculated value based on the gas price of the chain
// what if ETH price 📈 $1,000,000,000
// Chainlink Nodes pay the gas fees to give us randomness & do external execution
// so they price of requests change based on the 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 vrfCoordinator..
await deploy("VRFCoordinatorV2Mock", {
from: deployer,
log: true,
args: args,
});
log("Mocks deployed! 🎀");
log("----------------------------------------------------");
}
};
module.exports.tags = ["all", "mocks"];
01-deploy-raffle: const { network } = require("hardhat");
const { developmentChains, networkConfig } = require("../helper-hardhat-config");
const { verify } = require("../utils/verify");
const VRF_SUB_FUND_AMOUNT = ethers.utils.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.address;
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, 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,
log: 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.tags = ["all", "raffle"];
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
N-dcool
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here is my 00-deploy-mocks.js :