Interacting with a Moonbeam Node Using MetaMask¶
This guide outlines steps for using a self-contained Moonbeam dev node to send tokens between EVM accounts with MetaMask. If you haven’t already set up your own local dev node, refer to this tutorial or follow the instructions in the GitHub repository.
This tutorial was created using the pre-alpha release of Moonbeam. The Moonbeam platform, and the Frontier components it relies on for Substrate-based Ethereum compatibility, are still under very active development. We have created this tutorial so you can test out Moonbeam’s Ethereum compatibility features. Even though we are still in development, we believe it’s important that interested community members and developers have the opportunity to start to try things with Moonbeam and provide feedback.
The examples in this guide assume an Ubuntu 18.04-based environment and will need to be adapted accordingly for MacOS or Windows.
You can interact with Moonbeam in two ways: using Substrate RPC endpoints, or by using Web3-compatible RPC endpoints. The latter endpoints are currently being served from the same RPC server as the Substrate RPCs. In this tutorial, we will use the Web3 RPC endpoints to interact with Moonbeam.
Install the MetaMask Extension¶
First, we start with a fresh and default MetaMask installation from the Chrome store. Follow the "Get Started" guide, where you need to create a wallet, set a password, and store your secret backup phrase (this gives direct access to your funds, so make sure to store these in a secure place). Once completed, we will import our dev account:
The details for the dev account for this example are:
On the import screen, select “Private Key” and paste in the key listed above:
You should end up with an imported “Account 2” that looks like this:
Connect to the Local Moonbeam Node¶
Now let’s connect MetaMask to our locally running Moonbeam node.
Navigate to Settings -> Networks -> Add Network and fill in the following details:
New RPC URL:
When you hit "save" and exit the network settings screen, MetaMask should be connected to the local Moonbeam dev node via its Web3 RPC, and you should see the Moonbeam dev account with a balance of 123456.123 ETH.
Initiating a Transfer¶
Let’s try sending some tokens with MetaMask.
For simplicity, we will transfer from this dev account to the default MetaMask account that came with my installation using the “Transfer between my accounts” option. Let’s transfer 100 tokens and leave all other settings at the default:
Once you submit, you will see the transaction in the “pending” state until it is confirmed like this:
Note that the Account 2 balance has been decreased by the sent amount + gas fees. Flipping over to Account 1, we see the 100 sent tokens have arrived:
If you end up resetting your dev node using the Substrate purge-chain command, you will need to reset your MetaMask dev account using Settings -> Advanced -> Reset Account. This will clear the transaction history from your accounts and reset the nonce. Make sure you don’t erase anything you want to keep!
We Want to Hear From You¶
This is obviously a simple example, but it provides context for how you can start working with Moonbeam and how you can try out its Ethereum compatibility features. We are interested in hearing about your experience following the steps in this guide or your experience trying other Ethereum-based tools with Moonbeam. Feel free to join us in the Moonbeam Riot room here. We would love to hear your feedback on Moonbeam and answer any questions that you have.