Development of ParaSpell — XCM & XCMP tool

Dudo50
Networks @ FIIT STU
5 min readOct 22, 2022

What ParaSpell proposes

ParaSpell is XCM & XCMP related tool built to save developers time when interacting with the network. It is no longer necessary to search for correct XCM pallets, fill lengthy XCM messages with all the required details or go through research on launching networks. Developers can use ParaSpell to conveniently start necessary nodes with a single command, execute XCM transactions from a user-friendly UI, or open & close HRMP channels between nodes in the launched network from a user-friendly UI.

ParaSpell focuses mainly on substrate developers. Added value comes from being a user-friendly SDK for simplifying development by saving the time necessary to install & launch the network, open HRMP channels or create XCM transfers between nodes available in the network.

Overall ParaSpell is all about developer experience.

What calls does ParaSpell use?

Paraspell uses mainly two types of calls aside from queries.

  1. Calls to open/close HRMP channels
  2. Calls to create XCM transfer

We will look into the structure of one example from each.

The following call opens the HRMP channel between selected nodes. It requires Parachain IDs of both nodes, max size, and max message size. There are two calls required in each HRMP channel opening. The reason is, that in order to have bidirectional communication there need to be two channels open between selected nodes. One from each side. While opening these channels there must not be two same pallet calls submitted in one block because channels won’t open properly. This means that timing plays an important role here also. That is why there is also a 10-second timeout between these two calls.

It is hard to choose a concrete XCM call scenario because they are also mostly specific to nodes. We focused on selecting nodes that have as least different XCM pallets and calls as possible. However, with the ability to add new different nodes to the network, this might be a matter of deeper research.

This call requires multiple details to be filled in. Starting with the destination, the parent is set to 0 because Parachains are layer down from the Relay chain at layer 1. In the opposite scenario (Transfering from Parachain to Relay chain), the parent is set to 1 because the transfer is going to the upper layer. Then there needs to be the first junction filled. In this case, it is X1 and Parachain containing Parachain ID. After that another junction needs to be filled, that junction contains an account where XCM transfer is headed to. Notice, that there also needs to be a parent and set to 0 because the account is on Parachain. The next step is to fill the currency that the transfer will carry. In this case, the parent is also set to 0 because currency travels into the lower Parachain layer. Notice, that the interior is set as “Here” meaning, that currency comes from the Relay chain. Once the currency is selected concrete amount is required. The last step is to include fees for processing transactions. In this case, it is zero because we are transferring from the Relay chain which requires no fees attached.

More on XCM Calls used in ParaSpell can be found in ParaSpell Wiki

What issues and obstacles did we encounter during development?

The first obstacle was the need to research XCM calls on each node. This is due to different pallet names, different call names, or different data required by calls.

The second obstacle was deprecating the NPM library for network startup. We used the “Polkadot-launch” library that became deprecated previously. After some research, we found a maintained library for a network startup called “Parachain-launch”. This library operated a little differently than the old one. This meant, that we had to reconstruct the configuration file, makefile and many more. In fact, we created new article about migrating from Polkadot-launch to Parachain-launch to help other developers.

The third obstacle and last one was replacing nodes, that are not yet fully compatible with XCM transferring and a new network startup library for the ones that are. This meant, that previously used nodes of Basilisk and Moonbeam had to be replaced with Bifrost and Pichiu nodes. The process was rather extensive than hard.

Launching network and application

Provided, that all prerequisites, dependencies and necessary files are installed and compiled (all commands are available in the ParaSpell repository). Launching a network and application can be done with one simple command.

  • Launching a network can be done by the following command “make launch”

Once the network is started we should see docker output with no errors & all containers launched indicated by “done” green text near each container. Nodes can be then accessed on specified WS ports (they can be found in the network configuration file). They should all start producing blocks within minutes.

  • Launching the application can be done by the following command “npm run serve”

The application should be started within seconds and is available to be used right away given, that network is launched and operating already.

How to use ParaSpell

Once the network & application is launched, working with the application is easy and intuitive. Navigation to each important screen is in the navbar. Each call, that the application uses has callback support so status notifications will inform users about important information regarding their transaction. Transactions can also be made with prebuilt Accounts or developers can inject their own wallet using the PolkadotJS extension.

Example of transfer screen for Relay chain to Parachain transfer scenario:

The screen requires only a few details to fill compared to filling the entire XCM call from Polkadot UI. A similar XCM call created in a different scenario, with the same amount of details required on the ParaSpell UI side as displayed above results in a lengthy call displayed below.

If the developer was to create this call manually from Polkadot UI it would take them a marginally longer time compared to the user-friendly UI that Paraspell offers.

Future work

The technology ParaSpell uses is not going to stay state-of-the-art forever, so once new protocols, like expected XCMP, will be released, implemented HRMP will be deprecated.

Another area of focus will be optimizing network startup, adding new nodes, and giving users the ability to add a new node from the user interface.

Special thanks to Web3 Foundation Team & Viki Val

--

--

Dudo50
Networks @ FIIT STU

University student, blockchain developer, creator of ParaSpell