A blockchain implementation in Rust featuring a distributed node network, cryptocurrency wallet, and mining capabilities. ArcNet implements a UTXO-based blockchain with transaction signing, network synchronization, and a terminal user interface.
ArcNet is a complete blockchain ecosystem consisting of four main components:
- lib: Core library containing blockchain types, cryptographic operations, and network messaging
- node: Blockchain node that maintains and synchronizes the blockchain across the network
- wallet: Terminal-based wallet application with a TUI for managing keys, contacts, and transactions
- miner: Mining component for creating new blocks
- UTXO-based Blockchain: Unspent Transaction Output model for transaction management
- Cryptographic Security: ECDSA-based signing and verification using secp256k1
- Network Synchronization: Peer-to-peer node communication and blockchain synchronization
- Wallet Application: Terminal UI wallet with:
- Balance display with ASCII art
- Contact management
- Transaction sending
- Multiple key pair support
- Configurable transaction fees (fixed or percentage-based)
- Mining Support: Block template generation and validation
- Persistent Storage: Blockchain state saved to disk in CBOR format
- Rust: Version 1.70 or later (Rust 2024 edition)
- Cargo: Rust's package manager (included with Rust)
If you don't have Rust installed, you can install it using rustup:
# On Windows (PowerShell)
Invoke-WebRequest https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
.\rustup-init.exe
# On Linux/macOS
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh-
Clone the repository (or navigate to the project directory):
cd arcnet -
Build all components:
cargo build --release
This will compile all workspace members (lib, node, wallet, miner) and create executables in
target/release/. -
Build individual components (optional):
# Build only the wallet cargo build --release -p wallet # Build only the node cargo build --release -p node # Build only the miner cargo build --release -p miner
arcnet/
├── lib/ # Core library (blockchain types, crypto, network)
│ └── src/
├── node/ # Blockchain node implementation
│ └── src/
├── wallet/ # Wallet application
│ └── src/
│ ├── main.rs # Entry point
│ ├── core.rs # Core wallet logic
│ ├── ui.rs # Terminal UI
│ ├── tasks.rs # Background tasks
│ └── utils.rs # Utilities
├── miner/ # Mining component
│ └── src/
├── wallet_config.toml # Example wallet configuration
└── Cargo.toml # Workspace configuration
-
Start a seed node (first node in the network):
cargo run --release -p node -- --port 9000
-
Start additional nodes connected to existing nodes:
cargo run --release -p node -- --port 9001 127.0.0.1:9000 cargo run --release -p node -- --port 9002 127.0.0.1:9000 127.0.0.1:9001
Options:
--port <PORT>: Port number to listen on (default: 9000)--blockchain-file <FILE>: Path to blockchain storage file (default:./blockchain.cbor)<nodes...>: Space-separated list of node addresses to connect to
-
Generate a wallet configuration:
cargo run --release -p wallet -- generate-config --output wallet_config.toml
-
Edit
wallet_config.tomlto add your keys and contacts:keys = [ # Add your key pairs here # { public = "path/to/public.key", private = "path/to/private.key" } ] default_node = "127.0.0.1:9000" [[contacts]] name = "Alice" key = "path/to/alice.pub.poem" [[contacts]] name = "Bob" key = "path/to/bob.pub.poem" [fee_config] fee_type = "Percent" # or "Fixed" value = 0.1 # 0.1% for Percent, or fixed amount for Fixed
-
Generate key pairs (using the lib binary tools):
# Generate a key pair cargo run --release --bin key_gen -- --output my_key -
Run the wallet:
cargo run --release -p wallet -- --config wallet_config.toml --node 127.0.0.1:9000
Options:
--config <FILE>: Path to wallet configuration file (default:wallet_config.toml)--node <ADDRESS>: Override default node address
- Press
Esc: Access the menu bar - Press
q: Quit the application - Menu Options:
- Send: Send a transaction to a contact
- Quit: Exit the wallet
Run the miner to create new blocks:
cargo run --release -p miner -- --node 127.0.0.1:9000# List of key pairs (public and private key file paths)
keys = []
# Default node address to connect to
default_node = "127.0.0.1:9000"
# Contact list for easy sending
[[contacts]]
name = "ContactName"
key = "path/to/public/key.pub.poem"
# Transaction fee configuration
[fee_config]
fee_type = "Percent" # Options: "Percent" or "Fixed"
value = 0.1 # Percentage (0.1 = 0.1%) or fixed amount in satoshis- Arcs: Base unit (1 Arc = 100,000,000 satoshis)
- Satoshis: Smallest unit (like Bitcoin's satoshi)
# Run all tests
cargo test
# Run tests for a specific package
cargo test -p lib
cargo test -p wallet# Debug build (faster compilation)
cargo build
# Release build (optimized)
cargo build --releaseThe wallet application logs to logs/wallet.log with daily rotation. Log levels can be controlled via the RUST_LOG environment variable:
# Set log level
export RUST_LOG=debug # or trace, info, warn, error
# Run wallet with logging
cargo run --release -p wallet- tokio: Async runtime
- serde: Serialization framework
- anyhow: Error handling
- tracing: Structured logging
- cursive: Terminal UI framework
- clap: Command-line argument parsing
- kanal: Async channels
- text-to-ascii-art: Balance display formatting
- argh: Argument parsing
- dashmap: Concurrent hash map
- static_init: Static initialization
- k256: secp256k1 elliptic curve cryptography
- ecdsa: Digital signature algorithms
The network uses a custom message protocol for communication between nodes, wallets, and miners:
FetchUTXOs: Request UTXOs for a public keyUTXOs: Response with UTXO listSubmitTransaction: Submit a transaction to the networkNewTransaction: Broadcast a new transactionFetchTemplate: Request a block template for miningTemplate: Block template responseSubmitTemplate: Submit a mined blockNewBlock: Broadcast a new blockDiscoverNodes: Discover other nodes in the networkNodeList: List of known nodesAskDifference: Compare blockchain heightsFetchBlock: Request a specific block
- Ensure the port is not already in use
- Check firewall settings
- Verify the blockchain file path is writable
- Verify the node is running and accessible
- Check the node address in
wallet_config.toml - Ensure network connectivity
- Verify sufficient balance (check UTXOs)
- Ensure recipient's public key is correct
- Check that the node is synchronized
- Ensure you're using Rust 2024 edition
- Run
cargo cleanand rebuild - Check that all dependencies are available
Contributions are welcome! Please ensure:
- Code follows Rust conventions
- Tests are included for new features
- Documentation is updated
- James Muriuki - geniusinrust@gmail.com
Built with Rust and the amazing Rust ecosystem.