question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typechain fails when there is a `provider` method on contract

See original GitHub issue

image with the error message:

Property 'provider' in type 'MMInstantiator' is not assignable to the same property in base type 'Contract'.
  Type '(_index: BigNumberish, overrides?: CallOverrides | undefined) => Promise<string>' is not assignable to type 'Provider'.ts(2416)
Class 'Contract' defines instance member property 'provider', but extended class 'MMInstantiator' defines it as instance member function.ts(2425)

If I rename it, then all issues go away. Currently, I cannot lightly rename this method since there are deployed contracts already working with the current ABI.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
zemsecommented, Nov 6, 2020

I wonder what does Ethers itself do in this case?

ethers have two ways of calling a method, using the function and signature string:

contract.balanceOf('0xaddr')
contract['balanceOf[uint256]']('0xaddr')

AFAIK, when there are some conflicts with ethers reserved properties on the contract like provider in this case, ethers.js drops that function but the alternate method is available. There was an issue on ethers repo maybe a year back, I couldn’t find it to link here.

contract['provider(uint256)'](123)

@gbarros You can use this alternate syntax in your project. And until this problem is fixed, whenever you run typechain you’d just need to remove the function (which is highlighted as error). And the fix is probably about removing functions with reserved names.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing TypeChain — Typescript bindings for Ethereum ...
Usually to interact with a smart contract on the Ethereum blockchain you use Web3js: you pass an ABI and an address, you call...
Read more >
ContractFactory - ethers
The Contract Factory sends a special type of transaction, ... extracting the ABI and bytecode from it, allowing for the various formats the...
Read more >
Using TypeScript | Ethereum development environment for ...
To do it, open your terminal, go to your Hardhat project, and run: ... types for your smart contract you should install and...
Read more >
ethers-io/Lobby - Gitter
I've not tried if multiple address works now with ethers js. But in case it doesn't you can send raw rpc methods with...
Read more >
Migration guides — waffle documentation - Read the Docs
ethereum-provider - mock provider to interact with an in-memory blockchain ... is called waffle.json , it's possible to use just waffle to build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found