You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e503efd
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/build/clarinet/local-blockchain-development.md
+78-43Lines changed: 78 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Clarinet ships with a complete local blockchain environment so you can build, te
10
10
11
11
* A devnet refers to a local blockchain development environment in which your smart contracts and front end application can interact with simulated blockchain entities.
12
12
* With a devnet, your smart contract application can interact with simulated blockchain entities (miners, nodes, and a stream of mined blocks), all within your local machine.
13
-
* When devnets simulate a blockchain environment, the entities created—the other contracts, transactions, or nodes—resemble the conditions your application will inhabit once in production.
13
+
* When devnets simulate a blockchain environment, the entities created (the other contracts, transactions, or nodes) resemble the conditions your application will inhabit once in production.
14
14
* Devnets enable you to create different blockchain configurations.
15
15
* You can share a simnet environment with other devs and collaborate with them.
16
16
* You can start a devnet at an arbitrary block height with a specified network upgrade at a later block, and with many simulated users, to see how your application responds.
|`--manifest-path <path>`| Use an alternate `Clarinet.toml`|
33
+
|`--no-dashboard`| Stream logs instead of showing the interactive UI |
34
+
|`--deployment-plan-path <path>`| Apply a specific deployment plan |
35
+
|`--use-on-disk-deployment-plan`| Use an existing plan without recomputing |
36
+
|`--use-computed-deployment-plan`| Recompute and overwrite the plan |
37
+
|`--package <path>`| Load a packaged devnet configuration |
38
+
|`--from-genesis`| Skip the embedded Epoch 4.0 snapshot and boot from genesis, walking through every epoch |
39
+
|`--create-new-snapshot`| Boot from genesis and save a new global snapshot after the first Epoch 4.0 Stacks block |
38
40
39
41
{% hint style="info" %}
40
42
Prerequisites
41
43
42
-
Devnet requires Docker. If you see “clarinet was unable to create network,” ensure Docker Desktop is running or the Docker daemon is started.
44
+
Devnet requires Docker. If you see "clarinet was unable to create network," ensure Docker Desktop is running or the Docker daemon is started.
43
45
{% endhint %}
44
46
45
47
By default the dashboard displays service health, recent transactions, block production, contract deployments, and resource usage. Use `--no-dashboard` in CI or when you prefer streaming logs.
*`/v2/fees/transfer`: fee estimates for STX transfers
190
192
191
193
## Advanced configuration
192
194
@@ -207,53 +209,75 @@ disable_stacks_api = false
207
209
208
210
### Epoch configuration
209
211
210
-
Test different Stacks versions:
212
+
Devnet activates each Stacks epoch at a Bitcoin block height set under `[devnet]` in `settings/Devnet.toml`. These are the Clarinet v3.24.1 defaults; a key you leave out takes the default.
211
213
212
214
```toml
213
-
[epochs]
214
-
epoch_2_0 = 0# Stacks 2.0 from genesis
215
-
epoch_2_05 = 0# Stacks 2.05 from genesis
216
-
epoch_2_1 = 0# Stacks 2.1 from genesis
217
-
epoch_2_2 = 0# Pox-2 from genesis
218
-
epoch_2_3 = 0# Pox-3 from genesis
219
-
epoch_2_4 = 0# Pox-4 from genesis
220
-
epoch_3_0 = 101# Nakamoto activation at block 101
215
+
[devnet]
216
+
epoch_2_0 = 100
217
+
epoch_2_05 = 100
218
+
epoch_2_1 = 101
219
+
epoch_2_2 = 102
220
+
epoch_2_3 = 103
221
+
epoch_2_4 = 104
222
+
epoch_2_5 = 108
223
+
epoch_3_0 = 142# Nakamoto
224
+
epoch_3_1 = 144
225
+
epoch_3_2 = 146
226
+
epoch_3_3 = 148
227
+
epoch_3_4 = 150
228
+
epoch_4_0 = 162# PoX-5 and Clarity 6
221
229
```
222
230
231
+
Devnet's PoX cycle is 20 Bitcoin blocks long with a 5-block prepare phase, starting at block 100. `epoch_3_0` has to fall inside a reward phase; Clarinet refuses to start otherwise and names the offending height in the error.
232
+
233
+
By default `clarinet devnet start` restores an embedded snapshot taken after the first Epoch 4.0 Stacks block, so the chain is in Epoch 4.0 with `pox-5` deployed as soon as the dashboard shows the network ready. Changing any `epoch_*` height makes the snapshot unusable; Clarinet prints which fields differ from the snapshot and boots from genesis instead, which takes longer because every epoch transition is mined live. `--from-genesis` forces that path without editing the file.
234
+
235
+
To test against PoX-5 on Devnet, keep the defaults. To test a contract's behavior across an epoch boundary, raise `epoch_4_0` so the contract deploys before it, then watch the transition in the `--no-dashboard` logs.
236
+
237
+
{% hint style="info" %}
238
+
Devnet accounts carry an `sbtc_balance` next to `balance` in `settings/Devnet.toml` (1,000,000,000 sats for the generated wallets). Devnet funds each account's `sbtc_balance` on both snapshot and genesis boots, so sBTC-backed bond tests have a balance to draw on.
239
+
{% endhint %}
240
+
223
241
### Custom node/signer images
224
242
225
-
Clarinet runs Devnet with specific tags for each Docker image. For example, Clarinet v3.10.0 uses the following images:
243
+
Clarinet runs Devnet with a pinned tag for each Docker image. Clarinet v3.24.1 uses:
We recommend Devnet users let Clarinet handle it and use the default version. This ensures that your Clarinet version can handle and properly configure the images it uses.
248
+
Keep the defaults unless you are testing a node build. The Clarinet release pins the image that matches its epoch defaults; an older node image cannot reach `epoch_4_0`.
231
249
232
-
In some cases, you may need to use other images. Clarinet lets you do this by configuring it in `settings/Devnet.toml`. For example, if you don't want to run the `alpine` images:
250
+
To run other images, set `stacks_node_image_url` and `stacks_signer_image_url` under `[devnet]`in `settings/Devnet.toml`. This example runs the stacks-core 4.0.4 release in its Debian build, pinned by digest so the image cannot change under the same tag:
For the Alpine builds of the same release, use the `4.0.4-alpine` tags (`ghcr.io/stacks-network/stacks-core:4.0.4-alpine` and `ghcr.io/stacks-network/stacks-signer:4.0.4-alpine`).
268
+
269
+
Clarinet does not compare the image when it decides whether to restore its snapshot: the check covers the `epoch_*` heights, the signer keys and the stacking orders. A custom image therefore still starts from the snapshot embedded in the Clarinet release. Add `--from-genesis` to boot the custom image from genesis instead.
270
+
247
271
<details>
248
272
249
273
<summary>Build an image locally and use it</summary>
250
274
251
-
* Clone the stacks-core repository (or a fork) and checkout the desired branch.
275
+
* Clone the stacks-core repository (or a fork) and check out the release tag or branch you want to test.
<summary>Docker connection errors — “clarinet was unable to create network”</summary>
339
+
<summary>Docker connection errors: "clarinet was unable to create network"</summary>
316
340
317
341
Follow these steps to fix Docker connection issues:
318
342
319
-
Ensure Docker Desktop is running (macOS/Windows).Start the Docker daemon (sudo systemctl start docker) on Linux.Confirm permissions with docker ps.Reset Docker to factory defaults if problems persist.
343
+
* Ensure Docker Desktop is running (macOS/Windows).
344
+
* Start the Docker daemon (`sudo systemctl start docker`) on Linux.
345
+
* Confirm permissions with `docker ps`.
346
+
* Reset Docker to factory defaults if problems persist.
320
347
321
348
Verify Docker status:
322
349
@@ -329,7 +356,7 @@ docker ps
329
356
330
357
<details>
331
358
332
-
<summary>Port already in use — “bind: address already in use”</summary>
359
+
<summary>Port already in use: "bind: address already in use"</summary>
333
360
334
361
Find and stop the conflicting process (macOS/Linux):
335
362
@@ -385,7 +412,7 @@ rm -rf tmp/devnet
385
412
386
413
<details>
387
414
388
-
<summary>Network already exists — “network with name `.devnet` already exists”</summary>
415
+
<summary>Network already exists: "network with name `.devnet` already exists"</summary>
389
416
390
417
Remove the orphaned network:
391
418
@@ -410,7 +437,7 @@ docker network prune
410
437
411
438
<details>
412
439
413
-
<summary>Docker stream error during startup — “Fatal: unable to create image: Docker stream error”</summary>
440
+
<summary>Docker stream error during startup: "Fatal: unable to create image: Docker stream error"</summary>
414
441
415
442
**Error**: "Fatal: unable to create image: Docker stream error"
Older versions of this page showed the epoch keys in a top-level `[epochs]` table. Clarinet reads them only under `[devnet]`. Move the keys there and start Devnet again.
#The epoch running on mainnet, as pinned by your Clarinet release (default for new contracts)
74
76
epoch = "latest"
75
77
```
76
78
77
-
Using `"latest"` ensures your contracts always use the newest Clarity features and optimizations available in your version of Clarinet.
79
+
`"latest"` means the epoch active on mainnet, which Clarinet v3.24.1 pins to 4.0. It is not the newest epoch the Clarity VM knows about, so a contract marked `"latest"` deploys with the features mainnet has today.
80
+
81
+
The two keys depend on each other:
82
+
83
+
*`epoch` set, `clarity_version` omitted: Clarinet uses the default Clarity version for that epoch. Epoch 4.0 defaults to Clarity 6.
84
+
* Both omitted: Clarinet falls back to epoch 2.05 and Clarity 1, which rejects most current syntax. Set both.
85
+
*`clarity_version` newer than the epoch supports: `clarinet check` stops with `Clarity 6 can not be used with 3.4` (the message names your values).
86
+
87
+
A contract that calls `pox-5` or implements its `signer-manager-trait` needs `epoch = 4.0` or `"latest"`, because `pox-5` does not exist in earlier epochs; any `clarity_version` up to 6 compiles in that epoch. Pick Clarity 6 when the contract uses what Clarity 6 added: the `with-staking` and `with-pox` allowances for `restrict-assets?` and `as-contract?`, `get-bitcoin-tx-output?`, `verify-merkle-proof`, `ed25519-verify`, `secp256k1-decompress?`, or variadic `concat`. In Clarity 4 and 5 contracts the allowance keeps its old spelling, `with-stacking`; the `renamed_builtin` lint in `clarinet check` flags it once the contract's `clarity_version` is 6.
Copy file name to clipboardExpand all lines: docs/build/clarinet/simnet-only-code.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
description: Documentation and use cases for conditional code deployment with Clarinet
3
3
---
4
4
5
-
# Simnet-only code deployment
5
+
# Simnet-only code
6
6
7
7
Clarinet 3.17.0 introduced conditional code deployment, letting you write Clarity expressions that Clarinet only deploys in Simnet and never on-chain.
8
8
@@ -77,12 +77,20 @@ This feature only works at the tooling level, in Clarinet. If you deploy a contr
77
77
78
78
Smart contracts sometimes need to behave differently on testnet and mainnet. Simnet-only code deployment only covers Simnet vs "real-nets" (Devnet/Testnet/Mainnet). We may expand conditional deployments to more environments and conditions in the future, but we want to keep it simple for now.
79
79
80
-
If a smart contract needs different behavior on testnet vs mainnet, take a look at how the PoX contracts handle it (for example [pox-4](https://explorer.hiro.so/txid/SP000000000000000000002Q6VF78.pox-4?chain=mainnet&tab=sourceCode)) using`is-in-mainnet`:
80
+
If a smart contract needs different behavior on testnet and mainnet, look at how the PoX contracts handle it. `pox-5`, the contract deployed at `SP000000000000000000002Q6VF78.pox-5`, sets its cycle lengths with`is-in-mainnet`:
81
81
82
82
```clarity
83
-
;; Default length of the PoX registration window, in burnchain blocks.
`is-in-mainnet` is evaluated when the contract is deployed, so the same source gives mainnet a 2,100-block reward cycle with a 100-block prepare phase and testnet a 1,050-block cycle with a 50-block prepare phase. pox-5 uses the same keyword to pick the address version when it reconstructs a signer principal. Read the [deployed contract](https://explorer.hiro.so/txid/SP000000000000000000002Q6VF78.pox-5?chain=mainnet\&tab=sourceCode) or the [source at release 4.0.4](https://github.com/stacks-network/stacks-core/blob/4.0.4/stackslib/src/chainstate/stacks/boot/pox-5.clar#L356-L366).
0 commit comments