Magnet has evolved! Our project now contains two parts, Magnet Network and Magnet Stack.
🔎 For more about Magnet Network, head to our website New version coming soon!
📢 Follow our latest updates on Twitter
🤝 Engage with fellow developers on our Telegram server
Magnet Stack is an advanced platform designed to streamline Polkadot Coretime-ready chain deployment and project initiation, significantly simplifying the development process. Magnet Stack allows users to customize their blockchain network through an easy-to-use web UI, and automatically generate node codes.
Magnet Stack supports two types of Coretime functionalities, on-demand and Bulk, optimizing resource management and providing flexibility in blockchain architecture. On-demand coretime mode also supports on-demand block production and assurance mechanisms to further increase resource efficiency and stability.
Magnet Stack leverages Substrate's robust framework to support multiple virtual machines, including EVM, WASM and MoveVM, enabling developers to run and interact with various smart contract environments.
The platform provides customizable templates for various functionalities, allowing users to tailor their blockchain network to meet specific needs. This layer includes pre-built modules that can be easily integrated into your project, saving development time and effort.
The Appchain Model offers flexibility with support for multiple models, including parathread and Tanssi-container chains. This allows developers to choose the best architecture for their specific use case.
The Dynamic Generator facilitates the one-click generation of Substrate code for customized features, simplifying the node deployment process. This feature enables developers to quickly create and deploy nodes with the required specifications.
Magnet Stack enhances the user experience with a user-friendly interface and a comprehensive suite of SDKs, making blockchain development more accessible and efficient for developers of all skill levels.
Getting started with the Magnet Stack APP website, coming soon!
MAGNET serves as Polkadot's Smart Contract Docking Station, operating on the PAYG Model. It is in the process of developing a scalable smart contract platform, utilizing DOT as the gas fee within this model.
The main roles involved in the business logic are as follows:
Tanssi: As Magnet will become a ContainerChain in the Tanssi Network, Collators will be elected and supported by the Tanssi Network, and Magnet will no longer set up a Collators election mechanism.
Magnet: As a smart contract platform, it provides EVM/WASM smart contract services and charges GAS fees as platform fees.
Polkadot: Provides high-quality BlockSpace for Magnet and offers blockchain security services.
When providing smart contract platform services to users, Magnet calculates the total GAS fees from the current transaction pool and obtains the expected Blockspace/coretime price from RelayChain. By strategically leveraging the price difference, Magnet achieves continuous profits, thereby serving users more efficiently. Once the GAS fees exceed the expected price, Magnet will delegate Collators to package the transactions and submit a Blockspace Order to the Relaychain, strategically collecting gas fees to pay for coretime. Upon successful ordering, the produced blocks will be anchored to the Relaychain for block confirmation.
This pallet is crucial for managing and monitoring various aspects of blockspace and transaction processing.
This pallet is responsible for managing profits and costs associated with CoreTime.
This pallet ensures the stability and reliability of block intervals and credit account balances.
Each of these pallets plays a pivotal role in maintaining the efficiency, security, and financial integrity of the system, working in tandem to ensure the seamless functioning of the blockchain network.
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.
Substrate is developed using Rust; hence, Rust is a prerequisite for Substrate. Install Rust using rustup by running the following command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After completing the installation, restart your terminal and run:
source $HOME/.cargo/env
Or, add the following line to your shell profile file (e.g., ~/.bashrc
or ~/.zshrc
):
export PATH=$HOME/.cargo/bin:$PATH
Keep your Rust installation up to date by running:
rustup update
Substrate has several library dependencies. Install them using the appropriate commands for your operating system:
sudo apt update
sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev
brew install cmake pkg-config openssl git llvm
With Rust and the necessary libraries installed, proceed to install Substrate:
curl https://getsubstrate.io -sSf | bash -s -- --fast
Check your Substrate installation by running:
substrate --version
This command should output the installed Substrate version.
Configure the Rust toolchain for Substrate by running:
rustup default nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
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.
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.
Using the custom-spec-raw.json
file provided by substrate.
Clone the most recent release branch of the Polkadot repository to prepare a stable working environment.
git clone --branch release-v1.1.0 https://github.com/paritytech/polkadot-sdk.git
Change to the root of the polkadot directory by running the following command:
cd polkadot
Build the relay chain node by running the following command:
cargo build --release
Compiling the node can take 15 to 60 minuets to complete.
Verify the node built correctly by running the following command:
./target/release/polkadot --help
If command-line help is displayed, the node is ready to configure.
nohup ./target/release/polkadot --alice --validator --chain custom-spec-raw.json --port 30333 --rpc-port 9944 --rpc-cors all --unsafe-rpc-external >alice.log 2>&1 &
nohup ./target/release/polkadot --bob --validator --chain custom-spec-raw.json --port 30334 --rpc-port 9945 --rpc-cors all --unsafe-rpc-external >bob.log 2>&1 &
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:
# Clone the repository
git clone https://github.com/Magport/Magnet.git
# Navigate to the project directory
cd Magnet
# Build the project using Cargo
cargo build --release
Compiling the node may take about 30 minutes to complete, depending on your system's performance.
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:
chmod +x magnet_executable # Replace with the actual name of the downloaded file
./magnet_executable # Replace with the actual name of the downloaded file
paraid
in the browsernetwork
, select parachains
.
parathreads
, click on paraid
.
paraid
for this session is 2000.
./target/release/parachain-magnet-node build-spec --disable-default-bootnode >magnet-2000.json
Modify the magnet-2000.json
file, change para_id
to 2000 and parachainid
to 2000.
./target/release/parachain-magnet-node build-spec --disable-default-bootnode --chain magnet-2000.json --raw>raw-magnet-2000.json
./target/release/parachain-magnet-node export-genesis-wasm --chain raw-magnet-2000.json magnet-2000-wasm
./target/release/parachain-magnet-node export-genesis-state --chain raw-magnet-2000.json magnet-2000-state
nohup ./target/release/parachain-magnet-node --alice --collator --force-authoring --chain raw-magnet-2000.json --base-path ./alice --port 40333 --rpc-port 8844 --rpc-cors all --unsafe-rpc-external -- --execution wasm --chain ../polkadot-sdk/rococo/raw-rococo-local.json --port 30343 --rpc-port 9977 > magnet-2000.log 2>&1 &
Developer
, select Sudo
.
paraSudoWrapper
, on the right, select sudoScheduleParaInitialize(id,genesis)
.
id
, enter 2000.
For genesisHead
, choose file upload and upload the genesis file para-2000-genesis-state
generated in the steps above.
For ValidationCode
, choose file upload and upload the file para-2000-wasm
generated above.
For paraKind
, select yes.
Click submit
, followed by sign and submit
. Then, check the explorer to verify that the parachain is syncing with the relay chain.
Using polkadot.js, connect to port 8844, initiate a transfer, and verify that blocks are generated as expected.
Licensed under the Apache License, Version 2.0.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this repository by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.