smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
12.27k stars 2.95k forks source link

Error: ERROR processing C:\Users\HP\smartcontract-lottery\deploy\01-deploy-raffle.js: Error: incorrect data length (argument="gaslane", value={"type":"BigNumber","hex":"0x2386f26fc10000"}, code=INVALID_ARGUMENT, version=abi/5.6.4) #866

Open chidubemOkafor opened 2 years ago

chidubemOkafor commented 2 years ago

Lesson

Lesson 9

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/gyMwXuJrbJQ?t=55155

Operating System

Windows

Describe the bug

this is my 01-deploy-raffle.js

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

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

    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")
        vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address
        const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
        const transactionReciept = await transactionResponse.wait()
        subscriptionId = transactionReciept.events[0].args.subId

        await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, VRF_SUB_FUND_AMOUNT)
      } else {
        vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"]
        subscriptionId = networkConfig[chainId]["subscriptionId"]
      }

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

    const args = [
        vrfCoordinatorV2Address,
        interval,
        entranceFee,
        gasLane,
        subscriptionId,
        callBackGasLimit,
    ]
    const raffle = await deploy("Raffle", {
        from: deployer,
        args: args,
        log: true,
        waitConfirmations: network.config.blockConfirmations || 1,
    })

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

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

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

and this is my: helper.hardhat-config.js

     const { ethers } = require("hardhat")

     const networkConfig = {
      4: {
     name: "rinkeby",
     vrfCoordinatorV2: "0x6168499c0cFfCaCD319c818142124B7A15E857ab",
     entranceFee: ethers.utils.parseEther("0.01"),
     gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
     subscriptionId: "0",
     callBackGasLimit: "500000",
     interval: "30",
     },
     31337: {
     name: "hardhat",
     entranceFee: ethers.utils.parseEther("0.01"),
     gasLane: "0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc",
     callBackGasLimit: "500000",
     interval: "30",
     },
     }

     const developmentChains = ["hardhat", "localhost"]
      module.exports = {
      networkConfig,
      developmentChains,
      }

![Screenshot 2022-07-10 143112](https://user-images.githubusercontent.com/93622341/178163100-72b74043-3658-45ae-a408-b1fa9673a0b7.png

I know I formatted this wrongly pls help me out 😔

krakxn commented 2 years ago

Refactor args to arguments and copy this:

const arguments = [
        vrfCoordinatorV2Address,
        subscriptionId,
        networkConfig[chainId]["gasLane"],
        networkConfig[chainId]["keepersUpdateInterval"],
        networkConfig[chainId]["raffleEntranceFee"],
        networkConfig[chainId]["callbackGasLimit"],
    ]

Let me know if this works

chidubemOkafor commented 2 years ago

Refactor args to arguments and copy this:

const arguments = [
        vrfCoordinatorV2Address,
        subscriptionId,
        networkConfig[chainId]["gasLane"],
        networkConfig[chainId]["keepersUpdateInterval"],
        networkConfig[chainId]["raffleEntranceFee"],
        networkConfig[chainId]["callbackGasLimit"],
    ]

Let me know if this works

it didn't work

chidubemOkafor commented 2 years ago

I don't want to give up but this error is really pushing it

krakxn commented 2 years ago

Okay, I see two problems:

entranceFee: "100000000000000000", 

Note: The entranceFee above should be formatted as a string.

chidubemOkafor commented 2 years ago

Okay, I see two problems:

  • In networkConfig in your helper.hardhat-config.js file, copy the following:
entranceFee: "100000000000000000", 

Note: The entranceFee above should be formatted as a string.

  • Also, please check your subscriptionId, is it supposed to be zero?

yes, in the video he made the subscriptionId to be zero

chidubemOkafor commented 2 years ago

Okay, I see two problems:

  • In networkConfig in your helper.hardhat-config.js file, copy the following:
entranceFee: "100000000000000000", 

Note: The entranceFee above should be formatted as a string.

  • Also, please check your subscriptionId, is it supposed to be zero?

I am still getting the same error

alymurtazamemon commented 2 years ago

@Chidubemcodes Please discuss this next time in the discussions tab.

one issue I am seeing is that const { verify } = require("../helper.hardhat-config") verify coming from helper file but it is not there.

Also check the order of these args should be same as contract constructor.

const args = [
    vrfCoordinatorV2Address,
    interval,
    entranceFee,
    gasLane,
    subscriptionId,
    callBackGasLimit,
  ]
krakxn commented 1 year ago

If this is resolved, please close the issue.

Additionally, if possible, a discussion with the category "Ideas" w/ the answer.

bvdaniel commented 1 year ago

I'm having an issue like this in the same step, after the mocks are deployed:

Error: ERROR processing /home/daniel/daniel/dev/chainlink/smartcontract-lottery-fcc/deploy/01-deploy-raffle.js:
TypeError: Cannot read properties of undefined (reading 'toHexString')

I'll tell you what I can find

bvdaniel commented 1 year ago

I'm having an issue like this in the same step, after the mocks are deployed:

Error: ERROR processing /home/daniel/daniel/dev/chainlink/smartcontract-lottery-fcc/deploy/01-deploy-raffle.js:
TypeError: Cannot read properties of undefined (reading 'toHexString')

I'll tell you what I can find

My mistake is that I was catching the 31337 network, where I hadn't specified gasLane yet, so I had an "undefined" value where a string should be.

koyuncuoglum95 commented 1 year ago

The gasLimit value is a property of a transaction object that specifies the maximum amount of gas that can be used for executing the transaction. It's possible that the gasLimit value provided in the script is too large or too small, resulting in the error.

One potential solution is to check the gasLimit value being passed to the contract deployment function and ensure that it is a valid integer value. You can also try to increase the gasLimit value slightly to see if that resolves the error.

Another possibility is that there is an issue with the version of the ABI library being used. You may want to check if there is an updated version of the library available and update it if necessary.