Skip to main content

Local Devnet Overview

The local devnet is a private Cardano blockchain running on your machine, perfect for rapid development and testing.

Why Local Devnet?

AspectLocal DevnetPublic Testnet
Block Time100ms - 1s (configurable)~20 seconds
ADA SupplyUnlimited (faucet)Limited (request from faucet)
Network LatencyZeroVariable
PrivacyCompletePublic
AvailabilityAlways (your machine)Depends on network

Architecture

┌──────────────────────────────────────────────────────┐
│ Your Application │
└────────────────────────┬─────────────────────────────┘


┌──────────────────────────────────────────────────────┐
│ Cardano DevKit │
│ ┌─────────────┐ ┌───────────────┐ ┌────────────┐ │
│ │ DevKit API │ │ DevnetManager │ │ React Hooks│ │
│ └─────────────┘ └───────────────┘ └────────────┘ │
└────────────────────────┬─────────────────────────────┘
│ HTTP/WebSocket

┌──────────────────────────────────────────────────────┐
│ Local Devnet (Docker) │
│ ┌─────────────┐ ┌───────────────┐ ┌────────────┐ │
│ │ Cardano Node│ │ Indexer API │ │ Explorer │ │
│ │ (Producer) │ │ (Blockfrost) │ │ (Web UI) │ │
│ └─────────────┘ └───────────────┘ └────────────┘ │
└──────────────────────────────────────────────────────┘

Components

Cardano Node

  • Full cardano-node in block-producer mode
  • Configurable block time (100ms minimum)
  • Genesis with pre-funded addresses

Indexer API

  • Blockfrost-compatible REST API
  • SQLite storage for persistence
  • WebSocket for real-time subscriptions
  • Built-in faucet endpoint

Block Explorer

  • Web UI to explore transactions
  • Real-time block updates
  • Address and transaction search

Quick Start

# Start with fast blocks
npx cardano-devkit start --block-time 200

# Check status
npx cardano-devkit status

# View current tip
npx cardano-devkit tip

# Stop devnet
npx cardano-devkit stop

Configuration Options

OptionDefaultDescription
--port8080API port
--block-time1000Block time in milliseconds
--websockettrueEnable WebSocket subscriptions
--explorer-port8081Block explorer port

Programmatic Usage

import { createDevnetManager } from 'cardano-devkit';

const devnet = createDevnetManager({
port: 8080,
blockTimeMs: 200,
enableWebSocket: true
});

// Start devnet
await devnet.start();

// Get chain tip
const tip = await devnet.getTip();
console.log('Current slot:', tip.slot);
console.log('Block height:', tip.height);

// Fund an address
await devnet.topup(address, 1000_000_000n);

// Stop devnet
await devnet.stop();

Data Persistence

By default, the devnet resets on restart. To persist data:

# Start with persistence
npx cardano-devkit start --persist

# Reset persisted data
npx cardano-devkit reset

Next Steps