Ошибка при развертывании контракта Solidity: ожидалось 0 аргументов конструктора, получено 6

Я пытаюсь развернуть контракт Solidity, используя сценарий развертывания в Hardhat. Однако в процессе развертывания возникла ошибка. В качестве среды разработки я использую Hardhat и уже успешно скомпилировал контракт. Однако похоже, что существует проблема с байт-кодом или данными, предоставляемыми во время развертывания. Сообщение об ошибке, которое я получил, выглядит следующим образом:Error: expected 0 constructor arguments, got 6

Развернуть скрипт

      const { network, ethers } = require("hardhat");
const {
  developmentChains,
  networkConfig,
  VERIFICATION_BLOCK_CONFIRMATIONS
} = require("../helper-hardhat-config.js");
const { verify } = require("../utils/verify");

console.log("I've reached here");

const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("1");

module.exports = async ({ getNamedAccounts, deployments }) => {
  const { deploy, log } = deployments;
  const { deployer } = await getNamedAccounts();
  let chainId = network.config.chainId;
  let vrfCoordinatorV2Address, subscriptionId, vrfCoordinatorV2Mock;

console.log("i've reached here")

  console.log(`chainId 01 : ${chainId}`)
  console.log("inside the 01-deploy-raffle.js");
  if (developmentChains.includes(network.name)) {
    vrfCoordinatorV2Mock = await ethers.getContract(
      "VRFCoordinatorV2Mock"
    );
    console.log("after mock");

    vrfCoordinatorV2Address = await vrfCoordinatorV2Mock.address;

    console.log(`Address ${vrfCoordinatorV2Address}`)
    const txResponse = await vrfCoordinatorV2Mock.createSubscription();
    const txReceipt = await txResponse.wait(1);
    subscriptionId = txReceipt.events[0].args.subId;
    // usually you will need Link token to fund the sub on a real network
    await vrfCoordinatorV2Mock.fundSubscription(
      subscriptionId,
      VRF_SUB_FUND_AMOUNT
    );
  } else {
    vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"];
    subscriptionId = networkConfig[chainId]["subscriptionId"];
  }
  const waitBlockConfirmations = developmentChains.includes(network.name)
  ? 1
  : VERIFICATION_BLOCK_CONFIRMATIONS

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

const entranceFee = networkConfig[chainId]["entranceFee"];
const gasLane = networkConfig[chainId]["gasLane"];
const callBackGasLimit = networkConfig[chainId]["callBackGasLimit"];
const interval = networkConfig[chainId]["interval"];

const args = [entranceFee, vrfCoordinatorV2Address, gasLane, subscriptionId, callBackGasLimit, interval];

//Error starts here!!

const lottery = await deploy("Lottery", {
  from: deployer,
  args: args,
  log: true,
  waitConfirmations: network.config.blockConfirmations || 1,
});

// Rest of the script...

Код надежности

      // SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AutomationCompatibleInterface.sol";

      abstract contract Lottery is VRFConsumerBaseV2, AutomationCompatibleInterface {
    // types/ enums
    enum LotteryState {
        open,
        calculating
    }

    // state variables
    uint256 private immutable i_entranceFee;
    address payable[] private s_players;
    VRFCoordinatorV2Interface private immutable i_vrfCoordinator;
    bytes32 private immutable i_gasLane;
    uint64 private immutable i_subscriptionId;
    uint16 private constant REQUEST_CONFIRMATIONS = 3;
    uint32 private immutable i_callBackGasLimit;
    uint32 private constant NUM_WORDS = 1;

    // lottery variables
    address private s_recentWinnerAddress;
    LotteryState private s_LotteryState;
    uint256 private s_LastTimeStamp;
    uint256 private immutable i_Interval;

    // events
    event LotteryEnter(address indexed player);
    event RequestedLotteryWinner(uint256 indexed requestId);
    event WinnerPicked(address indexed winner);

constructor(
    uint256 entranceFee,
    address vrfCoordinatorV2,
    bytes32 gasLane,
    uint64 subscriptionId,
    uint32 callBackGasLimit,
    uint256 interval
)
    VRFConsumerBaseV2(vrfCoordinatorV2)
{
            i_entranceFee = entranceFee;
        i_vrfCoordinator = VRFCoordinatorV2Interface(vrfCoordinatorV2);
        i_gasLane = gasLane;
        i_subscriptionId = subscriptionId;
        i_callBackGasLimit = callBackGasLimit;
        s_LotteryState = LotteryState.open;
        s_LastTimeStamp = block.timestamp;
        i_Interval = interval;
}
//Rest of the code

Я подозреваю, что проблема может быть связана с тем, что байт-код не предоставляется правильно во время развертывания. Я убедился, что контракт успешно скомпилирован и байт-код доступен в каталоге артефактов/.

Может ли кто-нибудь помочь мне решить эту ошибку? Что может быть причиной ошибки во время развертывания?

0 ответов

Другие вопросы по тегам