Command Line Interface
The Cardano DevKit CLI provides tools for wallet management, transaction building, devnet control, and project scaffolding.
Installation
# Run directly with npx
npx cardano-devkit --help
# Or install globally
npm install -g cardano-devkit
cardano-devkit --help
Quick Start
# Initialize a new project
cardano-devkit init
# Start local devnet
cardano-devkit devnet start
# Generate a test wallet
cardano-devkit generate wallet --network Preprod
# Check system health
cardano-devkit health
Project Initialization
init
Initialize a new Cardano project with configuration files.
# Basic initialization
cardano-devkit init
# Interactive wizard mode
cardano-devkit init --wizard
# Specify options directly
cardano-devkit init --network Preprod --template basic
Options:
| Option | Description |
|---|---|
--wizard | Interactive setup wizard |
--network <network> | Default network (Mainnet, Preprod, Preview, LocalDevnet) |
--template <template> | Project template (basic, full, minimal) |
--typescript | Generate TypeScript configuration |
--skip-git | Skip git initialization |
Wizard Mode:
The wizard guides you through configuration:
? Project name: my-cardano-app
? Select default network: Preprod
? Enable TypeScript? Yes
? Initialize local devnet configuration? Yes
? Select features:
◉ Wallet management
◉ Transaction building
◉ NFT minting
◯ Smart contracts
◯ Governance
? Create example files? Yes
✓ Created cardano.config.json
✓ Created tsconfig.json
✓ Created src/index.ts
✓ Initialized git repository
Run 'npm install' to install dependencies.
Code Generation
generate
Generate various code artifacts and configurations.
cardano-devkit generate <type> [options]
Types:
| Type | Description | Example |
|---|---|---|
seed | Generate a new seed phrase | generate seed |
wallet | Generate wallet from seed | generate wallet --network Preprod |
address | Generate address from seed | generate address --seed "..." |
policy-id | Generate minting policy | generate policy-id --type sig |
key | Generate key pair | generate key |
contract | Smart contract template | generate contract escrow |
component | React component | generate component WalletButton |
config | Configuration file | generate config |
generate seed
Generate a new seed phrase.
# Default 24 words
cardano-devkit generate seed
# Specify word count
cardano-devkit generate seed --words 15
# Output as JSON
cardano-devkit generate seed --json
generate wallet
Generate a complete wallet configuration.
# Generate new wallet
cardano-devkit generate wallet --network Preprod
# From existing seed
cardano-devkit generate wallet --seed "your seed phrase here" --network Preprod
# Output formats
cardano-devkit generate wallet --network Preprod --json
cardano-devkit generate wallet --network Preprod --output wallet.json
Output:
Wallet Generated
════════════════════════════════════════
Network: Preprod
Address: addr_test1qz...
Seed: abandon abandon abandon...
⚠️ Store your seed phrase securely!
generate address
Generate an address from a seed phrase.
# From environment variable
SEED="your seed phrase" cardano-devkit generate address --network Preprod
# With explicit seed
cardano-devkit generate address --seed "your seed phrase" --network Preprod
# Generate multiple addresses
cardano-devkit generate address --seed "..." --network Preprod --count 5
generate policy-id
Generate a minting policy and policy ID.
# Signature policy
cardano-devkit generate policy-id --type sig
# Time-locked policy
cardano-devkit generate policy-id --type time --lock-until "2024-12-31"
# Multi-signature policy
cardano-devkit generate policy-id --type multi --required 2 --keys 3
generate contract
Generate smart contract templates.
# Escrow contract
cardano-devkit generate contract escrow
# Vesting contract
cardano-devkit generate contract vesting
# Time-lock contract
cardano-devkit generate contract timelock
# Output to file
cardano-devkit generate contract escrow --output contracts/escrow.ts
generate component
Generate React components.
# Wallet connect button
cardano-devkit generate component WalletButton
# Transaction builder form
cardano-devkit generate component TxBuilder
# Output path
cardano-devkit generate component WalletButton --output src/components/
generate config
Generate configuration files.
# Default config
cardano-devkit generate config
# Specific network
cardano-devkit generate config --network Mainnet
# Full configuration
cardano-devkit generate config --full
Devnet Commands
devnet start
Start the local development network.
# Basic start
cardano-devkit devnet start
# With options
cardano-devkit devnet start --block-time 500 --explorer
Options:
| Option | Description | Default |
|---|---|---|
--block-time <ms> | Block production interval | 1000 |
--explorer | Start block explorer | false |
--port <port> | API port | 10080 |
--ogmios | Enable Ogmios | false |
--kupo | Enable Kupo | false |
devnet stop
Stop the local devnet.
cardano-devkit devnet stop
devnet status
Check devnet status.
cardano-devkit devnet status
devnet fund
Fund an address from the faucet.
cardano-devkit devnet fund <address> <amount>
# Example
cardano-devkit devnet fund addr_test1qz... 1000
devnet logs
View devnet logs.
cardano-devkit devnet logs
cardano-devkit devnet logs --follow
Wallet Commands
wallet balance
Check wallet balance.
cardano-devkit wallet balance --address <address> --network Preprod
wallet utxos
List wallet UTxOs.
cardano-devkit wallet utxos --address <address> --network Preprod
Transaction Commands
tx send
Send a simple ADA transfer.
cardano-devkit tx send \
--from <seed-or-address> \
--to <recipient> \
--amount 10 \
--network Preprod
tx build
Build a transaction without submitting.
cardano-devkit tx build \
--from <address> \
--to <recipient> \
--amount 10 \
--network Preprod \
--output tx.json
tx sign
Sign a transaction.
cardano-devkit tx sign \
--tx tx.json \
--seed "your seed phrase" \
--output tx.signed.json
tx submit
Submit a signed transaction.
cardano-devkit tx submit --tx tx.signed.json --network Preprod
Diagnostic Commands
health
Quick system health check.
cardano-devkit health --network Preprod
# Output:
# ✓ Network: healthy
# ✓ Provider: connected
# ✓ Tip: slot 45678901
diagnose
Run full diagnostics.
cardano-devkit diagnose --network Preprod
# Include wallet
cardano-devkit diagnose --network Preprod --address <address>
# JSON output
cardano-devkit diagnose --network Preprod --json
Utility Commands
convert
Convert between ADA and lovelace.
# ADA to lovelace
cardano-devkit convert 10 --to lovelace
# Output: 10000000
# Lovelace to ADA
cardano-devkit convert 5000000 --to ada
# Output: 5
validate
Validate Cardano data.
# Validate address
cardano-devkit validate address <address>
# Validate transaction hash
cardano-devkit validate txhash <hash>
# Validate policy ID
cardano-devkit validate policyid <id>
decode
Decode Cardano data.
# Decode CBOR transaction
cardano-devkit decode tx <cbor-hex>
# Decode address
cardano-devkit decode address <address>
Configuration
Environment Variables
| Variable | Description |
|---|---|
CARDANO_NETWORK | Default network |
CARDANO_SEED | Wallet seed phrase |
CARDANO_API_KEY | Provider API key |
CARDANO_DEVNET_PORT | Devnet API port |
Configuration File
Create cardano.config.json:
{
"network": "Preprod",
"providers": {
"Preprod": {
"type": "koios",
"url": "https://preprod.koios.rest/api/v1"
}
},
"devnet": {
"blockTime": 1000,
"enableExplorer": true
}
}
Global Options
All commands support these options:
| Option | Description |
|---|---|
--network <network> | Override network |
--config <file> | Config file path |
--json | Output as JSON |
--verbose | Verbose output |
--quiet | Suppress output |
--help | Show help |
Examples
Complete Workflow
# 1. Initialize project
cardano-devkit init --wizard
# 2. Start devnet
cardano-devkit devnet start
# 3. Generate test wallet
cardano-devkit generate wallet --network LocalDevnet --output test-wallet.json
# 4. Fund wallet from faucet
cardano-devkit devnet fund $(cat test-wallet.json | jq -r '.address') 1000
# 5. Check balance
cardano-devkit wallet balance --address $(cat test-wallet.json | jq -r '.address')
# 6. Send transaction
cardano-devkit tx send \
--from "$(cat test-wallet.json | jq -r '.seed')" \
--to addr_test1... \
--amount 10 \
--network LocalDevnet
# 7. Run diagnostics
cardano-devkit diagnose --network LocalDevnet
CI/CD Integration
# Run health check in CI
cardano-devkit health --network Preprod --json || exit 1
# Validate before deployment
cardano-devkit validate address $DEPLOY_ADDRESS || exit 1
# Generate test fixtures
cardano-devkit generate seed --json > test-fixtures/seed.json
Exit Codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Invalid arguments |
| 3 | Network error |
| 4 | Wallet error |
| 5 | Transaction error |