4meta5 / moonbeam

An Ethereum-compatible smart contract parachain on Polkadot

Home Page:https://moonbeam.network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

moonbeam

Tests

Run an Ethereum compatible parachain (and blockchain for now, until parachains are more stable) based on Substrate.

See moonbeam.network for the moonbeam blockchain description.
See www.substrate.io for substrate information.

Install (linux)

Get the code

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

git clone -b tutorial-v3 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

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

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

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
Moonbase Alpha TestNet 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

This github repository is also linked to Gitlab CI

Contribute

Code style

Moonbeam is following the Substrate code style
We provide a .editorconfig (compatible with VSCode using RLS)

About

An Ethereum-compatible smart contract parachain on Polkadot

https://moonbeam.network

License:GNU General Public License v3.0


Languages

Language:Rust 59.3%Language:TypeScript 31.9%Language:Shell 5.8%Language:Dockerfile 1.9%Language:Ruby 0.9%Language:HTML 0.2%