Lesson 4, Robonomics Parachain in Practice

At the moment, Robonomics, in addition to the Ethereum network, also operates on the basis of the Polkadot ecosystem, which has greater scalability through the use of sharded blockchains. To do this, the ecosystem uses a sharded model, with the following elements:

Polkadot base scheme

  • relay chain — central blockchain used by others for basic coordination of work;
  • parachains — data structures (usually also blockchains) used for specific applications; Robonomics operates as a parachain;
  • validators — nodes that create blocks in the relay chain and also verify new block candidates from parachains for inclusion to the shared state of Polkadot;
  • collators — nodes that maintain a parachain by collecting its transactions and producing new block candidates to pass to validators;
  • Cross-Consensus Messaging Format (XCM) — format that allows parachains to send messages of any type to each other.

The goal of this lesson is to get to know the basic elements of the Polkadot ecosystem and understand how they interact with each other. To do this, you will run your local relay chain and several Robonomics-based parachains.

Requirements

  • Docker, please install it.
  • Polkadot-launch, please install it (optionally, if you don't want to use docker).

Launch the relay

Run a local instance of Rococo (polkadot testnet) relay chain with two Robonomics-based parachains as the children.

First, pull version 2 of WinterSchool Docker using the command below:

docker pull robonomics/robonomics:winter-school-2

Now run the docker using the command below:

docker run -ti --rm --network host robonomics/robonomics:winter-school-2 bash
cd polkadot-launch/
./launch.sh

Depending on the specs of your machine, it can take up to several minutes, but be patient. As a result, you should have three chain instances.

The video below is a walk through the previous steps. Refer to the video if you would have problems with the chain instances.

Click on picture to view asciinema video

Once the instances are created, you can access them by their IDs. In our case, the IDs are as the following:

As the next step, let's create an HRMP channel to pass messages between parachains. We would use sudo module to call on relay chain page. To do this, Open Rocco relay chain(https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer) and switch to local node from the top left. Then, go to Developer->Sudo, fill in parts as shown in figure below and click on Submit Sudo.

hrmp

When the channel is created, the XCM calls would become available. Let's use datalogXcm pallet - a XCM version of datalog pallet in first parachain (9988).

In the next step, switch to the first parachain(https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9988#/explorer). Find Settings->Developer, paste the following configurations, and click on Save.

{
    "Address": "AccountId",
    "LookupSource": "AccountId",
    "AccountInfo": "AccountInfoWithDualRefCount"
}

After saving the configurations, find Extrinsics under the Developer tab. Fill in the parts as shown in figure below and click on Submit Transaction. Wait for transaction to be finalized.

datalogXcmSend

As a result of the above operation, the message on second parachain will call datalog pallet and write data onto the chain.

To view the message, go to the other parachain (https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9989#/explorer).

You should be able to see that your message has been sent from the first parachain (9998) to the second one (9999). The message will appear in the Explorer tab under recent events.

datalogXcmRecv

This example demonstrated that how XCM could be used for cross chain usage of standard Robonomics pallets.

← Lesson 3, Robonomics IO in Practice Lesson 5, Connectivity →