GithubHelp home page GithubHelp logo

ftupas / cairo-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from auditless/cairo-template

0.0 0.0 0.0 20 KB

A minimal template for building smart contracts with Cairo 1.0

License: MIT License

Rust 80.98% Makefile 19.02%

cairo-template's Introduction

Minimal Cairo 1.0 Template PRs Welcome

Built with auditless/cairo-template

A minimal template for building smart contracts with Cairo 1.0 using the Quaireaux project defaults.

How it works

  • No submodules, forks or other heavy machinery
  • Uses the cairo-test-runner binary for running tests
  • Built as a Scarb package for reusability and uses Scarb dependencies for libraries
  • Has reproducible builds using GitHub Actions
  • Includes a standard Makefile for commonly used commands

Installing dependencies

Step 1: Install Cairo 1.0 (guide by Abdel)

If you are on an x86 Linux system and able to use the release binary, you can download Cairo here https://github.com/starkware-libs/cairo/releases.

For everyone, else, we recommend compiling Cairo from source like so:

# Install stable Rust
$ rustup override set stable && rustup update

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

# 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 ~/Bin && git fetch && git pull && cargo build --all --release

Step 2: Add Cairo 1.0 executables to your path

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

NOTE: If installing from a Linux binary, adapt the destination path accordingly.

This will make available several binaries. The one we use is called cairo-test.

Step 3: Install the Cairo package manager Scarb

Follow the installation guide in Scarb's Repository.

How to use this template

First you will need to clone the repository or click the Use this template button at the top of the page to create a new repository based on the template.

Next, you will want to update the configuration files with the name of your project:

├── .cairo_project.toml
└── .Scarb.toml

Working with your project

The Cairo template currently supports building and testing contracts.

Build

Build the contracts.

$ make build

Test

Run the tests in src/test:

$ make test

Format

Format the Cairo source code (using Scarb):

$ make fmt

Thanks to

  • The Quaireaux team for coming up with this configuration and especially Abdel for helping me with Cairo 1.0 installation
  • Paul Berg and the foundry-template project which served as inspiration
  • Last but not least, the StarkWare team for building the first smart contract language that is a joy to use

Other templates

License

MIT © Auditless Limited

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.