Skip to main content

CLI Reference

Common flags​

--no-color​

Disable colors.

-p --profile STRING​

Specifies active configuration profile defined in the configuration file.

-v --version​

Show Protostar, Cairo-lang and Cairo 1 compiler versions.

Commands​

build​

$ protostar build

Compile Cairo 1 contracts.

--compiled-contracts-dir PATH=build​

An output directory used to put the compiled contracts in.

--contract-name STRING​

Specify a contract name that should be built.

--json​

Print machine-readable output in NDJSON format.

build-cairo0​

$ protostar build-cairo0

Compile Cairo 0 contracts.

--cairo-path PATH[]​

Additional directories to look for sources.

--compiled-contracts-dir PATH=build​

An output directory used to put the compiled contracts in.

--contract-name STRING​

Specify a contract name that should be built.

--disable-hint-validation​

Disable validation of hints when building the contracts.

--json​

Print machine-readable output in NDJSON format.

cairo-migrate​

Migrate project sources to Cairo 0.10.

targets STRING[]=['.']​

Targets to migrate (a target can be a file or directory)

calculate-account-address​

In order to create an account, you need to prefund the account. To prefund the account, you need to know its address. This command calculates the account address.

--account-address-salt INT​

Required.

An arbitrary value used to determine the address of the new contract.

--account-class-hash CLASS_HASH​

Required.

Class hash of the declared account contract.

--account-constructor-input INT[]​

Input to the account's constructor.

--json​

Print machine-readable output in NDJSON format.

call​

Call a contract on Starknet with given parameters

--abi PATH​

Path to the ABI file to be used by Data Transformer. If not provided, Protostar will get the ABI from Starknet.

--chain-id INT​

The chain id. It is required unless --network is provided.

--contract-address ADDRESS​

Required.

The address of the contract being called in hex (prefixed with '0x') or decimal representation.

--function STRING​

Required.

The name of the function being called.

--gateway-url STRING​

The URL of a Starknet gateway. It is required unless --network is provided.

-i --inputs INPUT[]​

Inputs to the constructor, represented either by a list of space-delimited values (1 2 3) or by a mapping of their names to their values (a=11 b=12 c=13). Calldata arguments may be of any type that does not contain pointers. Read more about representing Cairo data types in the CLI.

--json​

Print machine-readable output in NDJSON format.

-n --network STRING​

The name of the Starknet network. It is required unless --gateway-url is provided.

Supported Starknet networks:

  • testnet
  • mainnet
  • testnet2

declare​

Send a declare transaction of Cairo 1 contract to Starknet.

contract STRING​

Required.

Name of the contract defined in the protostar.toml

--account-address ADDRESS​

Required.

Account address in hex (prefixed with '0x') or decimal representation.

--block-explorer BLOCK_EXPLORER​

Generated links will point to that block explorer. Available values:

  • starkscan
  • viewblock
  • voyager

--chain-id INT​

The chain id. It is required unless --network is provided.

--gateway-url STRING​

The URL of a Starknet gateway. It is required unless --network is provided.

--json​

Print machine-readable output in NDJSON format.

--max-fee FEE​

Required.

The maximum fee that the sender is willing to pay for the transaction. Provide "auto" to auto estimate the fee.

-n --network STRING​

The name of the Starknet network. It is required unless --gateway-url is provided.

Supported Starknet networks:

  • testnet
  • mainnet
  • testnet2

--private-key-path PATH​

Path to the file, which stores your private key for the account in hex (prefixed with '0x') or decimal representation. Can be used instead of PROTOSTAR_ACCOUNT_PRIVATE_KEY env variable.

--signer-class STRING​

Custom signer class module path.

--token STRING​

Used by whitelisted users for deploying contracts in Alpha MainNet.

--wait-for-acceptance​

Wait for the transaction to be accepted on chain.

declare-cairo0​

Send a declare transaction of Cairo 0 contract to Starknet.

contract PATH​

Required.

Path to compiled contract.

--account-address ADDRESS​

Required.

Account address in hex (prefixed with '0x') or decimal representation.

