Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
5b1cb05
add: Added an external resource section
Nonnyjoe Nov 7, 2024
00443bf
update: restructured external resource position
Nonnyjoe Nov 7, 2024
c38e32c
add: Added an external resource section
Nonnyjoe Nov 7, 2024
02134c3
update: restructured external resource position
Nonnyjoe Nov 7, 2024
822b3ef
update: added shour descriptions for different integratins
Nonnyjoe Nov 18, 2024
b634c68
add: added the integrations guide section
Nonnyjoe Nov 25, 2024
d0b4092
update on structure, spliting architecture concepts and installation …
jplgarcia Dec 9, 2024
ff11b01
updated tutorials for v2
jplgarcia Dec 23, 2024
ac5095d
admonition
jorka Dec 2, 2024
f3c1025
announcement bar
jorka Dec 2, 2024
238159a
api item
jorka Dec 2, 2024
674e187
edit this page, custom icons
jorka Dec 9, 2024
98198ad
footer
jorka Dec 10, 2024
6de6563
edit icon fix
jorka Dec 11, 2024
0d312ce
edit icon fix
jorka Dec 11, 2024
c92663b
remove console log
jorka Dec 12, 2024
38f8111
sidebar version
jorka Dec 12, 2024
1d9feb8
sidebar version
jorka Dec 12, 2024
d355522
config and deps
jorka Dec 12, 2024
36d6a98
remove DocVersionBadge
jorka Dec 12, 2024
8177c81
open api config - enable generation of previos versions
jorka Dec 13, 2024
0b80416
generate prev versions open api
jorka Dec 13, 2024
3d274ac
yarn lock
jorka Dec 13, 2024
add2564
remove log
jorka Dec 13, 2024
6155ed6
add deps
jorka Dec 13, 2024
803da51
fix mdx
jorka Dec 18, 2024
e6dbf93
add missing page to fix broken links
jorka Dec 18, 2024
4e008b9
fix api folder for v2, comment missing redirects, switch to v2
jorka Dec 18, 2024
55a4533
docs: application section updated to v2
henriquemarlon Dec 2, 2024
97da595
docs: typos and solving requests for input-box and application consensus
henriquemarlon Mar 8, 2025
384e61d
docs: update from json-rpc to contracts
henriquemarlon Mar 8, 2025
a647296
docs: update broken links
henriquemarlon Mar 8, 2025
24bda59
docs: update broken links
henriquemarlon Mar 8, 2025
5fe240d
docs: update from json-rpc to contracts
henriquemarlon Mar 8, 2025
c763fea
docs: solve broken links and wrong references
henriquemarlon Mar 8, 2025
d23c7dc
migration guide v1.5 to v2
riseandshaheen Mar 11, 2025
f5ba31c
feat: docs v2 products restructuring, rollups and coprocessor in navbar
riseandshaheen Apr 28, 2025
6007060
fix: visibility of version dropdown and table of contents on coproces…
riseandshaheen Apr 29, 2025
06dc744
doc: added quickstart(rollups) to Get-Started tab
riseandshaheen Apr 30, 2025
304a6d1
refactor: removed troubleshooting, differences with rollups and nonod…
riseandshaheen May 1, 2025
85d94ae
revert: coprocessor content
riseandshaheen May 16, 2025
071c4c8
updated content for cartesi-machine and fraud-proofs
riseandshaheen May 16, 2025
40f939a
changed table font size for better fit
jplgarcia May 20, 2025
a1d870e
docs(api): graphql reference update
henriquemarlon Mar 31, 2025
2a27555
queries update
henriquemarlon Apr 3, 2025
9b234fc
docs: more clear description and some broken links
henriquemarlon Apr 7, 2025
6223b22
docs: add delegate call voucher docs
henriquemarlon Apr 8, 2025
05018ac
docs: fix references for filters
henriquemarlon Apr 8, 2025
ab0e448
docs: update inspect request reference
henriquemarlon Apr 8, 2025
089d7df
docs:add reference for delegate call vouchers on vouchers section
henriquemarlon Apr 8, 2025
c6ce67e
docs(api-reference): add exception and finish to backend
henriquemarlon Apr 8, 2025
2c8ea55
docs(api-reference): chnage query for enum
henriquemarlon Apr 8, 2025
6908076
docs(api-reference): add outputs on intro for backend apis
henriquemarlon Apr 9, 2025
24ae0e3
docs(api-reference): update info for finish endpoint
henriquemarlon Apr 9, 2025
f3c6ce1
docs: improve delegate call voucher description
henriquemarlon May 2, 2025
53ab86a
docs: json-rpc api section
henriquemarlon May 2, 2025
3eb3e30
docs: improve description and references
henriquemarlon May 3, 2025
0ead892
docs: improve description and references
henriquemarlon May 3, 2025
d288aca
docs: fix sidebar
henriquemarlon May 3, 2025
614da5d
docs: update json-rpc api reference
henriquemarlon Jun 2, 2025
356b917
update contracts and json-rpc, consensus WIP
henriquemarlon Jun 26, 2025
fc4baa3
docs: modified development section images
Nonnyjoe Mar 16, 2025
0676a9d
docs: modified assets-handling section
Nonnyjoe Mar 16, 2025
794b64a
docs: modified building section in line with v2 updates
Nonnyjoe Mar 16, 2025
67a20da
docs: partial update to the cli command section
Nonnyjoe Mar 16, 2025
84e360c
docs: Modified graphQL queries and dapp reference in query section
Nonnyjoe Mar 16, 2025
49d467a
docs: updated send-inputs section in line with V2 updates
Nonnyjoe Mar 16, 2025
ec2a456
docs: added page for managing devnet environment
Nonnyjoe Mar 18, 2025
eda318a
docs: modifying the deploying an app section
Nonnyjoe Mar 19, 2025
df321c8
docs: updated cli-commands section inline with cli2.0
Nonnyjoe Mar 20, 2025
5eed1d5
docs: updated broken links in tutorial section referencing changes in…
Nonnyjoe Mar 20, 2025
28584a2
docs: modified page title for building and deploying an application
Nonnyjoe Mar 20, 2025
1720f94
docs: reflected first stage of reviews
Nonnyjoe Mar 21, 2025
0314a2f
docs: updated cli commands in line with cli-aplha-9
Nonnyjoe Apr 21, 2025
6021fb8
docs: updated api-reference
Nonnyjoe Jun 5, 2025
e969173
docs: restructured development section
Nonnyjoe Jun 5, 2025
6e099f4
docs: Implemented reviews across development section
Nonnyjoe Jun 9, 2025
b1c5c51
docs: Rebased on staging and fixed broken links
Nonnyjoe Jun 9, 2025
3aedbbe
update delegatecall
henriquemarlon Aug 8, 2025
3fb1c87
removed espresso, added react tutorials and app-chains page
riseandshaheen Jun 16, 2025
3092ac0
added diagrams and minor improvements
riseandshaheen Jul 3, 2025
15624f6
added spacing on big square image
jplgarcia Jul 3, 2025
85c78f1
update application contract and add consensus section
henriquemarlon Aug 8, 2025
fa89c0e
minor improvements and cosmetic changes
henriquemarlon Aug 10, 2025
8ee5070
fix: id correspondence
henriquemarlon Aug 10, 2025
e568b48
fix: id correspondence
henriquemarlon Aug 10, 2025
2ca0d0e
revert golang version for delegate call voucher
henriquemarlon Aug 10, 2025
5480910
docs(development): Updated development section in line with updates o…
Nonnyjoe Aug 12, 2025
b886b67
feat: src files and deployment tutorial for local node deployment
henriquemarlon Aug 11, 2025
e20fed1
feat: change link for compose file
henriquemarlon Aug 11, 2025
e24d7ae
minor improvements and snapshot section with gh actions example
henriquemarlon Aug 14, 2025
f671a36
docs: update snapshot workflow description and minor updates on self-…
henriquemarlon Aug 21, 2025
20f790f
Fraud Proofs Tab- Content
riseandshaheen Aug 25, 2025
9661939
cosmetic updates and review comments updated content
riseandshaheen Aug 27, 2025
685f8a4
cosmetic updates, dapp to app, sidebar collapse set to true
riseandshaheen Aug 28, 2025
51be67b
honeypot application logic corrections
riseandshaheen Sep 4, 2025
82d6b8c
updates with review comments from lyno
riseandshaheen Sep 5, 2025
086d13b
Rename Computation-Hash-Rollups.jpg to computation-hash-rollups.jpg
riseandshaheen Sep 5, 2025
b489a06
minor updates
riseandshaheen Sep 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ id: introduction
title: Introduction
---

