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 startUseful flags:
--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
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:
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:
::get_assets_maps
;; +-------------------------------------------+-----------------+
;; | Address | STX Balance |
;; |-------------------------------------------+-----------------|
;; | ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM | 100000000000000 |
;; | ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5 | 100000000000000 |
;; | ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG | 100000000000000 |
;; | ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC | 100000000000000 |
;; | ST2NEB84ASENDXKYGJPQW86YXQCEFEX2ZQPG87ND | 100000000000000 |
;; +-------------------------------------------+-----------------+When devnet starts it automatically deploys your project contracts so you can interact immediately.
$ clarinet devnet start
Deploying contracts...
Deploying counter.clar ✓ ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.counter
Deploying token.clar ✓ ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.token
Deploying marketplace.clar ✓ ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.marketplace
All contracts deployed successfullyConfiguration and customization
Devnet behavior is controlled by configuration files in your project.
Basic configuration
settings/Devnet.toml defines network settings:
[network]
name = "devnet"
# Service ports
stacks_node_rpc_port = 20443
stacks_api_port = 3999
stacks_explorer_port = 8000
bitcoin_node_rpc_port = 18443
[network.devnet]
bitcoin_controller_block_time = 30_000 # 30 seconds
disable_bitcoin_explorer = false
disable_stacks_explorer = false
disable_stacks_api = falsePort configuration
Avoid local conflicts by customizing ports:
stacks_node_rpc_port = 30443
stacks_api_port = 4999
postgres_port = 6432
stacks_explorer_port = 4020Mining intervals
Control block production speed:
bitcoin_controller_block_time = 1_000 # Fast development (1 second)
bitcoin_controller_block_time = 30_000 # Standard testing (30 seconds)
bitcoin_controller_block_time = 120_000 # Realistic timing (2 minutes)Custom accounts
Add accounts with specific balances:
[accounts.treasury]
mnemonic = "twice kind fence tip hidden tilt action fragile skin nothing glory cousin"
balance = 10_000_000_000_000
[accounts.alice]
mnemonic = "female adjust gallery certain visit token during great side clown fitness like"
balance = 5_000_000_000_000Accessing services
Devnet exposes several ways to interact with the blockchain.
Stacks Explorer
Visit the explorer to browse transactions, blocks, contract state, and account balances:
http://localhost:8000API endpoints
Query blockchain data with the Stacks API:
curl http://localhost:3999/v2/infoCommon 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:
curl -X POST http://localhost:20443/v2/transactions \
-H "Content-Type: application/json" \
-d @transaction.jsonUseful 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:
[network.devnet]
bitcoin_controller_block_time = 1_000
disable_bitcoin_explorer = true
disable_stacks_explorer = true
disable_stacks_api = falseEpoch configuration
Test different Stacks versions:
[epochs]
epoch_2_0 = 0 # Stacks 2.0 from genesis
epoch_2_05 = 0 # Stacks 2.05 from genesis
epoch_2_1 = 0 # Stacks 2.1 from genesis
epoch_2_2 = 0 # Pox-2 from genesis
epoch_2_3 = 0 # Pox-3 from genesis
epoch_2_4 = 0 # Pox-4 from genesis
epoch_3_0 = 101 # Nakamoto activation at block 101Package deployment
Create reusable devnet configurations:
$ clarinet devnet package --name demo-env
Packaging devnet configuration...
Created demo-env.jsonUse a packaged configuration:
$ clarinet devnet start --package demo-env.jsonCommon issues
Last updated
Was this helpful?
