Skip to content
cartesiPublic

About

Cartesi CLI tool

Resources

Security policy

Stars

12 stars

Watchers

12 watching

Forks

Repository files navigation

Cartesi CLI

npm CLI License

Create, build, run, and interact with Cartesi applications from your terminal.

Note

This README covers Cartesi CLI 2.0, which is currently published as alpha pre-releases under the npm alpha tag. The npm latest tag still installs the 1.x line.

Overview

cartesi build builds the drives configured for an application, boots a RISC-V Cartesi Machine with them, and stores the resulting machine snapshot in .cartesi/. Docker-backed drives are built for linux/riscv64 with Docker Buildx.

cartesi run starts a local environment with Docker Compose and, when a machine snapshot is available, deploys and registers the application on it. The environment includes:

  • an Anvil development chain;
  • the Cartesi Rollups Node, with its JSON-RPC and Inspect endpoints;
  • PostgreSQL; and
  • a Traefik proxy that serves every endpoint from a single local port.

Getting started

Requirements

  • Docker Engine 25.0 or later with Docker Compose 2.24 or later and Buildx 0.13 or later; Docker Desktop provides all three
  • Docker support for linux/riscv64. Docker Desktop includes it; on a standalone Docker Engine, install it with docker run --privileged --rm tonistiigi/binfmt:riscv
  • Node.js 24 or later when installing through npm

The CLI runs tools such as cartesi-machine from your PATH when they are installed, and otherwise runs them in Docker. If cartesi-machine is installed on the host, it must be version 0.22.x. Machines stored with 0.21 can't be loaded by 0.22, so rebuild and redeploy applications after upgrading.

Run cartesi doctor after installation to check these requirements.

Installation

Install from npm:

npm install -g @cartesi/cli@alpha

Alternatively, download a standalone binary, which does not require Node.js, from the latest @cartesi/cli@2.0.0-alpha.* pre-release on GitHub Releases: cartesi-darwin-arm64.tar.gz, cartesi-darwin-x64.tar.gz, cartesi-linux-arm64.tar.gz, or cartesi-linux-x64.tar.gz (not the .map.tar.gz source maps). Extract it, rename the executable to cartesi, and move it to a directory on your PATH.

Verify the installation:

cartesi --version
cartesi doctor

Create your first application

Create, build, and run an application:

cartesi create hello --template python
cd hello
cartesi build
cartesi run --services explorer

cartesi run prints the URLs of the local endpoints and of the explorer. Keep it running and, in another terminal, interact with the application:

cartesi send "hello world" --encoding string
cartesi status
cartesi address-book

The proxy prefers port 6751 and picks another free port up to 6761 when it is taken. Always use the URLs printed by cartesi run.

Commands

Command Purpose
create <name> --template <template> Scaffold an application from a template
build Build the configured drives and create a machine snapshot
run Start the local environment and deploy the application
send [input] Send an input to the application
deposit ether | erc20 | erc721 | erc1155-single | erc1155-batch Deposit an asset into the application
status Show the status of the local environment
logs Show logs from the local node; use --follow to stream them
address-book Print the addresses of the deployed contracts
hash Print the machine hash of the built application
shell Open a shell inside the application machine
clean Delete cached build artifacts
doctor Check local prerequisites
foreclose Foreclose the local application as its guardian so users can withdraw
refund <input-index> Refund a deposit that was not finalized before the foreclosure
withdraw --account <address> Withdraw an account's funds from a foreclosed application

The deploy command is deprecated in 2.0. The cartesi CLI is meant for application development; cartesi-rollups-cli, distributed with the Cartesi Rollups Node, deploys and registers applications on public networks. Follow the self-hosted deployment guide for the complete workflow.

Run cartesi <command> --help for every option.

Configuration

Applications are configured with cartesi.toml. Without one, the CLI uses a Docker-backed root drive, 128 MiB of machine RAM, and the other default machine settings. Sizes accept IEC units such as 64Mi and 4Ki. The following example increases the RAM to 256 MiB while keeping the default root drive:

[machine]
ram_length = "256Mi"

[drives.root]
builder = "docker"
dockerfile = "Dockerfile"
format = "ext2"

See the advanced configuration guide for all available settings. Pass -c, --config <file> to build, run or shell to load additional files on top of cartesi.toml; the option can be repeated, and later files extend or override earlier ones.

run options

Run cartesi run --help to see all options and their defaults. Commonly used ones include --prt to deploy with PRT consensus, --fork-url to fork an existing Ethereum network, and --block-time and --epoch-length to tune the local chain.

Set supported CARTESI_* variables in the host environment before starting cartesi run, and the CLI forwards them to the node. List the supported variables with:

cartesi run --list-supported-variables

Optional services

Enable optional services with --services:

Service Description
explorer Rollups Explorer web interface
bundler ERC-4337 bundler
paymaster Mock verifying paymaster for account abstraction
passkey Passkey server
cartesi run --services explorer
cartesi run --services bundler,paymaster,passkey

Templates

Template Language
cpp, cpp-low-level C++
go Go
java Java
javascript, typescript JavaScript and TypeScript
lua Lua
python Python
ruby Ruby
rust Rust

Templates are maintained in cartesi/application-templates, on the prerelease/sdk-12 branch that cartesi create uses by default. Pass --branch <name> to use another branch.

Development

This section is for working on the CLI itself. The repository is a Bun monorepo managed with Turborepo and Biome:

Path Package Purpose
apps/cli @cartesi/cli The CLI, distributed through npm and as native Linux and macOS binaries
packages/sdk @cartesi/sdk Docker image used to build and run Cartesi applications
packages/mock-verifying-paymaster @cartesi/mock-verifying-paymaster Mock ERC-4337 verifying paymaster used by the optional services
packages/tsconfig tsconfig Shared TypeScript configurations

Install dependencies and run the main checks:

bun install
bun run build
bun run lint
bun run test

The full build requires Docker, because it builds the SDK image. CLI integration tests may start containers and pull images. Focused commands include:

bun run build --filter @cartesi/cli
bun test apps/cli/tests/unit/

Releases are managed with Changesets. Publishing @cartesi/cli to npm also uploads the native binaries to the matching GitHub release. See the CLI changelog for changes between releases.

Contributing

Issues and pull requests are welcome on GitHub.

Security

Do not open a public issue, pull request, or discussion for a security problem. Report it privately by email to rollups@cartesi.foundation with the affected component and version, the impact and who is affected, and steps to reproduce. The full policy and the published security reviews are on the Audit reports page.

Related projects and support

For help, join the Cartesi Discord. For reproducible bugs and feature requests, open a GitHub issue and include the output of cartesi doctor and cartesi status --json, with sensitive information removed.

License

Licensed under the Apache License 2.0.

About

Cartesi CLI tool

Resources

Security policy

Stars

12 stars

Watchers

12 watching

Forks

Releases

Packages

Used by

Contributors

Languages