Skip to content

SAMIR897/mini_chain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⛓️ Mini Chain

A ground-up blockchain implementation in Rust demonstrating Proof-of-Work consensus, SHA-256 block hashing, and chain validation.

Features

  • 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

Usage

cargo run

Sample Output

🔗 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

How It Works

  1. A genesis block is created with no transactions
  2. Transactions are added to a pending pool
  3. Mining a block applies SHA-256 hashing with an incrementing nonce until the hash meets the difficulty target (leading zeros)
  4. Each block stores the hash of the previous block, creating an immutable chain
  5. Validation checks every block's hash and previous-hash link

Tech Stack

  • sha2 — SHA-256 hashing
  • chrono — Block timestamps
  • serde / serde_json — Serialization and JSON export

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages