Add a contract

Clarinet can handle adding and configuring a new contract to your project.

To add a new contract, run the clarinet contract new command, along with your contract name, inside your project.

Terminal
clarinet contract new my-contract

Project structure

Clarinet will add 2 files to your project: my-contract.clar and my-contract.test.ts.

my-contract.clar
my-contract.test.ts
.gitignore
Clarinet.toml
package.json
tsconfig.json
vitest.config.js

Clarinet will also add the configuration to the Clarinet.toml file for your contract.

[contracts.my-contract]
path = 'contracts/my-contract.clar'
clarity_version = 2
epoch = 2.4
Adding contracts manually

You can also add contracts to your project by adding the files manually. However, you must add the appropriate configuration to Clarinet.toml in order for Clarinet to recognize the contracts.

On this page