Skip to content

Creating a new Project

In this guide, you will learn how to create a new project or example using CrabRolls! This guide will help you set up your environment and create a new project or example.

Prerequisites

To start and run a new project or example using CrabRolls, you need a few tools and dependencies. This guide will help you set up your environment and create a new project or example using CrabRolls.

From template

Current we have a template to create a new project or example using CrabRolls, available in the CrabRolls template repository, this template are a echo example, and you can see more information about it in the Echo example documentation. To use the template, you can follow the steps below:

  1. Clone the template repository:

    Terminal
    git clone git@github.com:crabrolls-cartesi/template.git
  2. Enter the template directory:

    Terminal
    cd template
  3. Now you can use the Cartesi CLI to run the application:

    Firts you need to build the project:

    Terminal
    cartesi build

    And then you can run the project:

    Terminal
    cartesi run

    The terminal will show the output of the application like:

    Terminal
    prompt-1 | Anvil running at http://localhost:8545
    prompt-1 | GraphQL running at http://localhost:8080/graphql
    prompt-1 | Inspect running at http://localhost:8080/inspect/
    prompt-1 | Explorer running at http://localhost:8080/explorer/
    prompt-1 | Bundler running at http://localhost:8080/bundler/rpc
    prompt-1 | Paymaster running at http://localhost:8080/paymaster/
    prompt-1 | Press Ctrl+C to stop the node

    Now you can test the Examples or create your own project based on the template!

From scratch

If you want to create a new project or example from scratch, you can follow the steps below:

  1. Create a new cargo project:

    Terminal
    cargo new my_project
  2. Add the CrabRolls dependencies to your Cargo.toml file:

    Cargo.toml
    [dependencies]
    async-std = "1.12.0" # Current used async runtime(compatible with cartesi machine)
    crabrolls = "2.0.0" # Latest version of CrabRolls
    ethabi = "18.0.0" # Base ethereum abi/primitive types library used by CrabRolls
  3. Follow the Environment setup guide to set up your environment and how to use the Cartesi CLI to run the application.

Using examples

This project has a collection of examples that demonstrate how to use high-level features of CrabRolls. Each example is a standalone project that can be run independently. All the examples code is available in the CrabRolls repository and the use of each example is documented in the examples section of this documentation. Current available examples are: