-
Notifications
You must be signed in to change notification settings - Fork 680
Argument of type 'EthereumProvider' is not assignable to parameter of type 'ExternalProvider | JsonRpcFetchFunc'. #3455
Comments
Are you able to find and post the type for |
From ethers lib . |
My hunch is that this is due to Ganache's provider types are very strict, which let's us offer type hints like:
and:
The problem is that Ethers' expected provider function signature's This isn't really an Ether's problem though, nor is it a bug in Ganache. But it does make for a bad UX! Additionally, Ether's omits the Possible fixes: Ethers could relax its ExternalProvider type so that
Ganache could relax its types on
Ethers could use Generics:
Something similar to the above would allow for the best of both worlds. It even opens up the possibility for Ethers to flow the strict type checking offered by Ganache (and maybe others?) in its own methods, like That said, there may be some other issues with the types, but the problems are only with the types, not with the run-time Let's keep this open so the team here can discuss options and other potential solutions I haven't thought of. Re: docs for programmatic use... you are right; we are lacking in that department... docs are in the works! (cc @MicaiahReid) |
Hey, all I'm trying to create the provider as stated above, however, it seems the network is never set. I'm trying to do the following essentially: const options = {
chain: {
networkId: 5777,
chainId: 5777,
}
};
const server = Ganache.server(options);
const provider = new ethers.providers.Web3Provider(this.server.provider as unknown as ethers.providers.ExternalProvider);
await this.server.listen(8888, 'localhost'); However, |
What do you expect the network name to be? |
Something just like
because there is no network set. |
Update: My network error was resolved by specifying |
@gluax Ether's has no way of knowing that the network you created only milliseconds ago should have a name ("ganache" isn't a unique network, and all Ethereum networks use "evm"). That said, I wonder if chainId and networkId of @gluax Did you try |
@davidmurdoch ah that makes more sense. I'm out for lunch at the moment but will try the actual address for localhost when I get back and open an issue if that is the problem. |
Correct 127.0.0.1 works however specifying localhost does not. See issue #3491. |
Hey all.
I would love for there to be more typescript examples and more programmatic examples.
I'm trying to programmatically spin up a local blockchain with a contract for fuzz testing. I.e. I need the ability to randomly create addresses with funds and etc on demand. I do see a lot of the functions I need available, however, it's quite a struggle to figure out how to get access to what I need to call. So some more examples would really be appreciated for the programmatic side.
However, I'm blocked right at the start trying to create an ethers
Web3Provider
with the error,Argument of type 'EthereumProvider' is not assignable to parameter of type 'ExternalProvider | JsonRpcFetchFunc'.
The code is as follows:
Would appreciate any help here. Thanks.
The text was updated successfully, but these errors were encountered: