Skip to main content

Cardano DevKit

All-in-one development toolkit for Cardano blockchain.

Cardano DevKit provides everything you need to build on Cardano with JavaScript, TypeScript, or React. Simply npm install cardano-devkit and you're ready to go!

Why Cardano DevKit?โ€‹

  • ๐Ÿš€ Instant Local Development - Start a local blockchain in seconds with sub-second blocks (100-200ms)
  • ๐Ÿ”„ Seamless Network Switching - Move from local โ†’ testnet โ†’ mainnet with one method call
  • โš›๏ธ React Ready - Built-in hooks for modern dApp development
  • ๐Ÿ› ๏ธ CLI Tools - 46+ commands for devnet, transactions, and project scaffolding
  • ๐Ÿ“ก Real-time Updates - WebSocket subscriptions for live blockchain events
  • ๐Ÿงช Built-in Faucet - Get test ADA instantly during development
  • ๐Ÿ’พ Production-Grade Indexer - SQLite-backed, Blockfrost-compatible API
  • ๐Ÿ”ง Developer Utilities - UTxO manager, transaction history, address book, simulator
  • ๐Ÿ“ฆ Project Scaffolding - 7 templates, 8 features for instant project setup
  • ๐Ÿ’ป Interactive Console - REPL for quick prototyping and debugging
  • ๐Ÿ—๏ธ Namespace Imports - Organized grouped imports for cleaner code
  • ๐Ÿ” Diagnostics & Debug - Runtime diagnostics and transaction tracing

Quick Startโ€‹

# Install
npm install cardano-devkit

# Start local devnet
npx cardano-devkit start

# Fund your wallet
npx cardano-devkit topup addr_test1...

# Create a new project with wizard
npx cardano-devkit init --wizard
import { createDevKit, createDevnetManager, WalletHelper } from 'cardano-devkit';
import { ADA, Transaction, Debug } from 'cardano-devkit/namespaces';

// Enable debug mode for development
Debug.enable({ level: 'debug', timestamps: true });

// Start local devnet with fast blocks
const devnet = createDevnetManager({ blockTimeMs: 200 });
await devnet.start();

// Connect to local network
const devKit = createDevKit({ network: 'LocalDevnet' });
const lucid = await devKit.init();

// Check system health
const status = await devKit.healthCheck();
console.log('System healthy:', status.healthy);

// Generate wallet and build transactions
const seed = WalletHelper.generateSeed();
lucid.selectWallet.fromSeed(seed);

// Use namespace imports for cleaner code
const amount = ADA.toLovelace(10);
const preview = await Transaction.preview(lucid, tx);

// Ready to build your dApp!

Feature Highlightsโ€‹

Namespace Importsโ€‹

Clean, organized imports for better code:

import { ADA, Address, Transaction, NFT, Debug } from 'cardano-devkit/namespaces';

const lovelace = ADA.toLovelace(100); // Clean!
const isValid = Address.validate(addr); // Discoverable!
const preview = await Transaction.preview(lucid, tx);

Debug.enable({ level: 'debug' });

Diagnostics & Health Monitoringโ€‹

Built-in system health checks:

import { diagnose, isHealthy, quickBalance } from 'cardano-devkit';

// Quick health check
if (await isHealthy(devKit)) {
console.log('All systems go!');
}

// Full diagnostics
const diag = await diagnose(devKit);
console.log(diag.network.status); // 'healthy'
console.log(diag.wallet.balanceAda); // 150.5

// Quick balance check
const balance = await quickBalance(devKit);
console.log(`${balance.ada} ADA in ${balance.utxoCount} UTxOs`);

Debug & Transaction Tracingโ€‹

Trace transactions through their lifecycle:

import { traceTransaction, formatTrace, createDebugLogger } from 'cardano-devkit';

const logger = createDebugLogger('MyApp');

const { txHash, trace } = await traceTransaction(lucid, async (l) => {
logger.info('Building transaction...');
const tx = await l.newTx()
.pay.ToAddress(recipient, { lovelace: amount })
.complete();
return await tx.sign.withWallet().complete().then(s => s.submit());
});

console.log(formatTrace(trace));
// Shows timing for build, sign, submit, confirm phases

Developer Utilitiesโ€‹

// Smart coin selection
const manager = createUTxOManager();
manager.setUtxos(utxos);
const selected = manager.select(5_000_000n, 'optimal');

// Transaction history tracking
const history = createTxHistory();
history.add({ txHash, amount, direction: 'sent', status: 'pending' });

// Named addresses
const book = createAddressBook();
book.add({ label: 'treasury', address: 'addr_test1...' });
const addr = resolveAddress('treasury', book);

Enhanced Error Recoveryโ€‹

Errors include recovery suggestions:

try {
await sendAda(lucid, recipient, amount);
} catch (error) {
if (error instanceof CardanoDevKitError) {
console.error(error.message);

// Get recovery suggestions
for (const suggestion of error.suggestions) {
console.log('Try:', suggestion.action);
}

// Code example for fix
if (error.codeExample) {
console.log('Example:', error.codeExample);
}
}
}

Project Scaffoldingโ€‹

# Interactive wizard for new projects
cardano-devkit init --wizard

# Create full dApp with Aiken + React
cardano-devkit new my-marketplace --template nft-marketplace --features aiken,react,testing

# Generate code artifacts
cardano-devkit generate wallet --network Preprod
cardano-devkit generate contract escrow
cardano-devkit generate component WalletButton

Interactive Consoleโ€‹

cardano-devkit console --network Preprod

cardano:preprod> balance addr_test1...
๐Ÿ’ฐ Balance: โ‚ณ 1,234.567890

cardano:preprod> convert 100 ada
๐Ÿ’ฑ 100 ADA = 100,000,000 lovelace

Comparison with Yaci DevKitโ€‹

FeatureCardano DevKitYaci DevKit
LanguageJavaScript/TypeScriptJava
Installationnpm installDocker/ZIP download
React Supportโœ… Built-in hooksโŒ N/A
Block Time100ms minimum100ms minimum
CLIโœ… 46+ commandsโœ… Full CLI
WebSocketโœ… Real-timeโŒ Polling
Project Scaffoldโœ… 7 templatesโŒ N/A
Namespace Importsโœ… 15 namespacesโŒ N/A
Debug/Diagnosticsโœ… Built-inโŒ N/A
Target AudienceJS/TS developersAny language

Test Coverageโ€‹

  • 35+ test suites
  • 1,377 passing tests
  • 500+ exports (functions, classes, types)

Next Stepsโ€‹