You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"rule":"BASE_BASIS","sentence":"^\\QThis guide covers the Cartesi+Espresso integration and how to upgrade Cartesi application such that inputs can be submitted via Espresso instead of the regular base layer.\\E$"}
2
2
{"rule":"MORFOLOGIK_RULE_EN_US","sentence":"^\\QIntegrating Cartesi and Chronicle offers Cartesi applications access to onchain and offcahin data like, price feed without developers having to set up additional systems or intermediaries.\\E$"}
Copy file name to clipboardExpand all lines: cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/introduction.md
+80-3Lines changed: 80 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ id: introduction
3
3
title: Introduction
4
4
---
5
5
6
-
The backend of a Cartesi dApp retrieves a new request as follows:
6
+
The backend of a Cartesi application as mentioned in the [overview section](../index.md#backend-apis) contains the applications logic and state, it interacts with the Cartesi rollups framework by retrieving request and submitting structured outputs. The application backend retrieves a new request as follows:
7
7
8
8
- 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:
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.
@@ -140,10 +215,12 @@ An **Inspect** request involves making an external HTTP API call to the rollups
140
215
141
216
You can make a simple inspect call from your frontend client to retrieve reports.
142
217
143
-
To perform an Inspect call, use an HTTP GET request to `<address of the node>/inspect/<request path>`. For example:
218
+
To perform an Inspect call, use an HTTP POST request to `<address of the node>/inspect/<application name or address>` with a body containing the request payload. For example:
144
219
145
220
```shell
146
-
curl http://localhost:8080/inspect/mypath
221
+
curl -X POST http://localhost:8080/inspect/0xb483897a2790a5D1a1C5413690bC5933f269b3A9 \
222
+
-H "Content-Type: application/json" \
223
+
-d '"test"'
147
224
```
148
225
149
226
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**.
Copy file name to clipboardExpand all lines: cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/notices.md
+21-24Lines changed: 21 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ Crucially, the base layer conducts on-chain validation of these notices through
13
13
14
14
This validation process ensures the integrity and authenticity of the submitted notices, enabling the blockchain to verify and authenticate the declared off-chain events or conditions.
15
15
16
-
Let's see how a Cartesi dApp's **Advance** request sends an output to the rollup server as a notice:
16
+
Here are sample functions you can add to your application, then call to send a notice to the rollup server:
17
17
18
18
import Tabs from '@theme/Tabs';
19
19
import TabItem from '@theme/TabItem';
@@ -23,25 +23,30 @@ import TabItem from '@theme/TabItem';
23
23
<pre><code>
24
24
25
25
```javascript
26
-
async function handle_advance(data) {
27
-
console.log("Received advance request data " + JSON.stringify(data));
28
-
29
-
const inputPayload = data["payload"];
26
+
import { stringToHex, hexToString } from "viem";
30
27
28
+
const emitNotice = async (inputPayload) => {
29
+
let hexPayload = stringToHex(inputPayload); // convert payload from string to hex
31
30
try {
32
31
await fetch(rollup_server + "/notice", {
33
32
method: "POST",
34
33
headers: {
35
34
"Content-Type": "application/json",
36
35
},
37
-
body: JSON.stringify({ payload: inputPayload }),
36
+
body: JSON.stringify({ payload: hexPayload }),
38
37
});
39
38
} catch (error) {
40
39
//Do something when there is an error
41
40
}
41
+
}
42
42
43
+
async function handle_advance(data) {
44
+
console.log("Received advance request data " + JSON.stringify(data));
45
+
const payload = hexToString(data.payload); // convert input from hex to string for processing
46
+
await emitNotice(payload);
43
47
return "accept";
44
48
}
49
+
45
50
```
46
51
47
52
</code></pre>
@@ -51,24 +56,16 @@ async function handle_advance(data) {
51
56
<pre><code>
52
57
53
58
```python
54
-
55
-
def handle_advance(data):
56
-
logger.info(f"Received advance request data {data}")
Copy file name to clipboardExpand all lines: cartesi-rollups_versioned_docs/version-2.0/api-reference/backend/vouchers.md
+83Lines changed: 83 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,89 @@ The [`CartesiDApp`](../contracts/application.md) contract is crucial in validati
16
16
17
17
The result of the voucher execution is recorded on the base layer. This recording typically involves submitting claims by a consensus contract, ensuring the integrity and transparency of the executed on-chain action.
18
18
19
+
import Tabs from '@theme/Tabs';
20
+
import TabItem from '@theme/TabItem';
21
+
22
+
<Tabs>
23
+
<TabItemvalue="Python"label="Python"default>
24
+
<pre><code>
25
+
26
+
```python
27
+
# Voucher creation process
28
+
import requests
29
+
import json
30
+
from os import environ
31
+
from eth_utils import function_signature_to_4byte_selector
0 commit comments