0

I am trying to deploy a Solidity contract using a deployment script in Hardhat. However, I encountered an error during the deployment process.I'm using Hardhat as my development environment, and I have already compiled the contract successfully. However, it seems that there is an issue with the bytecode or data being provided during deployment. The error message I received is as follows:

Error: expected 0 constructor arguments, got 6

Deploy Script

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"); // Rest of the script... 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...

Solidity Code

// 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) { // (Constructor implementation...) } //Rest of the code 

I suspect that the issue might be related to the bytecode not being provided correctly during deployment. I have verified that the contract is compiled successfully and the bytecode is available in the artifacts/ directory.

Could someone please assist me in resolving this error? What could be causing the error during deployment?

1 Answer 1

1

Because of the abstract contract you defined in Lottery, remove abstract.(abstract contracts cannot be deployed directly.)

1
  • Thanks, @Ethan but I already tried that, it throws an error and refuses to compile and if I try making the constructor public, it logs that I am not implementing from the base contract. Commented Jul 3, 2023 at 9:59

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.