--block-explorer BLOCK_EXPLORER​

Generated links will point to that block explorer. Available values:

  • starkscan
  • viewblock
  • voyager

--chain-id INT​

The chain id. It is required unless --network is provided.

--gateway-url STRING​

The URL of a Starknet gateway. It is required unless --network is provided.

--json​

Print machine-readable output in NDJSON format.

--max-fee FEE​

Required.

The maximum fee that the sender is willing to pay for the transaction. Provide "auto" to auto estimate the fee.

-n --network STRING​

The name of the Starknet network. It is required unless --gateway-url is provided.

Supported Starknet networks:

  • testnet
  • mainnet
  • testnet2

--private-key-path PATH​

Path to the file, which stores your private key for the account in hex (prefixed with '0x') or decimal representation. Can be used instead of PROTOSTAR_ACCOUNT_PRIVATE_KEY env variable.

--signer-class STRING​

Custom signer class module path.

--token STRING​

Used by whitelisted users for deploying contracts in Alpha MainNet.

--wait-for-acceptance​

Wait for the transaction to be accepted on chain.

deploy​

protostar deploy 0x4221deadbeef123 --network testnet

Deploy contracts.

class-hash CLASS_HASH​

Required.

The hash of the declared contract class.

--account-address ADDRESS​

Required.

Account address in hex (prefixed with '0x') or decimal representation.

--block-explorer BLOCK_EXPLORER​

Generated links will point to that block explorer. Available values:

  • starkscan
  • viewblock
  • voyager

--chain-id INT​

The chain id. It is required unless --network is provided.

--gateway-url STRING​

The URL of a Starknet gateway. It is required unless --network is provided.

-i --inputs INPUT[]​

Inputs to the constructor, represented either by a list of space-delimited values (1 2 3) or by a mapping of their names to their values (a=11 b=12 c=13). Calldata arguments may be of any type that does not contain pointers. Read more about representing Cairo data types in the CLI.

--json​

Print machine-readable output in NDJSON format.

--max-fee FEE​

Required.

The maximum fee that the sender is willing to pay for the transaction. Provide "auto" to auto estimate the fee.

-n --network STRING​

The name of the Starknet network. It is required unless --gateway-url is provided.

Supported Starknet networks:

  • testnet
  • mainnet
  • testnet2

--private-key-path PATH​

Path to the file, which stores your private key for the account in hex (prefixed with '0x') or decimal representation. Can be used instead of PROTOSTAR_ACCOUNT_PRIVATE_KEY env variable.

--salt FELT​

An optional salt controlling where the contract will be deployed. The contract deployment address is determined by the hash of contract, salt and caller. If the salt is not supplied, the contract will be deployed with a random salt.

--signer-class STRING​

Custom signer class module path.

--token STRING​

Used by whitelisted users for deploying contracts in Alpha MainNet.

--wait-for-acceptance​

Wait for the transaction to be accepted on chain.

deploy-account​

Send a deploy-account transaction. The account contract must be already declared and prefunded.

--account-address-salt INT​

Required.

An arbitrary value used to determine the address of the new contract.

--account-class-hash CLASS_HASH​

Required.

Class hash of the declared account contract.

--account-constructor-input INT[]​

Input to the account's constructor.

--chain-id INT​

The chain id. It is required unless --network is provided.

--gateway-url STRING​

The URL of a Starknet gateway. It is required unless --network is provided.

--json​

Print machine-readable output in NDJSON format.

--max-fee WEI​

Required.

Max amount of Wei you are willing to pay for the transaction

-n --network STRING​

The name of the Starknet network. It is required unless --gateway-url is provided.

Supported Starknet networks:

  • testnet
  • mainnet
  • testnet2

--nonce INT​

Protects against the replay attacks.

--private-key-path PATH​

Path to the file, which stores your private key for the account in hex (prefixed with '0x') or decimal representation. Can be used instead of PROTOSTAR_ACCOUNT_PRIVATE_KEY env variable.

--signer-class STRING​

Custom signer class module path.

format​

$ protostar format

