Skip to content

CoverCompared/PolkaCover-MoonBeam-Chain

Repository files navigation

Install (linux)

Get the code

Get the tutorial specific tag of the PureStake/Moonbeam repo:

git clone -b tutorial-v2 https://github.com/PureStake/moonbeam
cd moonbeam

Setting up enviroment

Install Substrate pre-requisites (including Rust):

curl https://getsubstrate.io -sSf | bash -s -- --fast

Run the initialization script, which checks the correct rust nightly version and adds the WASM to that specific version:

./scripts/init.sh

Build Standalone

Build the corresponding binary file:

cd node/standalone
cargo build --release

Build Parachain

Build the corresponding binary file:

cargo build --release

The first build takes a long time, as it compiles all the necessary libraries.

Troubleshooting

If a cargo not found error appears in the terminal, manually add Rust to your system path (or restart your system):

source $HOME/.cargo/env

Run

Standalone Node in dev mode

./node/standalone/target/release/moonbase-standalone --dev

Docker image

Standlone node

You can run a standalone Moonbeam node with Docker directly:

docker run --rm --name moonbeam_standalone --network host purestake/moonbase:tutorial-v2.2 /moonbase/moonbase-standalone --dev

Chain IDs

The ethereum specification described a numeric Chain Id. The Moonbeam mainnet Chain Id will be 1284 because it takes 1284 milliseconds for a moonbeam to reach Earth.

Moonbeam nodes support multiple public chains and testnets, with the following Chain Ids.

Network Description Chain ID
Local parachain testnet 1280
Local standalone testnet 1281
Reserved for other testnets 1282 - 1283
Moonbeam (Polkadot) 1284
Moonriver (Kusama) 1285
Moonrock (Rococo) 1286
Public parachain testnet (alphanet) 1287
Reserved for other public networks 1288 - 1289

Runtime Architecture

The Moonbeam Runtime is built using FRAME and consists of several core pallets, as well as a few pallets that are only present conditionally. The core pallets are:

  • Balances: Tracks GLMR token balances
  • Sudo: Allows a privledged acocunt to make arbitrary runtime changes - will be removed before launch
  • Timestamp: On-Chain notion of time
  • EVM: Encapsulates execution logic for an Ethereum Virtual Machine
  • Ethereum: Ethereum-style data encoding and access for the EVM.
  • Ethereum Chain Id: A place to store the chain id for each Moonbeam network
  • Transaction Payment: Transaction payment (fee) management
  • Randomness Collective Flip: A (mock) onchain randomness beacon. Will be replaced by parachain randomness by mainnet.

Parachain

In addition to the core pallets above, the parachain node also features

  • ParachainUpgrade: A helper to perform runtime upgrades on parachains
  • MessageBroker: A helper to receive incoming XCPM messages
  • ParachainInfo: A place to store parachain-relevant constants like parachain id
  • TokenDealer: A helper for accepting incoming cross-chain asset transfers

Standalone

In addition to the core pallets above, the standalone node also features

  • Aura: Slot-based Authority Consensus
  • Grandpa: GRANDPA Authority consensus (This will be removed once it becomes a parachain)

Tests

Tests are run with the following command:

cargo test --verbose