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.
- Unix-like operating system or Windows Subsystem for Linux (WSL)
- Rust
- Docker
- Foundry
- node.js and npm
- Cartesi CLI
- Nonodo CLI (optional, but recommended for development)
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:
-
Clone the template repository:
Terminal git clone git@github.com:crabrolls-cartesi/template.git -
Enter the template directory:
Terminal cd template -
Now you can use the Cartesi CLI to run the application:
Firts you need to build the project:
Terminal cartesi buildAnd then you can run the project:
Terminal cartesi runThe terminal will show the output of the application like:
Terminal prompt-1 | Anvil running at http://localhost:8545prompt-1 | GraphQL running at http://localhost:8080/graphqlprompt-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/rpcprompt-1 | Paymaster running at http://localhost:8080/paymaster/prompt-1 | Press Ctrl+C to stop the nodeNow 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:
-
Create a new cargo project:
Terminal cargo new my_project -
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 CrabRollsethabi = "18.0.0" # Base ethereum abi/primitive types library used by CrabRolls -
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: