Legacy compiler CLI reference

Last edit


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

starknet-compile --help


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]
                      [--cairo_dependencies CAIRO_DEPENDENCIES]
                      file [file ...]


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


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.


The contract’s ABI.

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


A tool to compile Starknet contracts.

Positional arguments


File names.

Optional arguments

-h, --help

Show this help message and exit.

--abi ABI

Output the contract’s ABI.


Disable the hint validation.


Compile as account contract.


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.


Stop after the preprocessor step and output the preprocessed program.

--output OUTPUT

The output file name (default: stdout).


Don’t include debug information in the compiled file.


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.


Disables unused function optimization.