Skip to content

Get ethers.ContractInterface when calling contract.interface which is marked as ethers.utils.Interface #2702

Answered by ricmoo
EazyReal asked this question in Q&A
Discussion options

You must be logged in to vote

The ContractInterface is a type, so cannot be instantiated, in general; it just defines a "shape" as TypeScript calls it.

As for the example you give, that may depend on your environment and set up. For example, if you are using a bundler or npm link it will affect the reliability of instanceof.

This is why ethers doesn't use instanceof internally, because it is quite unreliable in a large variety of situations.

> contract.interface instanceof utils.Interface
true

Hope that helps.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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

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

This discussion was converted from issue #2688 on February 15, 2022 16:58.