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")
require("@nomiclabs/hardhat-waffle");
require("hardhat-gas-reporter");
require("@nomiclabs/hardhat-etherscan");
require("dotenv").config();
require("solidity-coverage");
require("hardhat-deploy");
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY || "";
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 || "";
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
// solidity: "0.8.17",
solidity: {
compilers: [
{
version: "0.8.8",
},
{
version: "0.6.6",
},
],
},
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 31337,
// gasPrice: 130000000000,
},
goerli: {
url: GOERLI_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 5,
blockConfirmations: 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, // here this will by default take the first account as deployer
1: 0, // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
},
},
};
01-deploy-fund-me.js be like:
// import
const { network } = require("hardhat");
const {
networkConfig,
developmentChains,
} = require("../helper-hardhat-config");
const { verify } = require("../utils/verify");
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"];
}
// what happens when we want to deploy to change chains?
// when going for localhost or hardhat network, we want to use a mock
const args = [ethUsdPriceFeedAddress];
const fundMe = await deploy("FundMe", {
from: deployer,
args: [address],
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
});
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
await verify(fundMe.address, args);
}
log("--------------------------------------------------");
};
issue
When I run yarn hardhat deploy --network goerli, it didn't success, and print error be like:
failed to get chainId, falling back on net_version...
An unexpected error occurred:
ProviderError: HttpProviderError
at HttpProvider.request (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
at LocalAccountsProvider.request (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/providers/accounts.ts:187:34)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at ChainIdValidatorProvider._getChainIdFromEthNetVersion (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/providers/chainId.ts:33:17)
at ChainIdValidatorProvider._getChainId (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/providers/chainId.ts:17:25)
at ChainIdValidatorProvider.request (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/providers/chainId.ts:55:29)
at DeploymentsManager.getChainId (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:443:23)
at DeploymentsManager.loadDeployments (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:619:17)
at DeploymentsManager.runDeploy (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:999:5)
at SimpleTaskDefinition.action (/Users/sunxy/vscode_project/hh-fcc/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/index.ts:409:5)
error Command failed with exit code 1.
Lesson
Lesson 7
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
macOS (Apple Silicon)
Describe the bug
above
my package.json be like:
And my hardhat.config.js be like:
01-deploy-fund-me.js be like:
issue
When I run
yarn hardhat deploy --network goerli
, it didn't success, and print error be like: