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: failed to get chainId, falling back on net_version... ConnectTimeoutError: Connect Timeout Error #6296

Open
PhilRandWu opened this issue Nov 20, 2023 · 1 comment
Labels

Comments

@PhilRandWu
Copy link

Lesson

Lesson 13

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")

No response

Operating System

Windows

Describe the bug

// hardhat.config.ts

hardhat: {
            chainId: 31337,
            forking: {
                url: MAINNET_RPC_URL,
                blockNumber: 14390000
            },
        },
MAINNET_RPC_URL = https://mainnet.infura.io/v3/key

// network.config.ts

  31337: {
        name: "localhost",
        wethToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
        lendingPoolAddressesProvider: "0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5",
        daiEthPriceFeed: "0x773616E4d11A78F511299002da57A0a94577F1f4",
        daiToken: "0x6b175474e89094c44da98b954eedeac495271d0f",
    },

It's just a call to the getWeth function,then Error: failed to get chainId, falling back on net_version... ConnectTimeoutError: Connect Timeout Error

@caducus7
Copy link

caducus7 commented Feb 7, 2024

I'm having the exact same issue on Lesson 07, when trying to deploy on Sepolia for the first time. I've been searching around but can't find a reason for this or tinker my way through to get the chainId, by defining anywhere else.

//hardhat-config.js

require("@nomicfoundation/hardhat-toolbox")
require("dotenv").config
require("@nomicfoundation/hardhat-verify")
require("hardhat-gas-reporter")
require("solidity-coverage")
require("hardhat-deploy")

/** @type import('hardhat/config').HardhatUserConfig */
const SEPOLIA_RPC_URL =
    process.env.SEPOLIA_RPC_URL ||
    "https://eth-sepolia.g.alchemy.com/v2/myappkey"
const PRIVATE_KEY =
    process.env.PRIVATE_KEY ||
    "myprivatekey"
const ETHERSCAN_API_KEY =
    process.env.ETHERSCAN_API_KEY || "etherscanapikey"
const COINMARKETCAP_API_KEY =
    process.env.COINMARKETCAP_API_KEY || "coimarketcapkey"

module.exports = {
    solidity: {
        compilers: [{ version: "0.8.8" }, { version: "0.6.6" }],
    },
    defaultNetwork: "hardhat",
    networks: {
        sepolia: {
            url: SEPOLIA_RPC_URL,
            chainId: 11155111,
            accounts: [PRIVATE_KEY],
            blockConfirmations: 6,
        },
        hardhat: {
            chainId: 31337,
        },
    },

//helper-hardhat-config if relevant

const networkConfig = {
    31337: {
        name: "localhost",
    },
    // Price Feed Address, values can be obtained at https://docs.chain.link/data-feeds/price-feeds/addresses
    11155111: {
        name: "sepolia",
        ethUsdPriceFeed: "0x694AA1769357215DE4FAC081bf1f309aDC325306",
    },
}

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

module.exports = { networkConfig, developmentChains }

//01-deploy-fund-me relevant chainId code

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


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

    let ethUsdPriceFeedAddress
    if (chainId == 31337) {
        const ethUsdAggregator = await deployments.get("MockV3Aggregator")
        ethUsdPriceFeedAddress = ethUsdAggregator.address
    } else {
        ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
    } 

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

No branches or pull requests

2 participants