Format Cairo source code.

target STRING[]=['.']​

Target to format; can be a file or a directory.

-c --check​

Run in 'check' mode. Exits with 0 if input is formatted correctly.Exits with 1 if formatting is required.

--ignore-broken​

Ignore broken files.

--verbose​

Log information about already formatted files as well.

init​

$ protostar init

Create a Protostar project with Cairo 1 template.

name STRING​

The name of the directory a new project will be placed in.

--minimal​

Create a minimal project structure.

init-cairo0​

$ protostar init-cairo0

Create a Protostar project with Cairo 0 template.

name STRING​

Name of the directory a new project will be placed in.Ignored when --existing is passed.

--existing​

Adapt current directory to a Protostar project.

install​

$ protostar install https://github.com/OpenZeppelin/cairo-contracts

Install a dependency as a git submodule.

package STRING​

  • GITHUB_ACCOUNT_NAME/REPO_NAME[@TAG]
    • OpenZeppelin/cairo-contracts@v0.4.0
  • URL_TO_THE_REPOSITORY
    • https://github.com/OpenZeppelin/cairo-contracts
  • SSH_URI
    • git@github.com:OpenZeppelin/cairo-contracts.git

--lib-path PATH​

Directory containing project dependencies. This argument is used with the configuration file V2.

--name STRING​

A custom package name. Use it to resolve name conflicts.

invoke​

Sends an invoke transaction to the Starknet sequencer.

--account-address ADDRESS​

Required.

Account address in hex (prefixed with '0x') or decimal representation.

--block-explorer BLOCK_EXPLORER​

Generated links will point to that block explorer. Available values:

  • starkscan
  • viewblock
  • voyager

--chain-id INT​

The chain id. It is required unless --network is provided.

--contract-address ADDRESS​

Required.

The address of the contract being called in hex (prefixed with '0x') or decimal representation.

--function STRING​

Required.

The name of the function being called.

--gateway-url STRING​

The URL of a Starknet gateway. It is required unless --network is provided.

-i --inputs INPUT[]​

Inputs to the constructor, represented either by a list of space-delimited values (1 2 3) or by a mapping of their names to their values (a=11 b=12 c=13). Calldata arguments may be of any type that does not contain pointers. Read more about representing Cairo data types in the CLI.

--json​

Print machine-readable output in NDJSON format.

--max-fee FEE​

Required.

The maximum fee that the sender is willing to pay for the transaction. Provide "auto" to auto estimate the fee.

-n --network STRING​

The name of the Starknet network. It is required unless --gateway-url is provided.

Supported Starknet networks:

  • testnet
  • mainnet
  • testnet2

--private-key-path PATH​

Path to the file, which stores your private key for the account in hex (prefixed with '0x') or decimal representation. Can be used instead of PROTOSTAR_ACCOUNT_PRIVATE_KEY env variable.

--signer-class STRING​

Custom signer class module path.

--wait-for-acceptance​

Wait for the transaction to be accepted on chain.

migrate-configuration-file​

Migrate protostar.toml V1 to V2.

multicall​

Execute multiple deploy (via UDC) or invoke calls in a single transaction ensuring atomicity.

file PATH​

Required.

Path to a TOML file with call declarations. File example:

[[call]]
# defines an contract address identifier
id = "my_contract"
type = "deploy"
class-hash = CONTRACT_CLASS_HASH
inputs = []

[[call]]
type = "invoke"
function = "increase_balance"

# contract-address accepts a contract address or an identifier
contract-address = "$my_contract"

# calldata accepts felts or identifiers
inputs = [42]

--account-address ADDRESS​

Required.

Account address in hex (prefixed with '0x') or decimal representation.

--block-explorer BLOCK_EXPLORER​

Generated links will point to that block explorer. Available values:

  • starkscan
  • viewblock
  • voyager

--chain-id INT​

The chain id. It is required unless --network is provided.

--gateway-url STRING​

The URL of a Starknet gateway. It is required unless --network is provided.

--json​

Print machine-readable output in NDJSON format.

--max-fee FEE​

