Add a contract

Clarinet can handle adding a new contract and its configuration to your project

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

Terminal
clarinet contract new my-contract

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 may 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.

Last updated on