full-blockchain-solidity-course-js
full-blockchain-solidity-course-js copied to clipboard
Invalid Signer Error
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.
thank you so much @mfeeney
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".
TY !