Required.

The maximum fee that the sender is willing to pay for the transaction. Provide "auto" to auto estimate the fee.

-n --network STRING​

The name of the Starknet network. It is required unless --gateway-url is provided.

Supported Starknet networks:

  • testnet
  • mainnet
  • testnet2

--private-key-path PATH​

Path to the file, which stores your private key for the account in hex (prefixed with '0x') or decimal representation. Can be used instead of PROTOSTAR_ACCOUNT_PRIVATE_KEY env variable.

--signer-class STRING​

Custom signer class module path.

remove​

$ protostar remove cairo-contracts

Remove a dependency.

package STRING​

Required.

  • GITHUB_ACCOUNT_NAME/REPO_NAME[@TAG]
    • OpenZeppelin/cairo-contracts@v0.4.0
  • URL_TO_THE_REPOSITORY
    • https://github.com/OpenZeppelin/cairo-contracts
  • SSH_URI
    • git@github.com:OpenZeppelin/cairo-contracts.git
  • PACKAGE_DIRECTORY_NAME
    • cairo_contracts, if the package location is lib/cairo_contracts

--lib-path PATH​

Directory containing project dependencies. This argument is used with the configuration file V2.

test​

$ protostar test

Executes tests using Cairo 1 runner.

target STRING[]=['.']​

A glob or globs to a directory or a test suite, for example:

  • tests/**/*_main*::*_balance — find test cases, which names ends with _balance in test suites with the _main in filenames in the tests directory,
  • ::test_increase_balance — find test_increase_balance test_cases in any test suite within the project.

-x --exit-first​

Exit immediately on first broken or failed test.

-i --ignore STRING[]​

A glob or globs to a directory or a test suite, which should be ignored.

--json​

Print machine-readable output in NDJSON format.

-lf --last-failed​

Only re-run failed and broken test cases.

--no-progress-bar​

Disable progress bar.

--report-slowest-tests INT​

Print the slowest tests at the end.

test-cairo0​

$ protostar test-cairo0

Execute tests with cairo0 runner (legacy).

target STRING[]=['.']​

A glob or globs to a directory or a test suite, for example:

  • tests/**/*_main*::*_balance — find test cases, which names ends with _balance in test suites with the _main in filenames in the tests directory,
  • ::test_increase_balance — find test_increase_balance test_cases in any test suite within the project.

--cairo-path PATH[]​

Additional directories to look for sources.

--disable-hint-validation​

Disable hint validation in contracts declared by the declare cheatcode or deployed by deploy_contract cheatcode.

--estimate-gas​

Show gas estimation for each test case. Estimations might be inaccurate.

-x --exit-first​

Exit immediately on first broken or failed test.

-i --ignore STRING[]​

A glob or globs to a directory or a test suite, which should be ignored.

--json​

Print machine-readable output in NDJSON format.

-lf --last-failed​

Only re-run failed and broken test cases.

--max-steps INT​

Set Cairo execution step limit.

--no-progress-bar​

Disable progress bar.

--report-slowest-tests INT​

Print the slowest tests at the end.

--safe-collecting​

Use Cairo compiler for test collection.

--seed INT​

Set a seed to use for all fuzz tests.

update​

$ protostar update cairo-contracts

Update a dependency or dependencies. If the default branch of a dependency's repository uses tags, Protostar will pull a commit marked with the newest tag. Otherwise, Protostar will pull a recent commit from the default branch.

package STRING​

  • GITHUB_ACCOUNT_NAME/REPO_NAME[@TAG]
    • OpenZeppelin/cairo-contracts@v0.4.0
  • URL_TO_THE_REPOSITORY
    • https://github.com/OpenZeppelin/cairo-contracts
  • SSH_URI
    • git@github.com:OpenZeppelin/cairo-contracts.git
  • PACKAGE_DIRECTORY_NAME
    • cairo_contracts, if the package location is lib/cairo_contracts

--lib-path PATH​

Directory containing project dependencies. This argument is used with the configuration file V2.

upgrade​

$ protostar upgrade

Upgrade Protostar.