The backend of a Cartesi dApp retrieves a new request as follows:
The backend of a Cartesi dApp processes requests in the following manner:

- Finish — Communicates that any previous processing has been completed and that the backend is ready to handle the subsequent request. This following request is returned as the call's response and can be of the following types:
- **Finish**Called via [`/finish`](./finish.md), indicates that any previous processing has been completed and the backend is ready to handle the next request. The subsequent request is returned as the call's response and can be of the following types:

- **Advance** — Provides input to be processed by the backend to advance the Cartesi Machine state. When processing an `Advance` request, the backend can call the methods `/voucher`, `/notice`, and `/report`. For such requests, the input data contains the payload and metadata, such as the account address that submitted the input.
- **Advance** — Provides input to be processed by the backend to advance the Cartesi Machine state. When processing an Advance request, the backend can call the [`/voucher`](./vouchers.md), and [`/report`](./reports.md) endpoints. For such requests, the input data contains both the payload and metadata, including the account address that submitted the input.

- **Inspect** — This function submits a query about the application's current state. When running inside a Cartesi Machine, this operation is guaranteed to leave the state unchanged since the machine is reverted to its exact previous condition after processing. For Inspect requests, the input data has only a payload.

:::caution Inspect requests
Inspect requests are best suited for non-production use, such as debugging and testing. They may not function reliably in production environments, potentially leading to errors or disruptions.
:::
- **Inspect** — Submits a query about the application's current state. When running inside a Cartesi Machine, this operation is guaranteed to leave the state unchanged, as the machine reverts to its exact previous condition after processing. For Inspect requests, the input data contains only a payload, and the backend can only call the [`/report`](./reports.md) endpoint.

