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.

Starting your local blockchain

Launch devnet with all required services:

clarinet devnet start

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

--package <path>

Load a packaged devnet configuration

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 for you:

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

Configuration and customization

Devnet behavior is controlled by configuration files in your project.

Basic configuration

settings/Devnet.toml defines network settings:

Port configuration

Avoid local conflicts by customizing ports:

Mining intervals

Control block production speed:

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

Test different Stacks versions:

Custom node/signer images

Clarinet runs Devnet with specific tags for each Docker image. For example, Clarinet v3.10.0 uses the following images:

  • stacks node: blockstack/stacks-blockchain:3.3.0.0.1-alpine

  • stacks signer: blockstack/stacks-signer:3.3.0.0.1.0-alpine

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.

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:

Build an image locally and use it
  • Clone the stacks-core repository (or a fork) and checkout the desired branch.

  • Build the Docker image stacks-node:local:

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

  • Set the image to be used:

  • Then start Devnet:

Package deployment

Create reusable devnet configurations:

Use a packaged configuration:

Common issues

Docker connection errors — “clarinet was unable to create network”

Follow these steps to fix Docker connection issues:

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”

Error: "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:

Terminal

Solution 3 - Full cleanup and restart:

Terminal

This ensures a clean Docker environment for devnet to start fresh.

Contract deployment failures

Ensure dependencies deploy first in Clarinet.toml:

Validate contracts before deployment:

Check logs:

Deploy manually if needed:


Additional Resources

  • [Hiro Blog] 5 Ways to Interact With Devnet in the Hiro Platform

Last updated

Was this helpful?