Lesson 7: fundme.test.js Error: Require a signer #1960
Answered
by
othaime-en
tobezhanabi
asked this question in
Q&A
-
Hi, I ran into an error while trying to test it("only allows the owner to withdraw", async function() {
const accounts = ethers.getSigners()
const attacker = accounts[1]
const attackerConnectedContract = await fundMe.connect(attacker)
await expect(attackerConnectedContract.withdraw()).to.be.reverted
}) and I got this error Error: sending a transaction requires a signer (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=contracts/5.6.2) |
Beta Was this translation helpful? Give feedback.
Answered by
othaime-en
Aug 22, 2022
Replies: 1 comment 5 replies
-
You forgot to add an await in this line |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
tobezhanabi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You forgot to add an await in this line
const accounts = ethers.getSigners()
As a result, you code execution proceeded without first waiting to get the list of accounts.It should be
const accounts = await ethers.getSigners()