Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Latest commit

 

History

History

echo-low-level

Echo low-level DApp

This example implements the same behavior as the Echo DApp written in Python, but here the back-end is written in C++ and uses the low-level Cartesi Rollup API instead of the HTTP API. As the other example, the DApp simply copies (or "echoes") each input received as a corresponding output notice.

Low-level API

For the Cartesi Machine to interact with the outside world in the Rollups context, it has to perform read and write operations in a specific memory region. We wrote a Linux Kernel module to perform these low-level operations. The Linux Kernel that we provide already comes with this module ready to use.

The Cartesi Rollup kernel module provides a device driver that allows it to communicate with the userspace. A process in the userspace should open the device driver and perform IOCTL system calls to interact with the device. The system calls available are specified in the rollup.h header file.

The Cartesi Rollup HTTP Server uses the Cartesi Rollup device driver API under the hood. Both the device driver API and the HTTP API provide the same functionality and are very similar. When possible, you should use the HTTP API described in the other examples. The device driver is a low-level API that is error-prone and is not available in host mode. The only reason to use the device driver directly instead of using the Cartesi HTTP API is to gain performance.

Interacting with the application

We can use the frontend-console application to interact with the DApp. Ensure that the application has already been built before using it.

First, go to a separate terminal window and switch to the frontend-console directory:

cd frontend-console

Then, send an input as follows:

yarn start input send --payload "Hello there"

In order to verify the notices generated by your inputs, run the command:

yarn start notice list

The payload of the notice should be "Hello there".

Running the back-end in host mode

This application does not support host mode because it uses the Cartesi Rollup device driver, which is available only inside the Cartesi Machine.