# 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] COMMANDS: wallet Wallet management tx Transaction operations mine Mine a new block block Block explorer chain Chain information OPTIONS: --node Node URL [default: http://localhost:3000] -h, --help Print help -V, --version Print version ``` ### Wallet ```bash # Create a new wallet (keypair saved locally) blockchain-cli wallet create # Check balance blockchain-cli wallet balance
``` ### Transactions ```bash # Send tokens blockchain-cli tx send # View pending transactions blockchain-cli tx pending ``` ### Mining ```bash # Mine pending transactions (with progress indicator) blockchain-cli mine ``` ### Blocks ```bash # List recent blocks blockchain-cli block list [--limit 10] # Get block details blockchain-cli block get ``` ### Chain ```bash # 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 ```bash # 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 ``` ## 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](../blockchain-core) - Core library + REST API node - [blockchain-flutter](../blockchain-flutter) - Flutter mobile/web app ## License MIT