You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Clone the repository
git clone https://github.com/yourusername/mini-blockchain.git
cd mini-blockchain
# Build release version
cargo build --release
# The binary will be at ./target/release/blockchain
๐ Quick Start
# 1. Initialize a new blockchain
./target/release/blockchain init
# 2. Create a wallet
./target/release/blockchain wallet new --label "MyWallet"# 3. Start mining (replace ADDRESS with your wallet address)
./target/release/blockchain mine --address <ADDRESS> --count 5
# 4. Check your balance
./target/release/blockchain wallet balance --address <ADDRESS># 5. View blockchain info
./target/release/blockchain chain
use mini_blockchain::{Blockchain,Wallet,Miner,BLOCK_REWARD};fnmain(){// Create a blockchain with custom difficultyletmut blockchain = Blockchain::with_difficulty(8);// Create walletslet alice = Wallet::new();let bob = Wallet::new();println!("Alice: {}", alice.address());println!("Bob: {}", bob.address());// Mine blocks to earn coinslet miner = Miner::new(&alice.address());for _ in0..3{let(block, stats) = miner.mine_block(&mut blockchain,vec![]).unwrap();println!("Mined block {} in {}ms", block.index, stats.time_ms);}// Check balanceprintln!("Alice's balance: {} coins", alice.balance(&blockchain));// Create a transactionlet tx = alice.create_transaction(&bob.address(),50,&blockchain).unwrap();println!("Transaction: {}", tx.id);// Validate chainassert!(blockchain.is_valid());}
โ๏ธ Configuration
Setting
Default
Description
difficulty
16
Mining difficulty (leading zero bits)
block_reward
50
Coins per mined block
target_block_time
10s
Target time between blocks
difficulty_adjustment
10 blocks
Blocks between difficulty changes
๐งช Testing
# Run all tests
cargo test# Run with output
cargo test -- --nocapture
# Run specific module tests
cargo test crypto::
cargo test core::blockchain::
Test Coverage:
โ 52 unit tests
โ Block creation & mining
โ Chain validation
โ Transaction signing
โ UTXO tracking
โ Wallet operations
โ Storage persistence
โ Network message codec
โ P2P node creation
โ Smart contract VM
โ Contract deployment & execution
๐ Performance
Benchmarks on Intel i7 (single-threaded):
Difficulty
Avg. Attempts
Avg. Time
8 bits
~256
< 1ms
16 bits
~65,536
~50ms
20 bits
~1M
~500ms
24 bits
~16M
~8s
๐ฃ๏ธ Roadmap
โ Completed
Core blockchain with PoW
ECDSA transaction signing
UTXO model
Wallet management
CLI interface
Persistence layer
P2P networking
REST API
Smart contracts (VM, compiler, storage)
Web UI (SvelteKit + shadcn-svelte)
Contract deployment via Web UI
WebSocket for real-time updates
Multi-signature transactions
Token standards (ERC-20 style)
Block explorer search
๐ฎ Future Ideas
Mobile-responsive UI
Docker deployment
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with โค๏ธ in Rust
About
A robust, full-stack blockchain engine built in Rust. Features a custom VM for smart contracts with real gas economics, Proof-of-Work consensus, UTXO transactions, multisig wallets, and a real-time SvelteKit block explorer.