A ground-up blockchain implementation in Rust demonstrating Proof-of-Work consensus, SHA-256 block hashing, and chain validation.
- Transaction system with sender, receiver, and amount
- Block structure with SHA-256 hashing and previous-hash linking
- Proof-of-Work mining with configurable difficulty
- Chain validation — verifies hash integrity across all blocks
- JSON export — serializes the full blockchain to
blockchain.json
cargo run🔗 Mini Blockchain - Proof of Work Demo
Genesis block created: 0c9e6867f42f...
📝 New transaction: Alice -> Bob (50 coins)
📝 New transaction: Bob -> Charlie (25 coins)
Mining block 1...
⛏️ Block 1 mined! Nonce: 79 Hash: 00551a27e540...
Mining block 2...
⛏️ Block 2 mined! Nonce: 72 Hash: 006bf245eb21...
═══════════════════════════════════════
FULL BLOCKCHAIN
═══════════════════════════════════════
Block #0
Timestamp: 2026-03-10T12:32:23+00:00
Transactions: 0
Hash: 0c9e6867f42f...
───────────────────────────────────────
Block #1
Transactions: 2
Alice -> Bob : 50 coins
Bob -> Charlie : 25 coins
Hash: 00551a27e540...
───────────────────────────────────────
✅ Blockchain is valid!
💾 Blockchain saved to blockchain.json
- A genesis block is created with no transactions
- Transactions are added to a pending pool
- Mining a block applies SHA-256 hashing with an incrementing nonce until the hash meets the difficulty target (leading zeros)
- Each block stores the hash of the previous block, creating an immutable chain
- Validation checks every block's hash and previous-hash link
sha2— SHA-256 hashingchrono— Block timestampsserde/serde_json— Serialization and JSON export