Error: No Contract deployed with name FundMe #5597
-
This error is driving me crazy I should also add that I code in the Windows environment NOT WSL
and then i face to this f***ing Error:
fundme unit test: const { assert } = require("chai");
const { deployments, ethers, getNamedAccounts } = require("hardhat");
describe("FundMe", () => {
let fundMe;
let mockV3Aggregator;
let deployer;
const sendValue = ethers.utils.parseEther("1");
beforeEach(async () => {
// const accounts = await ethers.getSigners();
// deployer = accounts[0];
deployer = (await getNamedAccounts()).deployer;
await deployments.fixture(["all"]);
fundMe = await ethers.getContract("FundMe", deployer);
mockV3Aggregator = await ethers.getContract("MockV3Aggregator", deployer);
});
describe("construcotor", () => {
it("sets ths aggregator addresses correctly", async () => {
const response = await fundMe.priceFeed();
assert.equal(response, mockV3Aggregator.address);
});
});
}); this one is 00-deploy-mocks.js const { network } = require("hardhat");
const {
developmentChain,
DECIMAL,
INITIAL_ASNWER,
} = require("../helper-hardhat-config");
module.exports.default = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
if (developmentChain.includes(network.name)) {
log("Local network detected! Deploying Mocks...");
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
args: [DECIMAL, INITIAL_ASNWER],
log: true,
});
log("Mocks Deployed!");
log("___________________________________________________");
}
};
module.exports.tags = ["all", "mocks"]; 01-deploy-fund-me.js : const { network, run } = require("hardhat");
const { networkConfig, developmentChain } = require("../helper-hardhat-config");
const { verify } = require("../utils/verify");
module.exports.default = async ({ getNamedAccounts, deployments }) => {
const { deploy, log, get } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
let ethUsdPriceFeedAddress;
if (developmentChain.includes(network.name)) {
const ethUsdAggregator = await get("MockV3Aggregator");
ethUsdPriceFeedAddress = ethUsdAggregator.address;
} else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeedAddress"];
}
const args = [ethUsdPriceFeedAddress];
const fundMe = await deploy("FundMe", {
from: deployer,
args,
log: true,
waitConfirmations: network.config.blockConfirmation || 1,
});
if (
!developmentChain.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
await verify(fundMe.address, args);
}
log("---------------------------------------------");
};
module.exports.tags = ["all", "fundme"]; hardhat.config.js require("@nomicfoundation/hardhat-toolbox");
require("hardhat-deploy");
require("@nomiclabs/hardhat-etherscan");
require("dotenv").config();
require("hardhat-gas-reporter");
require("solidity-coverage");
const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL;
const SEPOLIA_PRIVATE_KEY = process.env.SEPOLIA_PRIVATE_KEY;
const GOERLI_RPC_URL = process.env.GOERLI_RPC_URL;
const GOERLI_PRIVATE_KEY = process.env.GOERLI_PRIVATE_KEY;
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY;
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY;
module.exports = {
// solidity: "0.8.18",
solidity: {
compilers: [{ version: "0.8.18" }, { version: "0.6.6" }],
},
defaultNetwork: "hardhat",
networks: {
sepolia: {
url: SEPOLIA_RPC_URL,
accounts: [SEPOLIA_PRIVATE_KEY],
chainId: 11155111,
blockConfirmation: 6,
},
goerli: {
url: GOERLI_RPC_URL,
accounts: [GOERLI_PRIVATE_KEY],
chainId: 5,
blockConfirmation: 6,
},
},
namedAccounts: {
deployer: {
default: 0,
},
users: {
default: 0,
},
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
gasReporter: {
enabled: COINMARKETCAP_API_KEY ? true : false,
currency: "USD",
coinmarketcap: COINMARKETCAP_API_KEY,
outputFile: "./gas-reporter.txt",
noColors: true,
},
}; |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
@amirxoder you need to parse args in your const fundMe = await deploy("FundMe", {
from: deployer,
args,
log: true,
waitConfirmations: network.config.blockConfirmation || 1,
}); after const fundMe = await deploy("FundMe", {
from: deployer,
args:args,
log: true,
waitConfirmations: network.config.blockConfirmation || 1,
}); then try to run |
Beta Was this translation helpful? Give feedback.
-
@amirxoder in your const ethUsdAggregator = await get("MockV3Aggregator"); to this const ethUsdAggregator = await deployments.get("MockV3Aggregator"); |
Beta Was this translation helpful? Give feedback.
-
@amirxoder Remove |
Beta Was this translation helpful? Give feedback.
-
@amirxoder Remove |
Beta Was this translation helpful? Give feedback.
@amirxoder Remove
default
from these exports otherwise script will not be able to detect tags exportmodule.exports.default