Skip to main content

Quickstart

Welcome to Quickstart. Here is a step-by-step guide to building a decentralized application quickly.

Set up your environment

The primary requirements for building on Cartesi are Docker Desktop and the Cartesi CLI.

windows os configuration

If you use Windows, you must have WSL2 installed and configured for building. In Docker Desktop settings, confirm that the WSL2-based engine configurations are enabled.

Install Docker Desktop and Cartesi CLI

  1. Install Docker Desktop for your operating system.

    To install Docker RISC-V support without using Docker Desktop, run the following command:

     docker run --privileged --rm tonistiigi/binfmt --install all
  2. Download and install the latest version of Node.js.

  3. Cartesi CLI is an easy-to-use tool to build and deploy your dApps. To install it, run:

     npm i -g @cartesi/cli

Create an application

To create the backend application from scratch, run:

cartesi create <dapp-name> --template <language>

This creates a new directory with template code in the language you specify.

$ cartesi create js-dapp --template javascript
✔ Application created at /js-dapp

Your application entry point will be the src/index.js file.

Build the application

To build your application, ensure you have Docker Desktop running.

After that, you can run the command provided below:

cartesi build

The cartesi build command builds a Cartesi machine and compiles your application so that it is ready to receive requests and inputs.

Run the application

Running your application starts a local Anvil node on port 8545.

To run your application:

cartesi run

Send inputs to the application

You have some options for sending input to your application. One option is the cartesi send command.

Another option is Cast, a command-line tool for making Ethereum RPC calls.

Additionally, you can build a custom web interface to input data into your application.

Using Cartesi CLI

Here is how you can send input to your dApp:

cartesi send

This guides you through sending inputs with the CLI interactively.

? Select the send sub-command (Use arrow keys)
❯ Send DApp address input to the application.
Send ERC-20 deposit to the application.
Send ERC-721 deposit to the application.
Send ether deposit to the application.
Send generic input to the application.

Using Cast

Here is how you can send input to your dApp with Cast:

cast send <InputBoxAddress> "addInput(address,bytes)" <DAppAddress> <EncodedPayload> --mnemonic <MNEMONIC>

This command sends an input payload to your application through the InputBox contract.

Replace placeholders like <InputBoxAddress>, <DAppAddress>, <EncodedPayload>, and <MNEMONIC> with the actual addresses, payload, and mnemonic for your specific use case.

You can obtain the relevant addresses by running cartesi address-book.

Using a custom web interface

You can create a custom frontend that interacts with your application.

Follow the React.js tutorial to build a frontend for your application.

Deploy the application

There are two methods to deploy an application:

  1. Self-hosted deployment: Deploy the application node using your infrastructure.

  2. Third-party service provider: Outsource running the application node to a service provider.

important

Deployment with a third-party service provider is under development and will be available in a future release.

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