Legacy compiler CLI reference

When the Starknet compiler is installed, you can view this command-line help in a terminal by entering the following command:

starknet-compile --help

Usage

starknet-compile [-h] [--abi ABI] [--disable_hint_validation]
                      [--account_contract] [--dont_filter_identifiers] [-v]
                      [--prime PRIME] [--cairo_path CAIRO_PATH]
                      [--preprocess] [--output OUTPUT] [--no_debug_info]
                      [--debug_info_with_source]
                      [--cairo_dependencies CAIRO_DEPENDENCIES]
                      [--no_opt_unused_functions]
                      file [file ...]

Example

The following example compiles the file contract.cairo. It generates two files:

contract_compiled.json

The contract class. This file contains the bytecode and all other information necessary to execute a contract. For information on contract classes, see Contract classes and instances.

contract_abi.json

The contract’s ABI.

starknet-compile contract.cairo \
    --output contract_compiled.json \
    --abi contract_abi.json

Description

A tool to compile Starknet contracts.

Positional arguments

file

File names.

Optional arguments

-h, --help

Show this help message and exit.

--abi ABI

Output the contract’s ABI.

--disable_hint_validation

Disable the hint validation.

--account_contract

Compile as account contract.

--dont_filter_identifiers

Disable the filter-identifiers-optimization.If True, all the identifiers will be kept, instead of just the ones mentioned in hints or 'with_attr' statements.

-v, --version

show program’s version number and exit

--prime PRIME

The size of the finite field.

--cairo_path CAIRO_PATH

A list of directories, separated by ":" to resolve import paths. The full list will consist of directories defined by this argument, followed by the environment variable CAIRO_PATH, the working directory and the standard library path.

--preprocess

Stop after the preprocessor step and output the preprocessed program.

--output OUTPUT

The output file name (default: stdout).

--no_debug_info

Don’t include debug information in the compiled file.

--debug_info_with_source

Include debug information with a copy of the source code.

--cairo_dependencies CAIRO_DEPENDENCIES

Output a list of the Cairo source files used during the compilation as a CMake file.

--no_opt_unused_functions

Disables unused function optimization.