Error: Cannot read properties of undefined (reading 'getBalance') #6635
Replies: 3 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
2 replies
-
|
i would like to say ethers 6 uses .getAddress() function instead of .address property. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
can anyone help me please? I got the same error @VatsalSharma12 @supermutecx |
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.
-
hello guys im running into an issue
Cannot read properties of undefined (reading 'getBalance')
here is the FundMetest.js code-
const { ethers, deployments, getNamedAccounts } = require("hardhat") const { expect, assert } = require("chai") const sendValue = "1000000000000000000" describe("FundMe", function () { let fundMe let deployer let mockV3Aggregator beforeEach(async function () { // Get the deployer account from named accounts const accounts = await getNamedAccounts() deployer = accounts.deployer // Deploy the contracts using the deployer account await deployments.fixture(["all"]) fundMe = await ethers.getContract("FundMe", deployer) mockV3Aggregator = await ethers.getContract( "MockV3Aggregator", deployer ) }) describe("constructor", function () { it("sets the aggregator address correctly", async function () { const response = await fundMe.getPriceFeed() assert.equal(response, mockV3Aggregator.target) }) }) describe("fund", function () { it("fails if you don't send enough ETH", async function () { await expect(fundMe.fund()).to.be.revertedWith( "You need to spend more ETH!" ) }) it("updates the amount funded data structure", async function () { const sendValue = ethers.parseEther("1") // 1 ETH await fundMe.fund({ value: sendValue, from: deployer }) const response = await fundMe.addressToAmountFunded(deployer) assert.equal(response.toString(), sendValue.toString()) }) it("adds funders to array of funders", async function () { await fundMe.fund({ value: sendValue }) const funder = await fundMe.funders(0) assert.equal(funder, deployer) }) }) describe("withdraw", async function () { beforeEach(async function () { await fundMe.fund({ value: sendValue }) }) it("Withdraw ETH from a single founder", async function () { //arrange const startingFundMeBalance = await fundMe.provider.getBalance( fundMe.target ) const startingDeployerBalance = await fundMe.provider.getBalance( deployer.target ) //act const transactionResponse = await fundMe.withdraw() const transactionReceipt = await transactionResponse.wait(1) const endingFundMeBalance = await fundMe.provider.getBalance( fundMe.target ) const endingDeployerBalance = await fundMe.provider.getBalance( deployer.target ) //asser. assert.equal(endingFundMeBalance, 0) assert.equal( startingFundMeBalance.add(startingDeployerBalance).toString(), endingDeployerBalance.toString() ) }) }) }). getAddress()function returns same error. could anyone tell what the error is?
Beta Was this translation helpful? Give feedback.
All reactions