0

I'm using Wagmi.sh. When I use useSwitchNetwork to switch Metamask to my local Hardhat node, the dialog pops up asking for confirmation, when I confirm it nothing happens - no error code (in the try..catch block or in the dialog) and Metamask doesn't switch to Hardhat. I can switch to Hardhat manually, just not via useSwitchNetwork. It works when switching to mainnets, e.g. Polygon, but not my local Hardhat. I changed my Hardhat chain ID to 1337 (and have this chain ID specified in Metamask), but don't see how that can be the problem.

Does anyone have any suggestions?

1 Answer 1

0

Hardhat is 31337 maybe wrong chain id.

https://wagmi.sh/core/chains -> make sure you import hardhat as a chain and add to the configure chains

I believe I did this successfully with Rainbow wallet provider and passing localhost as a chain parameter/provider then using wagmi hooks afterwards to interact. Hardhat local node can be tricky. Make sure you set up the hardhat node properly in metamask. If you cant get it to work focus on testnets should work easier.

2
  • http:// instead of https in MM network as well Dec 20, 2022 at 17:16
  • Hardhat should be 1337, see hardhat.org/hardhat-network/docs/metamask-issue
    – Rick
    Dec 26, 2022 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.