1

When the contract will deploy locally on developmentChains (hardhat environment) with the following script:

deploy.js

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


module.exports = async function ({ getNamedAccounts, deployments }) {
  const { deploy, log } = deployments
  const { deployer } = await getNamedAccounts()

  const chainId = network.config.chainId
  const VRF_SUB_FUND_AMOUNT_LOCALNETWORK = ethers.parseEther("100")

  const entranceFee = networkConfig[chainId]["entranceFee"]
  const gasLane = networkConfig[chainId]["keyHash"]
  const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"]
  const interval = networkConfig[chainId]["interval"]

  let vrfCoordinatorV2_5Address, subscriptionId, args

  if (developmentChains.includes(network.name)) {

    args = []
    // args = [30]

    const signer = await ethers.getSigner(deployer)
    const vrfCoordinatorV2_5Address = (await deployments.get("VRFCoordinatorV2_5Mock")).address
    const vrfCoordinatorV2 = await ethers.getContractAt("VRFCoordinatorV2_5Mock", vrfCoordinatorV2_5Address, signer)

    // create the subscription
    const transactionResponse = await vrfCoordinatorV2.createSubscription()
    const transactionReceipt = await transactionResponse.wait()

    subscriptionId = transactionReceipt.logs[0].args.subId

    const transactionResponseA = await vrfCoordinatorV2.fundSubscription(subscriptionId, VRF_SUB_FUND_AMOUNT_LOCALNETWORK)
    await transactionResponseA.wait()
  } else {
    vrfCoordinatorV2_5Address = networkConfig[chainId]["vrfCoordinatorV2"]
    subscriptionId = networkConfig[chainId]["subscriptionId"]
    args = [vrfCoordinatorV2_5Address, entranceFee, gasLane, subscriptionId, callbackGasLimit, interval]
  }

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

  if (!developmentChains.includes(network.name) && vars.has("ETHERSCAN_API_KEY")) {
    log("Verifying...")
    await verify(blob.address, args)
  }
  log("--------------------------")
}
module.exports.tags = ["all", "blob"]

Blob - Constructor

  constructor(
    address _vrfCoordinator,
    uint256 entrance,
    bytes32 gasLane,
    uint256 subscriptionId,
    uint32 callbackGasLimit,
    uint256 interval
  ) VRFConsumerBaseV2Plus(_vrfCoordinator) {
    i_vrfCoordinator = IVRFCoordinatorV2Plus(_vrfCoordinator);
    i_entrance = entrance;
    i_gasLane = gasLane;
    s_subscriptionId = subscriptionId; 
    i_callbackGasLimit = callbackGasLimit;
    i_interval = interval;
    s_lastTimestamp = block.timestamp;
  }

Actually, I expect the parse / compiler would expects 6 constructor arguments...

Hardhat-VM:

eth_chainId (2)
eth_accounts (2)
eth_chainId (2)
eth_estimateGas
eth_chainId
eth_getTransactionCount
eth_blockNumber
eth_chainId
eth_getBlockByNumber
eth_feeHistory
eth_maxPriorityFeePerGas
eth_sendTransaction
  Contract deployment: VRFCoordinatorV2_5Mock
  Contract address:    0x5fbdb2315678afecb367f032d93f642f64180aa3
  Transaction:         0xf2fe779536aaad6df94922f8e2583145e46c4330f52e1b88ea1fd759718c5f8c
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  Value:               0 ETH
  Gas used:            5364148 of 5364148
  Block #1:            0x9bb34680137d95c6e55c99dbce662af8af3b227a3fd3ea01fe913f169aa7073e

eth_chainId
eth_getTransactionByHash
eth_chainId
eth_getTransactionReceipt
hardhat_metadata
eth_blockNumber
eth_feeHistory
eth_sendTransaction
  Contract call:       VRFCoordinatorV2_5Mock#createSubscription
  Transaction:         0xf98cf0ad6d06ea315b959d7d5ebbf50b0c9cc8105b0405ef9e83af89a1326a27
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x5fbdb2315678afecb367f032d93f642f64180aa3
  Value:               0 ETH
  Gas used:            146429 of 30000000
  Block #2:            0x2ecc2208bcbe5c7eb9267a39c6d8d11ce7207df4775c67a783cdd102e37d7f72

eth_getTransactionByHash
eth_getTransactionReceipt
eth_blockNumber (2)
eth_feeHistory
eth_sendTransaction
  Contract call:       VRFCoordinatorV2_5Mock#fundSubscription
  Transaction:         0x3131c6d9ebe95c9cac82a5bd25b4f23be8fe5914a103ca96f53c467c0c735499
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  To:                  0x5fbdb2315678afecb367f032d93f642f64180aa3
  Value:               0 ETH
  Gas used:            72196 of 30000000
  Block #3:            0x023ceaf780f0324b3bfceacba1ee5c25864d1889df89bbff3e1a73402c68e77f

eth_getTransactionByHash
eth_getTransactionReceipt
eth_blockNumber
eth_chainId
eth_estimateGas -> !!! THIS IS COLORED RED!!!

  Contract creation without any data provided
  1. If args = [30] has some value, there´s an Error: expected 0 constructor arguments, got 1
  2. If args = [] is empty, there´s an ProviderError: Contract creation without any data provided. But VRFCoordinatorV2_5Mock has been deployed. Blob has not been deployed.

If more than 0 args the contract won´t deploy. Could someone assist me to prevent this error(s) and tell me what´s going on please?

5
  • Can you share your Blob contract's constructor?
    – Rohan Nero
    Commented Nov 21 at 19:41
  • 2
    I have edded it in the question
    – Dennis
    Commented Nov 21 at 19:58
  • I found a few relevant posts that seem similar to yours, by chance is your Blob contract marked abstract?: ethereum.stackexchange.com/questions/164615/… Stack overflow post: stackoverflow.com/questions/76603654/… Another Stack Exchange post: ethereum.stackexchange.com/questions/152066/…
    – Rohan Nero
    Commented Nov 22 at 20:32
  • 1
    Little bit strange ... I declared the contract as abstract after your advice. Then I got the same error messages as before. After this I canceled this declaration again and the parse wants to have 6 arguments now. The more the less your advice helped me to solve this issue. Now I have some undefined errrors :) but this is not part of this question.
    – Dennis
    Commented Nov 24 at 14:20
  • I'm sorry. I should have specified that those solutions were related to the contract being incorrectly marked abstract; I wasn't suggesting that you mark yours abstract. Anyway, I'm glad you were able to solve your issue!
    – Rohan Nero
    Commented Nov 26 at 4:26

0

Your Answer

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