If you have create or imported a project with no Clarity contracts, you will see a window that prompts you to create a new contract or open a web (or local) editor.
To create a new contract, you can simply click the "Create contract" button which will create an empty contract in your project.
You can also create a new contract for your project from the editor by following the steps below. Note: the sample project used here is from Clarity examples, and these steps assume that your project has no Clarity contracts already.
Hiro offers a collection of Clarity smart
contracts
in the platform available for you to quickly extend and deploy. Or you can
write your own from scratch.
Click the "Open in Web Editor" button. If you want to do this locally, you first need to set up SSH.
This will open up a new tab with VS Code editor, and inside VS Code, you will find the project directories and files.
Expand "NEW-PROJECT" and see a directory named "contracts". There should be no contracts in this folder yet.
Right-click the contracts folder, select "New file", and add a new contract with a name of your choice. Eg: counter.clar
This will create a .clar file in the contracts folder. Now you can use the Clarity examples to customize your contract.
Once your .clar file is ready, you can update the Clarinet.toml file located in the same project directory. Use the following code to update the .toml file with these parameters. [contracts.<your-contract-name>] and path to use your .clar file name as path = "<your-contract-name.clar>".
Save the file. You can now deploy your contracts in your project by referring to the deploy project guide.
If you have a project that already has at least one Clarity contract, it's very easy to add more by following the same steps above. If you are using the editor, in the 6th step, where you edit the Clarinet.toml file, you will also add two lines of code, as shown below. Note that the below code assumes that the newly added contract is clarity_contract_2. You also need to add the path to your new contract as shown below.
You can customize, test, and debug your contracts using the VS Code terminal inside the Hiro Platform. On your projects page, select the "Open editor" button to open up the VS Code editor. Select the three horizontal lines icon to open a new terminal. Refer to the following documents to test your contracts in the VS Code terminal.