web3modal-vanilla-js-example icon indicating copy to clipboard operation
web3modal-vanilla-js-example copied to clipboard

getChain() fails with Metamask/Ganache

Open topac opened this issue 4 years ago • 2 comments

I'm using the official live demo here https://web3modal.github.io/web3modal-vanilla-js-example/ Metamask connected. If the chain is changed to http://127.0.0.1:8545 (Ganache), I got the following error:

Uncaught (in promise) Error: No chain found matching chainId: 1337
    at Object.i [as getChain] (index.min.js:1)
    at fetchAccountData (example.js:88)
    at async refreshAccountData (example.js:152)
    at async HTMLButtonElement.onConnect (example.js:185)

Everything is file when using Mainnet or Ropsten.

topac avatar Dec 04 '20 10:12 topac

This example uses an NPM package called evm-chains which provides data about public chains that are EVM-compatible (like Ethereum)

Since Ganache is not a public chain it will fail to find data for it matching the chainId 1337 so I'm not sure this is necessarily a bug or out-of-scope of this example

Perhaps we could make an assumption that any unknown chains would be testnet but that's still too ambiguous IMO

What do you think @miohtama?

pedrouid avatar Dec 04 '20 14:12 pedrouid

I will fix the example to show the chain as "unknown" when the database lacks an entry.

miohtama avatar Dec 04 '20 17:12 miohtama