Clarinet is a Clarity runtime packaged as a command line tool, designed to facilitate smart contract understanding, development, testing and deployment. Clarinet consists of a Clarity REPL and a testing harness, which, when used together allow you to rapidly develop and test a Clarity smart contract, with the need to deploy the contract to a local devnet or testnet.
Clarinet is a Clarity runtime packaged as a command-line tool designed to facilitate smart contract understanding, development, testing, and deployment. It serves as an essential utility for working with Clarity, the programming language for the Stacks blockchain and Bitcoin.
Key Features:
Clarity REPL (Read-Eval-Print Loop): Enables interactive exploration and debugging of Clarity smart contracts directly from the command line.
Testing Harness: Provides a robust framework to test Clarity smart contracts locally, ensuring reliability before deployment.
Cross-Chain Compatibility: Supports development for both the Stacks blockchain and Bitcoin, leveraging their unique capabilities.
Local Development: Allows rapid iteration without the need to deploy contracts to live networks during testing.
Winget Installation: Can be easily installed via winget, ensuring seamless setup across supported platforms.
Audience & Benefit:
Ideal for smart contract developers, auditors, and testers seeking a streamlined workflow for building high-quality Clarity-based applications. Clarinet empowers users to reduce errors, accelerate development cycles, and deploy secure, efficient contracts with confidence.
README
Clarinet
Clarinet is the fastest way to build, test, and deploy smart contracts on the Stacks blockchain. It
gives you a local devnet, REPL, testing framework, and debugging tools to ship high-quality Clarity
code with confidence.
๐งโ๐ป Leverage a powerful CLI Create new projects, manage your smart contracts and their
dependencies using clarinet requirements, and interact with your code through the built-in REPL.
๐งช Write unit tests with the SDK Use the Clarinet SDK to write unit tests in a familiar JS
environment and validate contract behavior.
๐ ๏ธ Run a private blockchain environment Spin up a local devnet with nodes, miners, and APIs so
you can test and integrate your code.
Contributions are welcome and appreciated. The following sections provide information on how you can
contribute to Clarinet.
Prerequisites
Before contributing to Clarinet, you need the following tools.
Although it will work with older versions, the team always tries to keep up with the latest versions
of Rust and Node.js (LTS) tooling.
This repo follows the Conventional Commit
specification when writing commit messages.
Note: These conventions are helpful for any commit message, but all PR end up being merged with
"squash and merge", giving an other chance to refine the commit messages.
To start contributing, fork this repo and open a new branc:
Fork this repo and clone the fork locally.
Create a new branch
git checkout -b
Contributing to the CLI
After making your changes, ensure the following:
cargo build runs successfully.
cargo tst runs successfully.
cargo tst is an alias declared in ./cargo/config, it runs
cargo-nextest
You have formatted your code with cargo fmt-stacks
All functional tests in the examples directory pass.
for testdir in $(ls examples); do
pushd examples/${testdir}
../../target/debug/clarinet check .
popd
done
Submit a pull request against the main branch for review.
Contributing to the JS SDK
For VSCode users, we recommend opening the following workspace
./components/clarinet-sdk/clarinet-sdk.code-workspace. It's set up so that rust-analyzer uses the
Wasm target.
The SDK is divided between the Rust lib compiled to Wasm ./components/clarinet-sdk-wasm and a TS
wrapper around it: ./components/clarinet-sdk-wasm.
Compile the Wasm package with npm run build:sdk-wasm