Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.7.0) (argument="vrfCoordinatorV2", value=undefined, code=INVALID_ARGUMENT, version=abi/5.7.0) #6607

Open
BilgeKaanGencdogan opened this issue May 7, 2024 · 3 comments

Comments

@BilgeKaanGencdogan
Copy link

BilgeKaanGencdogan commented May 7, 2024

Hello,
I am having this issue,

bilgekaangencdogan@bilgekaangencdogan:~/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc$ yarn hardhat deploy
yarn run v1.22.22
warning package.json: No license field
$ /home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/.bin/hardhat deploy
WARNING: You are currently using Node.js v21.7.3, which is not supported by Hardhat. This can lead to unexpected behavior. See https://hardhat.org/nodejs-versions


Nothing to compile
Local network detected! Deploying mocks...
deploying "VRFCoordinatorV2Mock" (tx: 0x4e74378c5b2b11e352c170557032ab3fee375d54241c07e8580beab5e0cbd769)...: deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3 with 2984688 gas
Mocks Deployed!!
------------------------------------------------------------------
An unexpected error occurred:

Error: ERROR processing /home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/deploy/01-deploy-raffle.js:
Error: invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.7.0) (argument="vrfCoordinatorV2", value=undefined, code=INVALID_ARGUMENT, version=abi/5.7.0)
    at Logger.makeError (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
    at Logger.throwError (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
    at Logger.throwArgumentError (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/logger/src.ts/index.ts:285:21)
    at AddressCoder.Coder._throwError (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/abi/src.ts/coders/abstract-coder.ts:68:16)
    at AddressCoder.encode (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/abi/src.ts/coders/address.ts:22:18)
    at /home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/abi/src.ts/coders/array.ts:71:19
    at Array.forEach (<anonymous>)
    at pack (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/abi/src.ts/coders/array.ts:54:12)
    at TupleCoder.encode (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/abi/src.ts/coders/tuple.ts:54:20)
    at AbiCoder.encode (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/@ethersproject/abi/src.ts/abi-coder.ts:111:15)
    at DeploymentsManager.executeDeployScripts (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1215:19)
    at DeploymentsManager.runDeploy (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1061:5)
    at SimpleTaskDefinition.action (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/index.ts:450:5)
    at Environment._runTaskDefinition (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
    at Environment.run (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
    at SimpleTaskDefinition.action (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/index.ts:601:32)
    at Environment._runTaskDefinition (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
    at Environment.run (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
    at SimpleTaskDefinition.action (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/index.ts:690:5)
    at Environment._runTaskDefinition (/home/bilgekaangencdogan/Desktop/FreeCodeCampBlockchain/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

you can find my related files below

01-deploy-raffles:

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

const VRF_SUB_FUND_AMOUNT = ethers.parseEther("1")
module.exports = async function ({ getNamedAccounts, deployments }) {
    const { deploy, log } = deployments
    const { deployer } = await getNamedAccounts()
    const chainId = network.config.chainId
    let vrfCoordinatorV2Address, subscriptionId, vrfCoordinatorV2Mock

    if (developmentChains.includes(network.name)) {
        const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
        vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address
        const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
        const transactionReceipt = await transactionResponse.wait(1)
        subscriptionId = transactionReceipt.logs[0].args.subId
        // Fund the subscription
        // Usually, you'd need the link token on a real network
        await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, VRF_SUB_FUND_AMOUNT)
    } else {
        vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"]
        subscriptionId = networkConfig[chainId]["subscriptionId"]
    }

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

    // Ensure the Raffle contract is a valid consumer of the VRFCoordinatorV2Mock contract.
    if (developmentChains.includes(network.name)) {
        const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
        await vrfCoordinatorV2Mock.addConsumer(subscriptionId, raffle.address)
    }

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

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

helper-hardhat-config.js:

const { ethers } = require("hardhat")

const networkConfig = {
    11155111: {
        name: "sepolia",
        vrfCoordinatorV2: "0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B",
        entranceFee: ethers.parseEther("0.01"),
        gasLane: "0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae",
        subscriptionId: "0",
        callbackGasLimit: "500000", //500,000
        interval: "30",
    },
    31337: {
        name: "hardhat",
        entranceFee: ethers.parseEther("0.01"),
        gasLane: "0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae",
        callbackGasLimit: "500000", //500,000
        interval: "30",
    },
}

const developmentChains = ["hardhat", "localhost"]

module.exports = {
    networkConfig,
    developmentChains,
}

VRFCoordinatorV2Mock.sol:

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

import "@chainlink/contracts/src/v0.8/vrf/mocks/VRFCoordinatorV2Mock.sol";

I think there is a conflict with vrfCoordinatorV2 and VRFCoordinatorV2Mock, but I could not resolve it.
Thanks in advance!!

P.S: I know some people opened some issues about that error, but solutions in those issues did work for me, that is why I opened this issue, so please don't be mad at me @PatrickAlphaC :D

@flersion
Copy link

flersion commented May 9, 2024

Having the exact same problem when attempting to deploy at 15:19:40 in the video. I started this particular lesson a few days ago, so it could be a more recent issue.

@BilgeKaanGencdogan
Copy link
Author

Having the exact same problem when attempting to deploy at 15:19:40 in the video. I started this particular lesson a few days ago, so it could be a more recent issue.

Yes, I am in the same lesson. I could not resolve it. Hoping @PatrickAlphaC see my issue and respond it :D

@PatrickAlphaC
Copy link
Contributor

Hi all,

Sorry, I no longer will be supporting these repos.

Moving forward, I'd like to direct everyone over to Cyfrin Updraft where all content will be kept up to date! With tutorials like the foundry ultimate course kept open sourced and 100% free as always.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants