|
I run into this error, and tried all answered in the discussions before. Can someone please help me? helper-hardhat-config.js const networkConfig = {
31337: {
name: "localhost",
},
5: {
name: "goerli",
ethUsdPriceFeed: "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e",
},
137: {
name: "polygon",
ethUsdPriceFeed: "0xF9680D99D6C9589e2a93a78A04A279e509205945",
},
// 31337
};
const developmentChain = ["hardhat", "localhost"];
const DECIMALS = 8;
const INITIAL_ANSWER = 200000000000;
module.exports = {
networkConfig,
developmentChain,
DECIMALS,
INITIAL_ANSWER,
};00-deploy-mock.js const { network } = require("hardhat");
const DECIMALS = "8";
const INITIAL_PRICE = "200000000000"; // 2000
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
// If we are on a local development network, we need to deploy mocks!
if (chainId == 31337) {
log("Local network detected! Deploying mocks...");
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMALS, INITIAL_PRICE],
});
log("Mocks Deployed!");
log("------------------------------------------------");
log(
"You are deploying to a local network, you'll need a local network running to interact"
);
log(
"Please run `npx hardhat console` to interact with the deployed smart contracts!"
);
log("------------------------------------------------");
}
};
module.exports.tags = ["all", "mocks"];01-deploy-fund-me.js // import
// function deployFunc(hre) {
// console.log("Hi!");
// }
// module.exports.default = deployFunc;
const { network } = require("hardhat");
const { networkConfig, developmentChain } = require("../helper-hardhat-config");
// equals: const helperConfig = require("../helper-hardhat-config"); const networkConfig = helperConfig.networkConfig
// equals above, just don't have a func name
module.exports = async ({ getNamedAccounts, deployments }) => {
//const { getNameAccounts, deployments } = hre;
// hre.getNameAccounts; hre.deployments
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
// changing priceFeed according to chainId
// let ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"];
let ethUsdPriceFeedAddress;
if (chainId == 31337) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator");
ethUsdPriceFeedAddress = ethUsdAggregator.address;
} else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"];
}
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress], //Put price feed address
log: true,
});
log(
"------------------------------------------------------------------------"
);
// when going for localhost or hardhat we want to use the mock
// const fundMe = await deploy("FundMe", {
// from: deployer,
// args: [ethUsdPriceFeedAddress],
// log: true,
// });
};
module.exports.tags = ["all", "fundMe"];hardhat.config.js require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();
require("@nomiclabs/hardhat-etherscan");
require("./tasks/block-number");
require("hardhat-gas-reporter");
require("solidity-coverage");
require("hardhat-deploy");
/** @type import('hardhat/config').HardhatUserConfig */
const GOERLI_RPC_URL = process.env.GOERLI_RPC_URL || "https://eth-goerli"; // add this or in case env is not functioning normally
const PRIVATE_KEY = process.env.PRIVATE_KEY || "0xkey";
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || "key";
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY || "key";
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 31337,
// gasPrice: 130000000000,
},
goerli: {
url: GOERLI_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 5,
},
localhost: {
url: "http://127.0.0.1:8545/",
// accounts: Hardhat already generate 10 fake accounts for us
chainId: 31337,
},
},
solidity: {
compilers: [{ version: "0.8.17" }, { version: "0.6.6" }],
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
gasReporter: {
enabled: true,
outputFile: "gas-report.txt",
noColors: true,
currency: "USD",
coinmarketcap: COINMARKETCAP_API_KEY,
token: "MATIC",
},
nameAccounts: {
deployer: {
default: 0,
},
user: {
default: 1,
},
},
}; |
Answered by
ghost
Jan 3, 2023
Replies: 1 comment 3 replies
|
There's a typo in the name of the Let me know if this fix the issue. |
3 replies
Answer selected by
wendy556
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a typo in the name of the
namedAccountsfield in thehardhat.configfile, you're missing a d.Let me know if this fix the issue.