Skip to content

lesson 9: ethers.getContract is not a function #2770

Answered by byte14
yingang2 asked this question in Q&A
Discussion options

You must be logged in to vote

@yingang2, it seems your issue is solved by another answer which is great, but it doesn't mentioned the cause of the error and proper way to solve the issue. so I write this answer.

  • You are getting this error because ethers.getContract() does not exists in the @nomiclabs/hardhat-ethers plugin, for using ethers.getContract() you will need hardhat-deploy-ethers plugin which is a fork of @nomiclabs/hardhat-ethers with additional functionalities. Reference for hardhat-deploy-ethers plugin

  • Since one of your other plugin might have hard-coded dependency on @nomiclabs/hardhat-ethers, it will still use @nomiclabs/hardhat-ethers even if you installed hardhat-deploy-ethers. So you need to install

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@yingang2
Comment options

Comment options

You must be logged in to vote
5 replies
@RoboCrypter
Comment options

@byte14
Comment options

@yingang2
Comment options

@RoboCrypter
Comment options

@SanmeetShah
Comment options

Answer selected by yingang2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants