This example implements the same behavior as the Echo DApp written in Python, but here the back-end is written in Rust. As the other example, the DApp simply copies (or "echoes") each input received as a corresponding output notice.
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"
.
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 is written in Rust, so you need to have rust installed in order to recompile it.
In order to start the echo-rust back-end, run the following commands in a dedicated terminal:
cd echo-rust/
ROLLUP_HTTP_SERVER_URL="http://127.0.0.1:5004" cargo run
This will run the echo-rust 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 src/*.rs | ROLLUP_HTTP_SERVER_URL="http://127.0.0.1:5004" entr -r cargo run
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.