Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Created file counter/.gitignore
Created directory counter/contracts
Created directory counter/tests
Created file counter/settings/Devnet.toml
Created file counter/settings/Mainnet.toml
Created file counter/settings/Mainnet.toml
Created file counter/settings/Testnet.toml
Created file counter/package.json
Created file counter/tsconfig.json
Expand Down Expand Up @@ -73,7 +73,7 @@ Your `Clarinet.toml` now includes:
[contracts.counter]
path = 'contracts/counter.clar'
clarity_version = 2
epoch = 2.5
epoch = "latest"
```

## Step 3: Write Your Smart Contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ Format with custom settings:
$ clarinet format -i 4 -l 120 --in-place
```

Check formatting in CI/CD pipelines:

```terminal
$ clarinet format --check
```

The `--check` flag validates that all Clarity files are properly formatted without modifying them. This is perfect for continuous integration workflows where you want to ensure code style consistency.

### Ignoring blocks of code

Prevent formatting of specific code blocks:
Expand All @@ -151,4 +159,4 @@ Prevent formatting of specific code blocks:
(define-constant something (list
1 2 3 ;; Preserves custom spacing
4 5 ))
```
```
6 changes: 4 additions & 2 deletions content/docs/tools/clarinet/(clarinet-cli)/cli-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,16 @@ $ clarinet format [OPTIONS]
```

```terminal
$ clarinet format --check
$ clarinet format --dry-run
$ clarinet format --file contracts/token.clar --in-place
```

| Option | Short | Description | Required |
|--------|-------|-------------|----------|
| `--dry-run` | | Only echo the result of formatting | Yes |
| `--in-place` | | Replace the contents of a file with the formatted code | Yes |
| `--check` | | Check if code is formatted without modifying files | No |
| `--dry-run` | | Only echo the result of formatting | No |
| `--in-place` | | Replace the contents of a file with the formatted code | No |
| `--manifest-path <path>` | `-m` | Path to Clarinet.toml | No |
| `--file <file>` | `-f` | If specified, format only this file | No |
| `--max-line-length <length>` | `-l` | Maximum line length | No |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
- uses: actions/checkout@v4
- name: Check Clarity contracts check
run: clarinet check --use-on-disk-deployment-plan
- name: Check Clarity contracts format
run: clarinet format --check
```

## Runtime analysis
Expand Down Expand Up @@ -142,7 +144,7 @@ $ continue
Debug navigation commands:
- `step` or `s` - Step into sub-expressions
- `finish` or `f` - Complete current expression
- `next` or `n` - Step over sub-expressions
- `next` or `n` - Step over sub-expressions
- `continue` or `c` - Continue to next breakpoint

### **Using `::get_costs` for analyzing specific function costs**
Expand Down Expand Up @@ -185,15 +187,15 @@ Master interactive debugging to quickly identify issues by starting a debugging
$ clarinet console
$ ::debug (contract-call? .counter count-up)
ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.counter:9:3
6
6
7 ;; Increment the count for the caller
8 (define-public (count-up)
-> 9 (ok (map-set counters tx-sender (+ (get-count tx-sender) u1)))
^
10 )
11
11
12 ;; Get the current count for a user
(debug)
(debug)
$ continue
```

Expand Down
22 changes: 18 additions & 4 deletions content/docs/tools/clarinet/(overview)/project-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ description = "A counter smart contract"
[contracts.traits]
path = "contracts/traits.clar"
clarity_version = 3
epoch = 3.1
epoch = "latest"

[contracts.counter]
path = 'contracts/counter.clar'
clarity_version = 3
epoch = 3.1
epoch = "latest"
```

The manifest handles several critical functions:
Expand All @@ -65,6 +65,20 @@ The manifest handles several critical functions:
- **Stacks Epoch and Clarity version**: Specifies Clarity version and epoch for each contract
- **Boot sequence**: Lists contracts to deploy on `clarinet devnet start`

### Epoch configuration

You can specify the epoch in two ways:

```toml
# Use a specific epoch version
epoch = 3.1

# Use the latest available epoch (default)
epoch = "latest"
```

Using `"latest"` ensures your contracts always use the newest Clarity features and optimizations available in your version of Clarinet.

## Testing infrastructure

### Package configuration
Expand Down Expand Up @@ -241,11 +255,11 @@ Never commit mainnet private keys or mnemonics. Use environment variables for pr
```toml Clarinet.toml
[contracts.token]
clarity_version = 3
epoch = 3.1 # !mark
epoch = "latest" # !mark

[contracts.pool]
clarity_version = 3
epoch = 3.1 # !mark
epoch = "latest" # !mark
```

Mismatched versions can cause deployment failures and unexpected behavior. Always upgrade all contracts together when moving to a new Clarity version.
Expand Down