Setting Up a Moonbeam Node and Connecting to the Polkadot JS GUI¶
This guide outlines steps to create a standalone local node for testing the Ethereum compatibility functionality of Moonbeam.
This tutorial was created using the v3 release of Moonbase Alpha. The Moonbeam platform, and the Frontier components it relies on for Substrate-based Ethereum compatibility, are still under very active development. The examples in this guide assume an Ubuntu 18.04-based environment and will need to be adapted accordingly for MacOS or Windows.
If you follow to the end of this guide, you will have a Moonbeam node running in your local enviroment, and will be able to connect it to the default Polkadot JS GUI.
Installation and Setup¶
We start by cloning a specific tag of the Moonbeam repo that you can find here:
git clone -b tutorial-v3 https://github.com/PureStake/moonbeam cd moonbeam
Next, install Substrate and all its prerequisites (including rust), by executing:
curl https://getsubstrate.io -sSf | bash -s -- --fast
Now, lets make some checks (correct version of rust nigthly) with the initialization script:
Once you have followed all of the procedures above, it's time to build the standalone node by running:
cd ./node/standalone cargo build --release
If a cargo not found error shows up in the terminal, manually add Rust to your system path (or restart your system):
The initial build will take a while. Depending on your hardware, you should plan on 30 minutes for the build process to finish.
Here is what the tail end of the build output should look like:
Then you will want to run the node in dev mode using the following command:
For people not familiar with Substrate, the
--dev flag is a way you can run a Substrate-based node in a single node developer configuration for testing purposes. You can learn more about
--dev in this Substrate tutorial.
You should see an output that looks like the following, showing that blocks are being produced:
The local standalone Moonbeam node provides two RPC endpoints:
Getting Started with Docker¶
An alternative to the steps higlighted before is to use docker to run a pre-build binary. Doing so, you prevent having to install Substrate and all the dependencies, and you can skip the building the node process as well. The only requirement is to have Docker installed, and then you can execute the following command to download the corresponding image:
docker pull purestake/moonbase:tutorial-v3
The tail end of the console log should look like this:
Once the Docker image is downloaded, you can run it with the following line:
docker run --rm --name moonbeam_standalone --network host purestake/moonbase:tutorial-v3 /moonbase/moonbase-standalone --dev
If successful you should see an ouput similar to before, showing that blocks are being produced:
Connecting Polkadot JS Apps to a Local Moonbeam Node¶
The locally-running Moonbeam node is a Substrate-based node, so we can interact with it using standard Substrate tools. Let’s start by connecting to it with Polkadot JS Apps.
Open a browser to: https://polkadot.js.org/apps/#/explorer. This will open Polkadot JS Apps which automatically connects to Polkadot MainNet.
Click on the top left corner to open the menu to configure the networks, and then navigate down to open the Development sub-menu. In there, you will want to toggle the "Local Node" option which points Polkadot JS Apps to
ws://127.0.0.1:9944. Next, hit on the Switch button and the site should connect to your standalone Moonbeam node.
With Polkadot JS Apps connected, you will see the standalone Moonbeam node producing blocks.
Querying Account State¶
With the release of Moonbase Alpha v3, Moonbeam now works under a single account format, which is the Ethereum-styled H160 and is now also supported in Polkadot JS Apps. To check the balance of an address, you can simply import your account to the Accounts tab. You can find more information in this site.