JSON Blog
Overview
The JSON Blog application is a straightforward implementation that demonstrates how to manage blog posts using JSON-based inputs in the Crabrolls framework. It allows you to add, update, and delete posts. This document outlines how to use the JSON Blog application, including sending inputs and inspecting outputs. You can find the source code in the CrabRolls repository.
Usage
With the application running, you can manage blog posts by sending JSON-encoded messages. These messages can be sent using the send
command of the Cartesi CLI tool. The following examples demonstrate how to send different types of messages to the JSON Blog application.
Adding a New Post
To add a new post, use the following JSON input:
Send this input using the send
command:
Updating an Existing Post
To update an existing post, use the following JSON input:
Send this input using the send
command:
Deleting a Post
To delete a post, use the following JSON input:
Send this input using the send
command:
Inspecting Posts
You can get all the posts stored in the application by inspecting the cartesian state. The following example demonstrates how to get the outputs of the application:
Which will return response like this:
Now you can see the posts stored in the application by decoding the payload of the report using the command cast from foundry
:
This will return the posts stored in the application:
Inspecting Changes
The app send a notice of all the changes made to the state, so you can also inspect the notices to see the changes made to the state. The following command demonstrates how to get the notices of the application:
Now you can see the last notices of the application, including the changes made to the state:
Decoding the payload of the notice will return the changes made to the state:
This will return the changes made to the state: