Quickstart
Setup your Clarity project with the Clarinet SDK in less than 2 minutes.
You will learn how to:
- Initialize a simulated blockchain environment
- Retrieve accounts
- Execute public functions of a smart contract in a simulated environment.
- Debug smart contract calls by examining return values in the console.
Initialize project
Before we get started using the SDK, let's first create a new Node project in our terminal.
Install necessary packages
Now that we have our project setup, let's install our required packages: @hirosystems/clarinet-sdk
and @stacks/transactions
.
Retrieving accounts on simnet
Now let's create a hello-world
project. This will scaffold all the necessary files and directories for us to get started.
Create a say-hello
contract
Now that our project has been generated we can start creating our first contract. Let's name this one say-hello
.
Create a read-only
function called say-hi
Now that we have our say-hello.clar
file generated, let's create a read-only
function that prints out "Hello World".
Verify your contracts
In order to verify that our code is valid, we can run clarinet check
inside of our project directory to ensure our say-hi
function is valid.
By default, the SDK will look for a Clarinet.toml
file in the current working directory.
It's also possible to provide the path to the manifest like so:
Next step: Add unit tests with the Clarinet SDK
The Clarinet SDK allows you to write unit tests for your Clarity smart contracts. You can theoretically use any JavaScript test framework, but the SDK supports Vitest out of the box.
Additional resources
Last updated on