Metamask-extension: MetaMask doesn't work anymore with Hardhat Network (FKA: Buidler EVM)

Created on 8 Nov 2020  路  8Comments  路  Source: MetaMask/metamask-extension

Describe the bug

MM uses 2710 as chain id, instead of 31337 when connecting to Hardhat Network on localhost 8545. This makes transactions fail because Hardhat Network implements EIP155.

Steps to reproduce (REQUIRED)

Follow the steps here and try to make a tx from the frontend: https://github.com/nomiclabs/hardhat-hackathon-boilerplate

Expected behavior

The transaction you made in the frontend should succeed.

Screenshots

image
image

Browser details (please complete the following information):

  • OS: OS X
  • Hardware Wallet: None
  • Browser: Version 86.0.4240.183 (Official Build) (x86_64)
  • MetaMask Version: 8.1.3

(note that this was reported from multiple users with different configurations)

Additional context (Error Messages, etc.)

It may be a duplicate of https://github.com/MetaMask/metamask-extension/issues/9683, but note that Hardhat Network supports both net_version and eth_chainId. I don't see any eth_chainId being made though.

Most helpful comment

@fvictorio, thank you for confirming that!

We deliberately don't use the eth_chainId return value, for security reasons. I recommend running Hardhat on a different port, and adding it as a new custom network with the correct chain ID.

Since this is working as intended, I will now close this issue.

Having to add a new development network manually would be a regression in developer experience. I think it's worth figuring out a way to make this work to avoid introducing new additional friction

All 8 comments

I currently have this issues if you need help reproducing this.

@rekmarks would you mind confirming this one?

@alcuadrado @jamespfarrell can you go to Settings > Network > Localhost 8545 and update the chain ID manually?

Note that if you enter a decimal value it'll be displayed as hex, but the value will be saved correctly.

@rekmarks Yes, setting 31337 as the chain id and then resetting the account makes the transaction work.

This might also be of help: if I uninstall and re-install MetaMask, the default value for the chain id is 1337 (ganache's chain id).

Both Ganache and Hardhat support eth_chainId, so maybe MetaMask could use that method to get the correct chain id?

Also note that if you run ganache changing its chain and network ids it doesn't fail, as ganache doesn't implement EIP155.

You can try it with npx ganache-cli -i 1234 --chainId 1234.

@fvictorio, thank you for confirming that!

We deliberately don't use the eth_chainId return value, for security reasons. I recommend running Hardhat on a different port, and adding it as a new custom network with the correct chain ID.

Since this is working as intended, I will now close this issue.

Can you elaborate on those security concerns, @rekmarks ?

@fvictorio, thank you for confirming that!

We deliberately don't use the eth_chainId return value, for security reasons. I recommend running Hardhat on a different port, and adding it as a new custom network with the correct chain ID.

Since this is working as intended, I will now close this issue.

Having to add a new development network manually would be a regression in developer experience. I think it's worth figuring out a way to make this work to avoid introducing new additional friction

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnerfx picture johnerfx  路  4Comments

kumavis picture kumavis  路  3Comments

dpazdan picture dpazdan  路  3Comments

BassBauman picture BassBauman  路  3Comments

MarkOSullivan94 picture MarkOSullivan94  路  3Comments