-
Hello, failed to get chainId, falling back on net_version... I browsed the forum and found other people who encounter the same error message but didn't find an answer which solved my case. Could someone help me please? in the .env file, the GOERLI_RPC_URL is of the form GOERLI_RPC_URL=https://eth-goerli.g.alchemy.com/v2/<myKey> I tried several Alechemy keys without success. My hardhat.config.js file: require("hardhat-gas-reporter")
require("@nomiclabs/hardhat-etherscan")
require("solidity-coverage")
require("hardhat-deploy")
const GOERLI_RPC_URL =
process.env.GOERLI_RPC_URL ||
"https://eth-mainnet.alchemyapi.io/v2/your-api-key"
const PRIVATE_KEY =
process.env.PRIVATE_KEY ||
"0x11ee3108a03081fe260ecdc106554d09d9d1209bcafd46942b10e02943effc4a"
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || ""
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 31337,
// gasPrice: 130000000000,
},
goerli: {
url: GOERLI_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 5,
blockConfirmations: 6,
},
},
solidity: {
compilers: [
{
version: "0.8.7",
},
{
version: "0.6.6",
},
],
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
gasReporter: {
enabled: true,
currency: "USD",
outputFile: "gas-report.txt",
noColors: true,
// coinmarketcap: COINMARKETCAP_API_KEY,
},
namedAccounts: {
deployer: {
default: 0,
1: 0,
},
},
mocha: {
timeout: 500000,
}
} My 01-deploy-simpleStorage.js file: const { network } = require("hardhat")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId // chainId of the chain the script was deployed on
log(`Chain Id: ${chainId}`)
log("----------------------------------------------------")
log("Deploying SimpleStorage.sol and waiting for confirmations...")
const simpleStorage = await deploy("SimpleStorage", {
from: deployer,
args: [],
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
log(`ERC20.sol deployed at ${simpleStorage.address}`)
}
module.exports.tags = ["all", "simple"] Full message error: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hey @Direr make sure you have |
Beta Was this translation helpful? Give feedback.
-
@Direr I am noticing that you do not have this in hardhat file |
Beta Was this translation helpful? Give feedback.
-
Try the fix in the replies; if it persists, please push to GitHub and link it here. |
Beta Was this translation helpful? Give feedback.
Try the fix in the replies; if it persists, please push to GitHub and link it here.