1
const { network, ethers } = require("hardhat")
const { developmentChains, networkConfig } = require("../helper-hardhat-config")

const { verify } = require("../utils/verify")

const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("30")

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",
      deployer
    )
    vrfCoordinatorV2Address = VRFCoordinatorV2Mock.address

    const transactionResponse = await VRFCoordinatorV2Mock.createSubscription()
    const transactionReceipt = await transactionResponse.wait(1)
    subscriptionId = transactionReceipt.events[0].args[0]
    console.log("SubsCription Id: ", subscriptionId)
    await VRFCoordinatorV2Mock.fundSubscription(
      subscriptionId,
      VRF_SUB_FUND_AMOUNT
    )
  } else {
    vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorv2"]
    subscriptionId = networkConfig[chainId]["subscriptionId"]
  }

  const enterenceFee = networkConfig[chainId]["enterenceFee"]
  const gasLane = networkConfig[chainId]["gasLane"]
  const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"]
  const interval = networkConfig[chainId]["interval"]
  const arguments = [
    vrfCoordinatorV2Address,
    enterenceFee,
    gasLane,
    subscriptionId,
    callbackGasLimit,
    interval,
  ]

  console.log(deployer)

  const lottery = await deploy("Lottery", {
    from: deployer.deployer,
    args: arguments,
    log: true,
    waitConformations: network.config.blockConformations || 1,
  })

  if (
    !developmentChains.includes(network.name) &&
    process.env.ETHERSCAN_API_KEY
  ) {
    log("Verifying ..........")
    await verify(lottery.address, args)
  }

  log("--------------------------------------------")
}

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

Error:

ERROR processing C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\deploy\01-deploy-lottery.js:
Error: invalid signer or provider (argument="signerOrProvider", value={"deployer":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","player":"0x70997970C51812dc3A010C7d01b50e0d17dc79C8"}, code=INVALID_ARGUMENT, version=contracts/5.7.0)
    at Logger.makeError (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)
    at Logger.throwError (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)
    at Logger.throwArgumentError (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\@ethersproject\logger\src.ts\index.ts:285:21)
    at Contract.BaseContract (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\@ethersproject\contracts\src.ts\index.ts:674:20)
    at new Contract (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\@ethersproject\contracts\lib\index.js:1053:42)
    at getContractAt (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:437:10)
    at getContractOrNull (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:464:12)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runNextTicks (node:internal/process/task_queues:65:3) 
    at listOnTimeout (node:internal/timers:528:9)
    at DeploymentsManager.executeDeployScripts (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1222:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runNextTicks (node:internal/process/task_queues:65:3) 
    at listOnTimeout (node:internal/timers:528:9)
    at processTimers (node:internal/timers:502:7)
    at DeploymentsManager.runDeploy (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\DeploymentsManager.ts:1052:5)
    at SimpleTaskDefinition.action (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\index.ts:438:5)
    at Environment._runTaskDefinition (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat\src\internal\core\runtime-environment.ts:311:14)
    at Environment.run (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat\src\internal\core\runtime-environment.ts:159:14)
    at SimpleTaskDefinition.action (C:\Users\user\OneDrive\Desktop\BlockChain\hardhat-lottery\node_modules\hardhat-deploy\src\index.ts:584:32)

I am not able to figure out what mistake I am making.. also if I am removing deployer address from vrfCoordinatorV2Mock it is giving another error for-- from.toLowerCase() is not defined. Can someone here help me out with this bug?

0

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.