Skip to main content

Reading outputs

In Cartesi Rollups, the outputs include:

Vouchers and Notices are intended for on-chain validation by making function calls to the CartesiDApp contract (which is effectively our output contract). We validate and execute Vouchers using the executeVoucher() function. We validate Notices using the validateNotice() function call. Conversely, Reports serve as stateless logs, providing read-only information without affecting the state.

Let's take a look at how a Cartesi dApp reads Notices. We can send an input to the dApp using Cast:

cast send 0xInputBoxAddress123 "addInput(address,bytes)" 0xDAppAddress456 0xEncodedPayload789

On the back-end, the following example code creates and sends a notice containing a payload to the Rollup Server's /notice endpoint, enabling on-chain validation of specific events or conditions without requiring direct interaction with the dApp Rollup Contract:

notice = {"payload": "0xdeadbeef"} + "/notice", json=notice)

These outputs can then be read through the GraphQL API that the Cartesi Nodes expose.

The following code shows an example of a Javascript client querying the notices of a dApp that is running in a local environment:

const response = await fetch("http://localhost:4000/graphql", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: '{ "query": "{ notices { edges { node { payload } } } }" }',
const result = await response.json();
for (let edge of {
let payload = edge.node.payload;

© 2024 Cartesi Foundation Ltd. All rights reserved.

The Cartesi Project is commissioned by the Cartesi Foundation.

We use cookies to ensure that we give you the best experience on our website. By using the website, you agree to the use of cookies.