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-cpp

Echo C++ DApp

This example implements the same behavior as the Echo DApp written in Python, but here the back-end is written in C++. As the other example, the DApp simply copies (or "echoes") each input received as a corresponding output notice.

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

When developing an application, it is often important to easily test and debug it. For that matter, it is possible to run the Cartesi Rollups environment in host mode, so that the DApp's back-end can be executed directly on the host machine, allowing it to be debugged using regular development tools such as an IDE.

In order to start the echo-cpp back-end in host mode, run the following commands in a dedicated terminal:

cd echo-cpp/
./run-host.sh

This will run the echo-cpp back-end and send the corresponding notices to port 5004.

You can also use a tool like entr to restart it automatically when the code changes. For example:

ls *.cpp | entr -r ./run-host.sh

After the back-end successfully starts, it should print an output like the following:

Starting echo-dapp: Sending finish

After that, you can interact with the application normally as explained above.