Skip to main content

Introduction

In this course, we will build a dapp consisting of three blockchains: Order, Factory, and Delivery. They will interact with each other using ICMF.

ICMF can be compared to a message queue, where a chain can emit events on a specific topic or subscribe to several topics. This is an integral part of the architecture of Chromia, where blockchains need to communicate without user interaction.

Sending a message using ICMF is easy in Rell, but what actually happens under the hood?

  1. The sender dapp calls the function send_message, a part of the icmf rell library. This could be user-triggered via an operation or by the dapp itself.

  2. This emits an event on the node, which is sent to the cluster's anchoring chain.

  3. The receiver node polls for messages on the subscribed topics before each block gets built.

  4. When a message is found, the node calls the __icmf_message special operation on the dapp.

  5. The function receive_icmf_message gets called by the icmf library, which triggers any logic defined by the dapp.

Based on this, we see that the type of dapps that are ideal for this type of messaging is when you want chains to broadcast a message to indicate that it has completed an action. Then it is up to the other chains to subscribe to this action and then perform an action based on the information in the message. This way you can add more chains to your solution with new responsibilities, and they just have to subscribe to their topics of interest, no logic needs to be changed in the sender chain.

In our scenario, the factory workers do not care who created an order and when it was created. They only care about that an order is created and start their manufacturing process, similarly, for the Delivery chain. The delivery company only cares about what box or products they should deliver and where, not what is actually in the box.