Skip to main content

Compiling a Cairo 1 Project with Protostar

To build your contracts, first define them in protostar.toml

To build run

build
protostar build

Check CLI reference for more details.

Output directory

Running protostar build command will generate the compiled contracts in the build directory by default. You can specify a custom output directory using the --compiled-contracts-dir argument.

Example
$ protostar build --compiled-contracts-dir out

.sierra.json files contain contracts compiled to the sierra format. This format is used to declare contracts on Starknet. Read more about sierra here.

.casm.json files contain contracts compiled to the casm format which can be executed on the Cairo Virtual Machine. This format is used to calculate compiled_class_hash of a contract.

.class_hash files contain class hash of the built contract

.compiled_class_hash files contain compiled class hash of the built contract

note

If you need to print machine-readable output in JSON format, you should use --json flag.

Compiling a single contract

If your protostar.toml file defines multiple contracts, and you wish to compile only one of them, you can specify the --contract-name argument:

$ protostar build --contract-name my_contract