Skip to main content

On-chain API

Having informally discussed how Cartesi Compute represents Cartesi Machines on-chain, one can now describe in more details the API for requesting and retrieving computations in Cartesi Compute.

All interactions with the Cartesi Compute infrastructure are done through a single smart contract, conveniently called CartesiCompute. In this contract, there are only two endpoints that a developer needs to access. These are the functions instantiate and getResult, and they are respectively responsible for starting a new computation and obtaining its output.

The instantiate call is a little more elaborate, as it needs to specify all the details of the machine, including its hash, maximum running time and metadata about its input drives. This is explained in detail in the next section.

In contrast, the getResult endpoint is very simple: in a typical situation it returns the output of the computation. Here, "output of the computation" refers to the contents of the output drive inside the Linux machine when it halted.

In exceptional cases, the getResult function can return error codes, for example when one of the involved parties misbehaves and is proved wrong by the dispute resolution that followed.

© 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.