MetaMask - cogeorg/teaching GitHub Wiki
MetaMask is a browser extension for Chrome or Firefox that adds an Ethereum connection through a remote Ethereum node called Infura. Infura lets you connect to the main and the test networks. You can also connect MetaMask to your private node or to a running node emulator. MetaMask is still in an early stage of development and can be quite buggy at times.
To install MetaMask, go to their webpage https://metamask.io/ and click on "GET FIREFOX ADDON" or "GET CHROME ADDON", which ever browser you prefer. After you have clicked on through the install dialog, the MetaMask fox icon will appear in the upper right corner of your browser. The introduction video on that website is also highly recommended.
MetaMask uses the vault concept to contain the keys that correpond to your accounts. It stores them client side in your browser and handles the signature of your transactions before sending them to the node your are connected to. The vault is protected with a global password that is not stored anywhere online. You should, of course, keep it very safe but MetaMask also asks you to save a seed phrase that you may use to restore your password later.
There are two possibilities to initialize a vault. You can eiher create a vault and MetaMask will generate a random seed phrase or you can restore a vault from an existing seed phrase. This means you can move with your vault.
One unfortunate behavior of MetaMask that you have to keep in mind is that it does not create separate vaults for different nodes but keeps all accounts, whether they belong to the main net or an emulator, in the same vault. Therefore, carefully rename all your accounts in your vault to make sure you know where they belong to. When you initialize your vault, MetaMask creates an account on the main Ethereum network by default and calls it Account 1.
Connecting Ganache and MetaMask
We are going to work with the node emulator Ganache for development. To connect to Ganache's network, open Metamask, log in, and click on the network tab, click on Custom RPC:
Fill in the Ganache properties and click on Save:
You should now see Ganache listed as one of the networks and you are automatically connected to that network. You can click on the X to leave this view:
Next, we need to import the Ganache accounts. For that, switch to Ganache and click on the key symbol of the first account:
Copy the displayed key:
Switch back to MetaMask and click on the coloful circle. Then click on Import Account:
Paste the key you just copied and click Import:
MetaMask stores all keys in one vault and whenever you add an account, the names are generically generated. To keep them apart from all your other accounts, we are going to rename it. Click on the burger icon on the left:
Click on Details:
Click on the little edit pencil:
And rename the account:
Repeat these steps until you have the first 3 Ganache accounts imported:
This is it, MetaMask is connected to Ganache.