full-blockchain-solidity-course-js
full-blockchain-solidity-course-js copied to clipboard
Error: failed to get chainId, falling back on net_version... ConnectTimeoutError: Connect Timeout Error
trafficstars
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
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"]
}