This project is a simple educational blockchain implementation in Rust, designed for demonstration purposes. It allows you to create and validate blocks with transactions, simulate Proof-of-Work mining, and persist the blockchain state to a JSON file.
- Transactions with
from
,to
, andamount
- Proof-of-Work with adjustable difficulty
- Blockchain validation
- Persistent storage to
blockchain.json
(for simplicity) - Interactive CLI for adding transactions
Each time the program runs:
- It loads the blockchain from
blockchain.json
if it exists. - Prompts the user to enter transaction details.
- Creates a new block containing the transaction.
- Mines the block using a basic Proof-of-Work mechanism (hash must start with
0000
). - Adds the block to the chain and saves it back to disk.
- Install Rust and Cargo
cargo build
cargo run
--- New Transaction ---
From: Abdulelah
To: Sarah
Amount: 10
✅ Block added and mined.
Blockchain valid? true
main.rs
– main blockchain logic and CLI.blockchain.json
– saved blockchain state. (Generated after first transaction)