Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE
Need a crash course on Bitcoin layers?
→ READ OUR FREE GUIDE

Writing Clarity Feels Better Than Ever: Try Clarinet 3.0

The latest release of Clarinet comes with the stabilization of 2 powerful features that enable you to automatically standardize the format of your Clarity contract code and simulate mainnet transactions in your local development environment. This release also includes breaking changes as Clarinet upgrades to Stacks.js v7. Let’s get into it.

Type
Product update
Topic(s)
Product
Hiro
Published
May 8, 2025
Author(s)
Sr. Software Engineer
Clarinet 3.0
Contents

Stabilizing 2 Major Features

Earlier in the spring, we announced two powerful new features in Clarinet: transaction simulation and the Clarity formatter. After collecting community feedback and many rounds of iteration, these features are now stable with this latest Clarinet release.

Transaction Simulation

With transaction simulation, you can test your code with mainnet data. This feature lets you pull real-world data directly into your unit tests in simnet, so you can test your code more confidently, knowing that how it interacts with data structures locally is the same way it will interact with data onchain.

This is a powerful feature if your code interacts with other contracts on mainnet, such as price feeds, or if your app logic uses onchain data from Bitcoin or PoX. For example, you can now verify a Bitcoin L1 transaction with a Clarity smart contract inside of Clarinet simnet.

Say goodbye to the painful process of generating mock data locally. 

Learn more about this feature in our documentation.

Clarity Formatter

The Clarity formatter helps you create cleaner, more readable code with an opinionated code formatter that can easily and automatically format your Clarity smart contracts. With this feature, you can focus on writing your code instead of fussing with its formatting.

A screenshot of some newly formatted Clarity code

This feature is available in both Clarinet and the VS Code extension. In VS Code, there are multiple ways to trigger code formatting. For instance, you can automatically format your code whenever it’s saved. This can be enabled/disabled globally or on a per-language basis.

You can edit the VSCode settings.json file to only enable (or disable) it for Clarity:


"[clarity]": {
  "editor.formatOnSave": true,
},

To learn more, check out VS Code documentation for setting formatting preferences globally or for a specific language, and view our Clarity formatter documentation.

Got strong opinions on code formatting? Probably. Disagree with some of our formatting decisions in this feature? Maybe. Let us know by adding your thoughts in this GitHub discussion.

Breaking Changes: Clarinet Upgrades to Stacks.js v7

Stacks.js v7 improved the way developers can interact with Clarity values in JavaScript by making the representations of Clarity values in JS more human-readable. We’ve now upgraded Clarinet to use Stacks.js v7, so you can take advantage of these human-readable values in your unit tests, which is particularly helpful when you need to interact with and parse raw Stacks.js values.

Note: this may be a breaking change for your project, particularly if you directly manipulate the Clarity values object representation in JS. If you’re impacted by this breaking change, TypeScript will tell you that something needs to be updated in your code.

To learn more about this breaking change, view Clarity representation as well as serialize methods.

How to Upgrade Clarinet

In a Clarinet project, run the following command to upgrade the clarinet-sdk and stacks.js versions to latest:


npm i @hirosystems/clarinet-sdk@3  @stacks/transactions@7

You will also need to update your CLI version of Clarinet (which you can do by running <code-rich-text>brew upgrade clarinet<code-rich-text>, <code-rich-text>winget upgrade clarinet<code-rich-text>, etc. depending on how you installed it). Alternatively, you can upgrade by re-installing from source. If you haven’t installed Clarinet yet, follow the instructions in our docs.

As a reminder, you can use Clarinet with the latest versions of Vite and Vitest, and you are responsible for keeping your dependencies up to date. We recommend using the Dependi extension for VS Code, which can help you keep your dependencies up to date.

If you have any feedback on this latest release, reach out to us on the #clarinet channel under Hiro developer tools on the Stacks Discord.

Product updates & dev resources straight to your inbox
Your Email is in an invalid format
Checkbox is required.
Thanks for
subscribing.
Oops! Something went wrong while submitting the form.
Copy link
Mailbox
Hiro news & product updates straight to your inbox
Only relevant communications. We promise we won’t spam.

Related stories