- **Exception** — Called by the backend when it encounters an unrecoverable error during request processing. This signals to the Rollup HTTP Server that the current request processing failed and should be terminated. See [`/exception`](./exception.md) for more details.

## Advance and Inspect

Here is a simple boilerplate application that handles Advance and Inspect requests:
Expand Down Expand Up @@ -120,33 +118,111 @@ while True:
</code></pre>
</TabItem>

<TabItem value="Rust" label="Rust" default>
<pre><code>

```rust
use json::{object, JsonValue};
use std::env;

pub async fn handle_advance(
_client: &hyper::Client<hyper::client::HttpConnector>,
_server_addr: &str,
request: JsonValue,
) -> Result<&'static str, Box<dyn std::error::Error>> {
println!("Received advance request data {}", &request);
let _payload = request["data"]["payload"]
.as_str()
.ok_or("Missing payload")?;
// TODO: add application logic here
Ok("accept")
}

pub async fn handle_inspect(
_client: &hyper::Client<hyper::client::HttpConnector>,
_server_addr: &str,
request: JsonValue,
) -> Result<&'static str, Box<dyn std::error::Error>> {
println!("Received inspect request data {}", &request);
let _payload = request["data"]["payload"]
.as_str()
.ok_or("Missing payload")?;
// TODO: add application logic here
Ok("accept")
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = hyper::Client::new();
let server_addr = env::var("ROLLUP_HTTP_SERVER_URL")?;

let mut status = "accept";
loop {
println!("Sending finish");
let response = object! {"status" => status.clone()};
let request = hyper::Request::builder()
.method(hyper::Method::POST)
.header(hyper::header::CONTENT_TYPE, "application/json")
.uri(format!("{}/finish", &server_addr))
.body(hyper::Body::from(response.dump()))?;
let response = client.request(request).await?;
println!("Received finish status {}", response.status());

if response.status() == hyper::StatusCode::ACCEPTED {
println!("No pending rollup request, trying again");
} else {
let body = hyper::body::to_bytes(response).await?;
let utf = std::str::from_utf8(&body)?;
let req = json::parse(utf)?;

let request_type = req["request_type"]
.as_str()
.ok_or("request_type is not a string")?;
status = match request_type {
"advance_state" => handle_advance(&client, &server_addr[..], req).await?,
"inspect_state" => handle_inspect(&client, &server_addr[..], req).await?,
&_ => {
eprintln!("Unknown request type");
"reject"
}
};
}
}
}
```

