Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 2.3 KB

README.md

File metadata and controls

63 lines (41 loc) · 2.3 KB

Echo JS DApp

This example represents a minimalistic Cartesi Rollups application that simply copies (or "echoes") each input received as a corresponding output notice. This DApp's back-end is written in JavaScript.

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 response should be something like this:

[{"epoch":"0","input":"1","notice":"0","payload":"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.

This DApp's back-end is written in JavaScript using txiki runtime, so to run it in your machine you need to have txiki installed.

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

cd echo-js/
ROLLUP_HTTP_SERVER_URL="http://127.0.0.1:5004" tjs echo.js

The final command will effectively run the back-end and send corresponding outputs to port 5004. It can optionally be configured in an IDE to allow interactive debugging using features like breakpoints.

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

ls *.js | ROLLUP_HTTP_SERVER_URL="http://127.0.0.1:5004" entr -r tjs echo.js

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

HTTP rollup_server url is http://127.0.0.1:5004
Sending finish

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