Replies: 2 comments
-
|
i meet the same problem, did you resolve it? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Hi @eik-1 Instead of below: fundMe = await deployments.get("FundMe", deployer)
MockV3Aggregator = await deployments.get("MockV3Aggregator", deployer)try using this: fundMe = await ethers.getContract("FundMe", deployer)
mockV3Aggregator = await ethers.getContract("MockV3Aggregator", deployer) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I think there is a problem with hardhat-deploy functions.
This error that keeps on showing when I use
yarn hardhat testBelow is my FundMe.test.js
const { deployments, getNamedAccounts } = require("hardhat") const { assert } = require("chai") describe("FundMe", () => { let fundMe let MockV3Aggregator let deployer beforeEach(async () => { deployer = (await getNamedAccounts()).deployer await deployments.fixture(["all"]) fundMe = await deployments.get("FundMe", deployer) MockV3Aggregator = await deployments.get("MockV3Aggregator", deployer) }) describe("constructor", () => { it("sets the aggregator addresses corrrectly", async () => { const response = await fundMe.priceFeed() assert.equal(response, MockV3Aggregator.target) }) }) })Below is my deploymocks.js
const { network } = require("hardhat") const { developmentConfig, DECIMALS, INITIAL_PRICE, } = require("../helper-hardhat-config") async function deployFunc(hre) { const { getNamedAccounts, deployments } = hre const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainID = network.config.chainId if (chainID == 31337) { console.log("Local network detected! Deploying mocks...") await deploy("MockV3Aggregator", { from: deployer, log: true, args: [DECIMALS, INITIAL_PRICE], }) console.log("Mocks deployed!") log("------------------------------------------------------") } } module.exports.tags = ["all", "mocks"] module.exports = deployFuncBelow is my fundme.js
const { networkConfig, developmentConfig, } = require("../helper-hardhat-config.js") const { verify } = require("../utils/verify.js") const { network } = require("hardhat") async function deployFunc(hre) { const { getNamedAccounts, deployments } = hre const { deploy, log } = deployments const { deployer } = await getNamedAccounts() const chainId = network.config.chainID log("Deploying Contract ...") log(chainId) if (developmentConfig.includes(network.name)) { const ethUSDAggregator = await deployments.get("MockV3Aggregator") ethUSDPriceFeedAddress = ethUSDAggregator.address } else { ethUSDPriceFeedAddress = networkConfig[chainId]["ethUSDPriceFeed"] } const fundMe = await deploy("FundMe", { from: deployer, args: [ethUSDPriceFeedAddress], log: true, waitConfirmations: network.config.blockConfirmations || 1, }) log("Contract Deployed!!") log("------------------------------------------------------") if ( !developmentConfig.includes(network.name) && process.env.ETHERSCAN_API ) { log("Verifying Contract on Etherscan ...") await verify(fundMe.target, [ethUSDPriceFeedAddress]) log("Contract Verified!!") log("------------------------------------------------------") } } module.exports.tags = ["all", "fundme"] module.exports.default = deployFuncMy deployments folder has 2 subfolders: localhost and sepolia. I changed the name from localhost to hardhat because it was giving me errors for verifying otherwise.
Beta Was this translation helpful? Give feedback.
All reactions