Cannot add chains with empty blockExplorers
to MetaMask
#3652
Labels
Good First Issue
Misc: Good First Issue
blockExplorers
to MetaMask
#3652
Describe the bug
When attempting to add the Foundry chain to MetaMask, I encounter the following error:
I discovered that adding the
blockExplorers
parameter resolves the issue.Wagmi configures
wallet_addEthereumChain
'sblockExplorerUrls
based on the chain'sblockExplorers
. The current Wagmi implementation leads to an empty array forblockExplorerUrls
when chains lackblockExplorers
.wagmi/packages/core/src/connectors/injected.ts
Lines 373 to 393 in 4ba761d
According to MetaMask documentation, they require "One or more URLs", indicating that the empty array triggers the error.
I propose excluding
blockExplorerUrls
for chains that do not haveblockExplorers
.Link to Minimal Reproducible Example
No response
Steps To Reproduce
Create a project:
Apply this diff:
Run the project, connect MetaMask, and switch to the Foundry chain; then, the following error occurs:
By modifying as follows:
The error is resolved, and everything works as expected:
Wagmi Version
2.6.5
Viem Version
2.7.16
TypeScript Version
5.3.3
Check existing issues
Anything else?
No response
The text was updated successfully, but these errors were encountered: