Metamask is a crypto wallet and gateway to blockchain apps. It is the most famous and widely used wallet to interact with web3. To be able to operate properly, it needs to connect to a node from the blockchain where you want to read/submit transactions.
For example, to operate in Ethereum you need the RPC url of an Ethereum node. Metamask by default provides you an Ethereum node called mainnet.
It also provides you other RPC endpoints for the Ethereum testnets, such as Kovan, Rinkeby and Ropsten.
This feature is great and enough to interact with Ethereum, but it carries some disadvantages compared to connecting Metamask to your own Ethereum node:
- Security risks: using Metamask’s default nodes is to blindly trust in Metamask and the information they provide.
- Downtime: Metamask’s provided nodes are susceptible of experiencing downtimes, not allowing you to operate in Ethereum until it get resolved. It has happened in the past.
- Privacy: Metamask or their node provider may be recording users’ data to analyze it and sell it. Do not be part of it by running your own node.
- Decentralization: having your own node means a direct contribution to decentralization, making the blockchain more resilient and secure.
- DAppNode installed
- Have Metamask setup in the browser and a wallet configured
There are two ways of connecting Metamask to your node in DAppNode.
- Via local network endpoint (accessible from anywhere through VPN or WiFi)
- Making the endpoint available through HTTPS (accessible from anywhere without any extra steps)
Get your RPC: in the DAppNode UI go to any blockchain node and get your RPC, in this example it is used Geth.
The Geth RPC is http://geth.dappnode:8545
Create a custom RPC: once you have the RPC to be used, in the Metamask extension click on Networks > Custom RPC
Finally you will have to populate 3 fields:
- Name: the name of the network. Can be any name.
- New RPC url: the RPC url obtained before (http://geth.dappnode:8545)
- ChainId: it is a number that represents the blockchain, for mainnet is 1. You can get the chain ID of any blockchain you need from this website.
You can combine the HTTPS feature in DAppNode with Metamask, by exposing the RPC endpoint you choose via HTTPS, allowing you to use the RPC without being connected to your DAppNode via Wi-Fi or VPN.
To expose the RPC go to System > Network and expose the RPC of your choice.
If the RPC you are looking for is not listed then you will have to do it manually in the Package name > Network > HTTPS domain mapping view.
Right after exposing the RPC in the HTTPs view you will get an URL, this is the RPC to be used in the new Metamask network created, as was explained in the previous section.