Setup a Local Node
Installing Substrate Dependencies
Substrate is a modular framework that enables you to create purpose-built blockchains by composing custom or pre-built components. Below is a markdown document that you can use as a template for creating a guide on installing Substrate dependencies.
1. Install Rust
Substrate is developed using Rust; hence, Rust is a prerequisite for Substrate. Install Rust using rustup by running the following command in your terminal:
After completing the installation, restart your terminal and run:
Or, add the following line to your shell profile file (e.g., ~/.bashrc
or ~/.zshrc
):
Update Rust
Keep your Rust installation up to date by running:
2. Install Additional Libraries
Substrate has several library dependencies. Install them using the appropriate commands for your operating system:
For Ubuntu
For macOS
3. Install Substrate
With Rust and the necessary libraries installed, proceed to install Substrate:
4. Verify Installation
Check your Substrate installation by running:
This command should output the installed Substrate version.
5. Configure Rust Toolchain
Configure the Rust toolchain for Substrate by running:
Completion
At this point, you should have a working Substrate development environment. Regularly check for updates and keep your installations current by running rustup update
and cargo update
.
Remember to replace the placeholder text with the actual content, and feel free to modify the structure and formatting to suit your preferences and requirements.
Start the Magnet Node
To start Magnet, you will need a proper Substrate development environment.
If you need a refresher setting up your Substrate environment, see Substrate's Getting Started Guide.
I. Launching the Local Relay Chain
Using the custom-spec-raw.json
file provided by substrate.
1.Build the relay chain node
Clone the most recent release branch of the Polkadot repository to prepare a stable working environment.
Change to the root of the polkadot directory by running the following command:
Build the relay chain node by running the following command:
Compiling the node can take 15 to 60 minuets to complete.
Verify the node built correctly by running the following command:
If command-line help is displayed, the node is ready to configure.
2. Create the First Node
3. Create the Second Node
II. Connecting to the Local Parachain
1. Build the Magnet Node from Source Code
This method involves cloning the Magnet project repository from GitHub and compiling the project using Cargo, the package manager and build tool for Rust. Follow these steps:
Compiling the node may take about 30 minutes to complete, depending on your system's performance.
2. Run the Pre-Compiled Executable from GitHub
If you prefer not to build from source, you can directly download the pre-compiled executable file of the Magnet node from GitHub. This is usually faster as it bypasses the compilation process. Follow these steps:
Visit the Magnet project's GitHub releases page: Magnet Releases .
Select the latest version and download the pre-compiled executable suitable for your operating system.
After downloading, you may need to grant execution permissions to the file, depending on your operating system. On Linux or macOS, you can use the following command:
Run the executable to start the Magnet node:
3. Create a new paraid
in the browser
c. Choose an account and submit.
d. The registered
paraid
for this session is 2000.
4. Modify the Default Chain Specification
a. Generate the default chain specification:
Modify the magnet-2000.json
file, change para_id
to 2000 and parachainid
to 2000.
b. Convert the spec file to a raw file:
5. Prepare the Parachain Collator
a. Export the wasm file:
b. Generate the genesis state of the parachain:
c. Start the collator node:
6. Register on the Local Relay Chain
7. Test Parachain Block Production
Using polkadot.js, connect to port 8844, initiate a transfer, and verify that blocks are generated as expected.
Last updated