Quickstart

Make a contract call from your frontend application.

You will learn how to:

  • Install clarinet
  • Generate a new project with the clarinet CLI
  • Create a smart with Clarity
  • Verify and debug your code in your terminal

Install clarinet

Let's build a very simple hello-world project to demonstrate how easy it is to get started building on Stacks.

First, let's make sure we've installed clarinet so that we can use the command line tools.

Terminal
brew install clarinet

Create a new hello-world project

Now let's create a hello-world project. This will scaffold all the necessary files and directories for us to get started.

Terminal
clarinet new hello-world

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.

Terminal
cd hello-world
clarinet contract new 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".

say-hello.clar
(define-read-only (say-hi)
  (print "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.

Terminal
clarinet check
 1 contract checked

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.

More resources

Last updated on