Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Local Blockchain Development

Clarinet ships with a complete local blockchain environment so you can build, test, and debug smart contracts without deploying to a public network. This environment is called Devnet.

What is Devnet?
  • Devnet is a local blockchain development environment in which your smart contracts and front-end application can interact with simulated blockchain entities.

  • With Devnet, your smart contract application can interact with simulated blockchain entities (miners, nodes, and a stream of mined blocks), all within your local machine.

  • The entities Devnet simulates (other contracts, transactions, or nodes) resemble the conditions your application will meet in production.

  • Devnet lets you create different blockchain configurations.

  • You can share a simnet environment with other devs and collaborate with them.

  • You can start 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.

Starting your local blockchain

Launch Devnet with all required services:

Useful flags:

Option
Description

--manifest-path <path>

Use an alternate Clarinet.toml

--no-dashboard

Stream logs instead of showing the interactive UI

--deployment-plan-path <path>

Apply a specific deployment plan

--use-on-disk-deployment-plan

Use an existing plan without recomputing

--use-computed-deployment-plan

Recompute and overwrite the plan

--from-genesis

Skip the embedded Epoch 4.0 snapshot and boot from genesis, walking through every epoch

--create-new-snapshot

Boot from genesis and save a new global snapshot after the first Epoch 4.0 Stacks block

Prerequisites

Devnet requires Docker. If you see "clarinet was unable to create network," ensure Docker Desktop is running or the Docker daemon is started.

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.

Core services and features

Devnet starts these services:

Service
Port
Purpose

Stacks node

20443

Processes transactions and mines blocks

Bitcoin node

18443

Provides block anchoring in regtest mode

Stacks API

3999

REST API for blockchain data

Postgres

5432

Indexes blockchain data

Stacks Explorer

8000

Browse transactions in a web UI

Bitcoin Explorer

8001

View the Bitcoin regtest chain

Devnet includes pre-funded accounts:

When Devnet starts, it automatically deploys your project contracts so you can interact with them immediately.

Configuration and customization

Configuration files in your project control Devnet behavior.

Basic configuration

settings/Devnet.toml defines network settings:

Port configuration

Avoid local conflicts by customizing ports:

Mining intervals

Control block production speed. Set the key once; the commented lines show other values:

Custom accounts

Add accounts with specific balances:

Accessing services

Devnet exposes several ways to interact with the blockchain.

Stacks Explorer

Visit the explorer to browse transactions, blocks, contract state, and account balances:

API endpoints

Query blockchain data with the Stacks API:

Common endpoints:

  • /v2/info: network information

  • /v2/accounts/{address}: account details

  • /v2/contracts/source/{address}/{name}: contract source code

  • /extended/v1/tx/{txid}: transaction details

Direct RPC

Submit transactions directly to the Stacks node:

Useful RPC endpoints:

  • /v2/transactions: broadcast transactions

  • /v2/contracts/call-read: read-only contract calls

  • /v2/fees/transfer: fee estimates for STX transfers

Advanced configuration

Performance optimization

For faster development cycles:

Epoch configuration

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.

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.

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.

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.

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.

Custom node/signer images

Clarinet runs Devnet with a pinned tag for each Docker image. Clarinet v3.24.1 uses:

  • stacks node: ghcr.io/stacks-network/stacks-core:4.0.1-alpine

  • stacks signer: ghcr.io/stacks-network/stacks-signer:4.0.1-alpine

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.

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

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.

Build an image locally and use it
  • Clone the stacks-core repository (or a fork) and check out the release tag or branch you want to test.

  • Build the Docker image stacks-node:local:

  • Clarinet needs the image in a registry. You can host a local one and push the image to it:

  • Set the image:

  • Then start Devnet:

Common issues

Docker connection errors: "clarinet was unable to create network"
  • 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.

Verify Docker status:

Port already in use: "bind: address already in use"

Find and stop the conflicting process (macOS/Linux):

Windows equivalent:

Or update ports in settings/Devnet.toml:

High resource usage (slow performance, high CPU or memory)

Optimizations:

Set Docker resource limits:

Clean up old data:

Network already exists: "network with name `.devnet` already exists"

Remove the orphaned network:

If you're unsure of the name:

Prevent the issue by stopping Devnet with Ctrl+C and pruning orphaned networks:

Docker stream error during startup: "Fatal: unable to create image: Docker stream error"

This error often occurs when Docker images are corrupted or when explorers fail to start properly.

Solution 1: Disable explorers

If you don't need the web explorers, disable them in settings/Devnet.toml:

Solution 2: Clean Docker environment

Remove all containers and images, then restart:

Solution 3: Full cleanup and restart

Contract deployment failures

Ensure dependencies deploy first in Clarinet.toml:

Validate contracts before deployment:

Check logs:

Deploy manually if needed:

Epoch settings have no effect

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.


Last updated

Was this helpful?