Rust CLI tool for interacting with the blockchain node via REST API. clap 4, reqwest, colored output.
| src | ||
| .gitignore | ||
| Cargo.toml | ||
| CLAUDE.md | ||
| README.md | ||
blockchain-cli
Rust command-line tool for interacting with the blockchain node. Communicates entirely via REST API - no direct library dependency on blockchain-core.
Architecture
blockchain-cli/
└── src/
├── main.rs # Clap parsing + command dispatch
├── commands/
│ ├── mod.rs # Command enum (subcommands)
│ ├── wallet.rs # create, balance, list
│ ├── transaction.rs # send, list-pending
│ ├── mining.rs # mine (with progress bar)
│ ├── blocks.rs # list, get
│ └── node.rs # info, validate
├── client.rs # NodeClient (reqwest HTTP wrapper)
├── display.rs # Colored/formatted terminal output
├── config.rs # Node URL, wallet directory
└── error.rs # CLI error types (anyhow)
Commands
USAGE:
blockchain-cli [OPTIONS] <COMMAND>
COMMANDS:
wallet Wallet management
tx Transaction operations
mine Mine a new block
block Block explorer
chain Chain information
OPTIONS:
--node <URL> Node URL [default: http://localhost:3000]
-h, --help Print help
-V, --version Print version
Wallet
# Create a new wallet (keypair saved locally)
blockchain-cli wallet create
# Check balance
blockchain-cli wallet balance <ADDRESS>
Transactions
# Send tokens
blockchain-cli tx send <FROM_ADDRESS> <TO_ADDRESS> <AMOUNT>
# View pending transactions
blockchain-cli tx pending
Mining
# Mine pending transactions (with progress indicator)
blockchain-cli mine <MINER_ADDRESS>
Blocks
# List recent blocks
blockchain-cli block list [--limit 10]
# Get block details
blockchain-cli block get <HASH>
Chain
# Chain info (height, difficulty, latest hash)
blockchain-cli chain info
# Validate entire chain
blockchain-cli chain validate
Design Decisions
| Decision | Choice | Rationale |
|---|---|---|
| CLI framework | clap 4 (derive) | Industry standard, excellent UX |
| HTTP client | reqwest | Async, well-maintained |
| Output | owo-colors + comfy-table | Colored text + formatted tables |
| Progress | indicatif | Mining progress bar |
| Errors | anyhow | Convenient error chaining for CLI |
| Node coupling | REST API only | Fully decoupled from core lib |
Quick Start
# Build
cargo build --release
# Start blockchain-node first (see blockchain-core repo)
# Then use the CLI:
blockchain-cli chain info
blockchain-cli wallet create
blockchain-cli mine <YOUR_ADDRESS>
Configuration
The CLI looks for wallets in ~/.blockchain-cli/wallets/. Node URL defaults to http://localhost:3000 and can be overridden with --node.
Related Repos
- blockchain-core - Core library + REST API node
- blockchain-flutter - Flutter mobile/web app
License
MIT