(Lesson7 FundMe Hardhat) Ethers getContract not working! Please help! #844
-
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
@shivam017arora Please follow How to Ask a Question Guide first and then tag me. |
Beta Was this translation helpful? Give feedback.
-
Try and import it in your hardhat.config.js file |
Beta Was this translation helpful? Give feedback.
-
Try running it with yarn then reinitialize vscode
or try reinstall all hardhat dependencies Check more info here: |
Beta Was this translation helpful? Give feedback.
-
const { deployments, ethers, getNamedAccounts } = require("hardhat");
const { assert } = require("chai");
describe("FundMe", async () => {
let fundMe;
let mock;
beforeEach(async () => {
//deploy fundMe using hardhat-deploy
await deployments.fixture("all");
//get the contract instance
const { deployer } = await getNamedAccounts();
mock = await ethers.getContract("MockV3Aggregator", deployer);
fundMe = await ethers.getContract("FundMe", deployer);
});
describe("Constructor", async () => {
it("should deploy a contract", async () => {
const address = await fundMe.getPriceFeedAddress();
assert.equal(address, mock.address);
}).timeout(5000);
});
}); add ["all"] as mention below
|
Beta Was this translation helpful? Give feedback.
Try running it with yarn then reinitialize vscode
yarn hardhat add @nomiclabs/hardhat-ethers
& remember to import itor try reinstall all hardhat dependencies
Check more info here:
https://hardhat.org/hardhat-runner/plugins/nomiclabs-hardhat-ethers