</code></pre>
</TabItem>
</Tabs>

An **Advance** request involves sending input data to the base layer via JSON-RPC so they can reach the dApp backend to change the application's state.
An **Advance** request involves sending input data to the base layer via JSON-RPC, allowing it to reach the dApp backend to change the application's state.

![img](../../../../static/img/v1.3/advance.jpg)

In the dApp architecture, here is how an advance request plays out.
Here is how an advance request works in the dApp architecture:

- Step 1: Send an input to the [`addInput(address, bytes)`](../json-rpc/input-box.md) function of the InputBox smart contract.
- Step 1: Send an input to the [`addInput(address, bytes)`](../contracts/input-box.md#addinput) function of the InputBox smart contract.

- Step 2: The HTTP Rollups Server reads the data and gives it to the Cartesi machine for processing.
- Step 2: The HTTP Rollups Server reads the data and sends it to the Cartesi Machine for processing.

- Step 3: After the computation, the machine state is updated, and the results are returned to the rollup server.
- Step 3: After computation, the machine state is updated, and the results are returned to the rollup server.

An **Inspect** request involves making an external HTTP API call to the rollups server to read the dApp state without changing it.
An **Inspect** request involves making an external HTTP API call to the rollups server to read the dApp state without modifying it.

![img](../../../../static/img/v1.3/inspect.jpg)

You can make a simple inspect call from your frontend client to retrieve reports.

To perform an Inspect call, use an HTTP GET request to `<address of the node>/inspect/<request path>`. For example:
To perform an Inspect call, send an HTTP POST request to `<address of the node>/inspect/<application name>` with a payload in the request body. For example:

```shell
curl http://localhost:8080/inspect/mypath
curl -X POST http://localhost:8080/inspect/<application name> \
-H "Content-Type: application/json" \
-d '{"payload": "0xdeadbeef"}'
```

Once the call's response is received, the payload is extracted from the response data, allowing the backend code to examine it and produce outputs as **reports**.
The payload should be a hex-encoded string starting with '0x' followed by pairs of hexadecimal numbers.

After receiving the call's response, the payload is extracted from the response data, allowing the backend code to examine it and produce outputs as **reports**.

The direct output types for **Advance** requests are [vouchers](./vouchers.md), [notices](./notices.md), and [reports](./reports.md), while **Inspect** requests generate only [reports](./reports.md).
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,22 @@ async function handle_advance(data) {
<pre><code>

```python
# Notice creation Process from a message string
def emit_notice(message):
notice_payload = {"payload": "0x" + message.encode("utf-8").hex()}
response = requests.post(rollup_server + "/notice", json=notice_payload)
if response.status_code == 200 or response.status_code == 201:
logger.info(f"Notice emitted successfully with data: {notice_payload}")
else:
logger.error(f"Failed to emit Notice with data: {notice_payload}. Status code: {response.status_code}")

emit_notice("hello world")
def handle_advance(data):
logger.info(f"Received advance request data {data}")

status = "accept"
try:
inputPayload = data["payload"]
# Send the input payload as a notice
response = requests.post(
rollup_server + "/notice", json={"payload": inputPayload}
)
logger.info(
f"Received notice status {response.status_code} body {response.content}"
)
except Exception as e:
# Emit report with error message here
return status
```

</code></pre>
Expand All @@ -74,5 +80,5 @@ emit_notice("hello world")
</Tabs>

:::note querying notices
Frontend clients can query notices using a GraphQL API exposed by the Cartesi Nodes. [Refer to the documentation here](../../development/query-outputs.md/#query-all-reports) to query notices from the rollup server.
Frontend clients can query notices using a GraphQL API exposed by Cartesi Nodes. [Refer to the documentation here](../../development/query-outputs.md/#query-all-reports) to query notices from the rollup server.
:::
Loading
Loading