full-blockchain-solidity-course-js icon indicating copy to clipboard operation
full-blockchain-solidity-course-js copied to clipboard

Invalid Signer Error

Open mfeeney opened this issue 2 years ago • 3 comments

Lesson

Lesson 13

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/gyMwXuJrbJQ?t=71005

Operating System

Windows

Describe the bug

When running the aaveBorrow.js script, which calls the getWeth function in lesson 13, the ethers.getContractAt function attempts to use the deployer address. However, the ethers.getContractAt function expects a Signer for its third argument, not a string. This results in the following error:

Error: invalid signer (argument="signer", value="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", code=INVALID_ARGUMENT, version=contracts/5.6.2)

This can be resolved by using the ethers.getSigner function as follows:

const { deployer } = await getNamedAccounts()
const signer = await ethers.getSigner(deployer)
const iWeth = await ethers.getContractAt(
    "IWeth",
    networkConfig[network.config.chainId].wethToken,
    signer
)

This was observed using ethers version 5.6.9.

mfeeney avatar Jul 21 '22 16:07 mfeeney

thank you so much @mfeeney

rohan-ahire06 avatar Jul 23 '22 17:07 rohan-ahire06

Hey there, thanks for the heads up!

BTW, this is more relevant for discussions, as people primarily use it for logical errors; also the fact that it is not necessarily a code bug.

For enhancements, PRs are appreciated!

Please close the issue, and rather open a discussion with the category "Ideas".

krakxn avatar Sep 15 '22 04:09 krakxn

TY !

sligokid avatar Feb 02 '23 19:02 sligokid