Git Product home page Git Product logo

cairo-workshop's Introduction

Cairo 101 Workshop

A minimal template for the Cairo 101 workshop

Installing dependencies

Step 0: Install Rust

Before we begin installing Cairo, we first need to make sure we have Rust installed.

Run the following command to check if you already have Rust installed:

cargo --version

If it returns a version number, skip to Step 1. If not, Rust is not present in your system and we need to install it.

We recommend following the instructions for your system, shown in the official Rust docs. After that, rerun the previous command to validate Rust was successfully installed.

Step 1: Install Cairo 1.0

For Cairo, since the language is still in active developmment, we recommend compiling Cairo from source like so:

# Make sure we have the latest stable Rust version
$ rustup override set stable && rustup update

# Clone the Cairo compiler to the $HOME directory
$ cd ~ && git clone [email protected]:starkware-libs/cairo.git && cd cairo

# Generate release binaries
$ cargo build --all --release

NOTE: Keeping Cairo up to date

Now that your Cairo compiler is in a cloned repository, all you will need to do is pull the latest changes and rebuild as follows:

$ cd ~/cairo && git fetch && git pull && cargo build --all --release

Step 2: Add Cairo 1.0 executables to your path

Now that we have built the Cairo 1.0 binaries, we need to add them to the PATH environment variable. Add the following in your .bashrc or .zshrc:

export PATH="$HOME/cairo/target/release:$PATH"

After that, open a new shell and check that the following command returns a version number:

cairo-compile --version

Step 3: Install the Cairo package manager Scarb

Scarb is a package manager from Software Mansion for Cairo projects.

The installation process is similar to Cairo:

# Make sure we have the latest stable Rust version
$ rustup override set stable && rustup update

# Clone the Scarb repo to the $HOME directory
$ cd ~ && git clone [email protected]:software-mansion/scarb && cd scarb

# Generate release binaries
$ cargo build --all --release

# Add the Scarb binary to PATH
export PATH="$HOME/scarb/target/release:$PATH"

Step 4 (Optional): Setup Language Server

VS Code Extension

  • Disable previous Cairo 0.x extension if you already had it
  • Install the Cairo 1 extension for proper syntax highlighting and code navigation. Just follow the steps indicated here.

Cairo Language Server

From Step 1, the cairo-language-server binary should be built and executing this command will copy its path into your clipboard.

$ which cairo-language-server | pbcopy

Update the languageServerPath of the Cairo 1.0 extension by pasting the path.

Commands

The Cairo template currently supports building and testing contracts.

Build

Build the project.

$ make build

Test

Run the tests in src/test:

$ make test

Format

Format the Cairo source code (using Scarb):

$ make fmt

License

This repo was generated from the auditless template for Cairo 1

MIT © Auditless Limited

cairo-workshop's People

Contributors

davidesilva avatar zepedroresende avatar

Stargazers

Sean avatar

Watchers

José Gomes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.