Cheat sheet
Get started with Scarb by following a cheatsheet of the most important commands.
Creating new project
scarb new project/directory
TIP
There is scarb init
which runs in current directory instead of creating new one.
Compiling
scarb build
Built Sierra code of this package will be written to target/dev
directory.
TIP
scarb clean
cleans target
directory.
TIP
scarb check
checks for errors without compiling the packages.
Building CASM
Add following to Scarb.toml
:
[lib]
casm = true
Adding following line to [lib]
section will stop building Sierra code:
sierra = false
Building StarkNet contracts
Add following to Scarb.toml
:
[dependencies]
starknet = ">=2.8.5"
[[target.starknet-contract]]
Adding dependencies
In manifest
Add dependency hosted on the official scarbs.xyz registry:
[dependencies]
alexandria_math = "0.1.0"
Add dependency hosted on a Git repository:
[dependencies]
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" }
Add dependency located in local path:
[dependencies]
alexandria_math = { path = "../path-to-alexandria-checkout/alexandria" }
TIP
You can add version
field to specify package version requirement.
TIP
You can add branch
, tag
and rev
fields to Git dependencies.
TIP
You can use ssh://
URLs, Scarb uses local git
installation for all network operations.
TIP
You can add development dependencies in [dev-dependencies]
section.
Via scarb add
Add dependency from the official scarbs.xyz registry:
scarb add [email protected]
Add dependency hosted on a Git repository:
scarb add alexandria_math --git https://github.com/keep-starknet-strange/alexandria.git
Add dependency located in local path:
scarb add alexandria_math --path ../path-to-alexandria-checkout/alexandria
TIP
You can specify package version like this: [email protected]
, but see remarks in previous section.
TIP
--git
supports --branch
, --tag
and --rev
arguments.
TIP
scarb rm
removes a dependency.
TIP
--dev
flag adds/removes a development dependency.
Formatting
Format Cairo code:
scarb fmt
Check formatting in CI:
scarb fmt -c
Updating locked dependencies
scarb update