CLI Reference
The Clarinet CLI provides a comprehensive suite of tools for Clarity smart contract development. From project initialization to deployment, Clarinet streamlines your entire development workflow.
Create a new project:
clarinet newGenerate a new smart contract:
clarinet contracts newValidate contract syntax and types:
clarinet checkInteractive REPL for testing contracts:
clarinet consoleLaunch a local development network:
clarinet devnet startManage deployments:
clarinet deployments
Initialize a new project
clarinet new
clarinet new creates a new project with all necessary configuration files and directory structure.
Usage
clarinet new [OPTIONS] <NAME>$ clarinet new my-defi-protocol
Create directory my-defi-protocol
Create directory contracts
Create directory settings
Create directory tests
Create file Clarinet.toml
Create file settings/Mainnet.toml
Create file settings/Testnet.toml
Create file settings/Devnet.toml
Create directory .vscode
Create file .vscode/settings.json
Create file .vscode/tasks.json
Create file .gitignore
Create file .gitattributes
Create file package.json
Create file tsconfig.json
Create file vitest.config.js--disable-telemetry
Do not provide developer usage telemetry for this project
Manage your contracts
clarinet contracts
clarinet contracts is a subcommand for working with contracts. It has two subcommands:
new
Generate files and settings for a new contract
rm
Remove files and settings for a contract
Usage with new
Usage with rm
--manifest-path <path>
Path to Clarinet.toml
Validate your contracts
clarinet check
clarinet check checks contracts syntax and performs type checking.
Usage
--manifest-path <path>
-m
Path to Clarinet.toml
--deployment-plan-path <path>
-p
If specified, use this deployment file
--use-on-disk-deployment-plan
-d
Use on disk deployment plan (prevent updates computing)
--use-computed-deployment-plan
-c
Use computed deployment plan (will overwrite on disk version if any update)
--enable-clarity-wasm
Allow the Clarity Wasm preview to run in parallel with the Clarity interpreter (beta)
Interact with your contracts in a local REPL
clarinet console
clarinet console loads contracts in a REPL for an interactive session.
Usage
The Clarinet console offers a variety of commands for contract interaction:
::help: Lists all console commands::functions: Display all the native functions available in Clarity::keywords: Display all the native keywords available in Clarity::describe <function> | <keyword>: Display documentation for a given native function or keyword::toggle_costs: Display cost analysis after every expression::toggle_timings: Display the execution duration::mint_stx <principal> <amount>: Mint STX balance for a given principal::set_tx_sender <principal>: Set tx-sender variable to principal::get_assets_maps: Get assets maps for active accounts::get_contracts: Get contracts::get_block_height: Get current block height::advance_chain_tip <count>: Simulate mining of<count>blocks::advance_stacks_chain_tip <count>: Simulate mining of<count>stacks blocks::advance_burn_chain_tip <count>: Simulate mining of<count>burnchain blocks::set_epoch <epoch>: Update the current epoch::get_epoch: Get current epoch::debug <expr>: Start an interactive debug session executing<expr>::trace <expr>: Generate an execution trace for<expr>::get_costs <expr>: Display the cost analysis::reload: Reload the existing contract(s) in the session::read <filename>: Read expressions from a file::encode <expr>: Encode an expression to a Clarity Value bytes representation::decode <bytes>: Decode a Clarity Value bytes representation
--manifest-path <path>
-m
Path to Clarinet.toml
--deployment-plan-path <path>
-p
If specified, use this deployment file
--use-on-disk-deployment-plan
-d
Use on disk deployment plan (prevent updates computing)
--use-computed-deployment-plan
-c
Use computed deployment plan (will overwrite on disk version if any update)
--enable-remote-data
-r
Enable remote data fetching from mainnet or a testnet
--remote-data-api-url <url>
-a
Set a custom Stacks Blockchain API URL for remote data fetching
--remote-data-initial-height <height>
-b
Initial remote Stacks block height
--enable-clarity-wasm
Allow the Clarity Wasm preview to run in parallel with the Clarity interpreter (beta)
Start a local development network
clarinet devnet
clarinet devnet is a subcommand for working with Devnet. It has two subcommands:
start
Start a local Devnet network for interacting with your contracts
package
Generate package of all required devnet artifacts
Usage with start
--manifest-path <path>
-m
Path to Clarinet.toml
--no-dashboard
Display streams of logs instead of terminal UI dashboard
--deployment-plan-path <path>
-p
If specified, use this deployment file
--use-on-disk-deployment-plan
-d
Use on disk deployment plan (prevent updates computing)
--use-computed-deployment-plan
-c
Use computed deployment plan (will overwrite on disk version if any update)
--package <path>
Path to Package.json produced by 'clarinet devnet package'
Usage with package
--name <name>
-n
Output json file name
--manifest-path <path>
-m
Path to Clarinet.toml
Manage your deployments
clarinet deployments
clarinet deployments is a subcommand for managing deployments on Devnet/Testnet/Mainnet.
check
Check deployments format
generate
Generate new deployment
apply
Apply deployment
Usage with check
--manifest-path <path>
Path to Clarinet.toml
Usage with generate
--simnet
Generate a deployment file for simnet environments (console, tests)
--devnet
Generate a deployment file for devnet, using settings/Devnet.toml
--testnet
Generate a deployment file for testnet, using settings/Testnet.toml
--mainnet
Generate a deployment file for mainnet, using settings/Mainnet.toml
--manifest-path <path>
Path to Clarinet.toml
--no-batch
Generate a deployment file without trying to batch transactions (simnet only)
--low-cost
Compute and set cost, using low priority (network connection required)
--medium-cost
Compute and set cost, using medium priority (network connection required)
--high-cost
Compute and set cost, using high priority (network connection required)
--manual-cost
Leave cost estimation manual
Usage with apply
--devnet
Apply default deployment settings/default.devnet-plan.toml
--testnet
Apply default deployment settings/default.testnet-plan.toml
--mainnet
Apply default deployment settings/default.mainnet-plan.toml
--manifest-path <path>
-m
Path to Clarinet.toml
--deployment-plan-path <path>
-p
Apply deployment plan specified
--no-dashboard
Display streams of logs instead of terminal UI dashboard
--use-on-disk-deployment-plan
-d
Use on disk deployment plan (prevent updates computing)
--use-computed-deployment-plan
-c
Use computed deployment plan (will overwrite on disk version if any update)
Interact with Mainnet contracts
clarinet requirements
clarinet requirements is a subcommand for interacting with Mainnet contracts.
add
Add a mainnet contract as a dependency to your project
Usage
--manifest-path <path>
Path to Clarinet.toml
Editor Integrations
clarinet lsp
clarinet lsp starts the Language Server Protocol service for Clarity, enabling intelligent code completion, error highlighting, and other IDE features in supported editors.
Usage
Debugging
clarinet dap
clarinet dap starts the Debug Adapter Protocol service, enabling debugging features like breakpoints, step-through execution, and variable inspection in supported editors.
Usage
Format your code
clarinet format
clarinet format formats Clarity code files according to standard conventions.
Usage
--check
Check if code is formatted without modifying files
No
--dry-run
Only echo the result of formatting
No
--in-place
Replace the contents of a file with the formatted code
No
--manifest-path <path>
-m
Path to Clarinet.toml
No
--file <file>
-f
If specified, format only this file
No
--max-line-length <length>
-l
Maximum line length
No
--indent <size>
-i
Indentation size, e.g. 2
No
--tabs
-t
Use tabs instead of spaces
No
Utilities
clarinet completions
clarinet completions generates shell completion scripts for your shell.
Usage
Supported Shells
bashzshfishpowershellelvish
--shell <shell>
-s
Specify which shell to generation completions script for
Environment Variables
Clarinet supports environment variables for configuration. All environment variables are prefixed with CLARINET_:
Last updated
Was this helpful?
