This section is my scripts section.. I am running in this error since 1 day I have searched a lot but couldn't find satisfactory answer.. well I am running in total two errors. But for now only this is showing up,

Error: No Contract deployed with name Lottery
    at Object.getContract (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy-ethers\src\internal\helpers.ts:447:11)
    at mockKeepers (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\scripts\mockoffchain.js:4:18)

The code for the run scripts is below,

const { ethers, network } = require("hardhat")

async function mockKeepers() {
  const raffle = await ethers.getContract("Lottery")
  const checkData = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(""))
  const { upkeepNeeded } = await raffle.callStatic.checkUpkeep(checkData)
  if (upkeepNeeded) {
    const tx = await raffle.performUpkeep(checkData)
    const txReceipt = await tx.wait(1)
    const requestId = txReceipt.events[1].args.requestId
    console.log(`Performed upkeep with RequestId: ${requestId}`)
    if (network.config.chainId == 31337) {
      await mockVrf(requestId, raffle)
  } else {
    console.log("No upkeep needed!")

async function mockVrf(requestId, raffle) {
  console.log("We on a local network? Ok let's pretend...")
  const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
  await vrfCoordinatorV2Mock.fulfillRandomWords(requestId, raffle.address)
  const recentWinner = await raffle.getRecentWinner()
  console.log(`The winner is: ${recentWinner}`)

  .then(() => process.exit(0))
  .catch((error) => {

module.exports.tags = ["all", "lottery"]

Lottery is a contract in my contract and it's deployed too.. but I don't know why this error is comping up to me. If anyone knows the correct answer then tell me the right way to do so.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.