MetaMask Local Network

Have been checking out Ethereum during the break, mostly going through the docs as well as various guides that I’ve come across. The impetus was this article which gives a great intro to the emerging Web3 movement.

Along with setting up and interacting with a local geth node, it’s helpful to interact with accounts (as opposed to “wallets”) using the MetaMask wallet. MetaMask supports importing accounts using private keys or JSON in the Web3 Keystore format.

One thing that wasn’t obvious (and also the motivation for this post), was how to setup MetaMask and a geth node running locally for communication. By default, CORS is disabled and requires a runtime configuration flag to be passed:

geth --goerli --syncmode "light" --signer=/path/to/signer/clef.ipc --http \
  --http.corsdomain "moz-extension://67b02c56-bb74-4303-bfed-1aa4014483f1"

Make sure to set MetaMask ChainID to 5 when using the --goerli flag and/or explicitly set chain ID using the --networkid flag (and of course the correct chrome or moz extension UUID).