Hardhat FundMe Testing State Not working .connect not working #85
-
So, I ran into this weird problem where when working with await fundMe.connect it("allows us to withdraw with multiple funders", async function() {
const accounts = await ethers.getSigners(); //get accounts in array
//loop throught accounts
for(let i = 1; i< 6; i++) {
//create new objects to this account
const fundMeConnectedContract = await fundMe.connect(accounts[i]);
await fundMeConnectedContract.fund({value: sendValue});
console.log(`${fundMeConnectedContract.address}: is a different account `)
}
What consoles logs is
Hahha not a different account So, that's my current predicament. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The Your code console.log(`${fundMeConnectedContract.address}: is a different account `) is just printing the address of the same contract, and that is why the outputs are all the same address. If you are willing to get the address of different accounts you can try this console.log(`senders address :`, accounts[i].address); |
Beta Was this translation helpful? Give feedback.
The
.connect
method ties the same contract with different signers/accounts, i.e., all the requests to the contract will be made from the connected account.Your code
is just printing the address of the same contract, and that is why the outputs are all the same address.
If you…