Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
= Compiling Starknet Contracts

Compile a Starknet Contract to a Sierra ContractClass:
Starknet contracts are compiled in two stages: first from Cairo to Sierra, then from Sierra to CASM.

== Cairo to Sierra

`starknet-compile` compiles a Cairo contract to a Sierra ContractClass (a JSON file containing
the contract's Sierra code, ABI, and entry point information):

[source,bash]
----
Expand All @@ -13,9 +18,22 @@ Or specify the contract path if multiple contracts are defined in the same proje
cargo run --bin starknet-compile -- /path/to/crate/ /path/to/output.json --contract-path path::to::contract
----

Compile a Sierra ContractClass into a CompiledClass (CASM):
== Sierra to CASM

`starknet-sierra-compile` compiles a Sierra ContractClass into a CompiledClass (CASM),
which is the executable bytecode format that runs on the Cairo VM:

[source,bash]
----
cargo run --bin starknet-sierra-compile -- /path/to/input.json /path/to/output.casm
----

== Using Scarb

For most projects, link:https://docs.swmansion.com/scarb/[Scarb] (the Cairo package manager)
handles compilation automatically. Running `scarb build` compiles contracts and produces the
Sierra ContractClass JSON files in the `target/` directory.

== See also

- xref:../../language_constructs/pages/contracts.adoc[Contracts] — Writing Starknet contracts in Cairo
Loading