Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 7 error : "before each" hook for "should set the aggregator address correctly": TypeError: ethers.getContract is not a function #6484

Open
wbshobhit1 opened this issue Mar 6, 2024 Discussed in #6483 · 1 comment

Comments

@wbshobhit1
Copy link

Discussed in #6483

Originally posted by wbshobhit1 March 6, 2024
`const { assert } = require("chai");
const { getNamedAccounts, deployments, ethers } = require("hardhat");

describe("FundMe", async function () {
let fundMe;
let deployer;
let mockV3Aggregator;
beforeEach(async function () {
// const accounts = await ethers.getSigners();
// const accountZero = accounts[0];
deployer = (await getNamedAccounts()).deployer;
await deployments.fixture(["all"]);
fundMe = await ethers.getContract("FundMe", deployer);
mockV3Aggregator = await ethers.getContract(
"MockV3Aggregator",
deployer,
);
});

describe("constructor", async function () {
    it("should set the aggregator address correctly", async function () {
        const response = await fundMe.priceFeed();
        assert.equal(response, mockV3Aggregator.target);
    });
});

});
`

I am getting this error "TypeError: ethers.getContract is not a function"
i have tried all the possible solution present on the StackOverflow and ethetruem stack solution no solution seems to work.

@mrxain699
Copy link

Hello @wbshobhit1 Try ether.getContractFactory("FundMe).then((factory) => factory.deploy(deployer))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants