MARKDOWN SOURCE
# pow-chain A small, self-contained Rust demo of a proof-of-work blockchain. It mines a genesis block and two example transfer blocks, prints each hash and link, and validates the completed chain. > **Educational only:** this project is not production cryptography, a secure > payment system, or a real currency. Its transactions are only checked for a > nonblank sender/recipient and a positive amount. It has no signatures, > balances, networking, persistence, consensus, or protection against an > attacker controlling the chain. ## Run Rust `1.98.1` is pinned in `mise.toml`; crate versions are pinned exactly in `Cargo.toml`, and `Cargo.lock` is used by every Cargo task. ```sh mise install mise run install mise run run mise run run -- --difficulty 4 mise run check ``` Difficulty is the required number of leading zero **hexadecimal digits** in a block's SHA-256 hash (from `0` to `64`). Higher values make mining exponentially slower; use small values for a quick demo. The default is `3`. ## What it demonstrates - Each block hashes its index, previous block hash, nonce, and ordered transactions using a stable, length-delimited encoding. - Mining increments the nonce until the hash meets the configured difficulty. - Validation checks transaction structure, sequential indices, predecessor links, recomputed hashes, and proof-of-work for every block. - Unit tests cover deterministic hashing/mining, transaction rejection, and tampering detection. Amounts are illustrative integers, not currency units. A valid chain here only means its local structure and proof-of-work checks pass; it does not imply that transactions are authorized or economically valid.
pow-chain
A small, self-contained Rust demo of a proof-of-work blockchain. It mines a genesis block and two example transfer blocks, prints each hash and link, and validates the completed chain.
Educational only: this project is not production cryptography, a secure payment system, or a real currency. Its transactions are only checked for a nonblank sender/recipient and a positive amount. It has no signatures, balances, networking, persistence, consensus, or protection against an attacker controlling the chain.
Run
Rust 1.98.1 is pinned in mise.toml; crate versions are pinned exactly in
Cargo.toml, and Cargo.lock is used by every Cargo task.
mise install
mise run install
mise run run
mise run run -- --difficulty 4
mise run check
Difficulty is the required number of leading zero hexadecimal digits in a
block's SHA-256 hash (from 0 to 64). Higher values make mining
exponentially slower; use small values for a quick demo. The default is 3.
What it demonstrates
- Each block hashes its index, previous block hash, nonce, and ordered transactions using a stable, length-delimited encoding.
- Mining increments the nonce until the hash meets the configured difficulty.
- Validation checks transaction structure, sequential indices, predecessor links, recomputed hashes, and proof-of-work for every block.
- Unit tests cover deterministic hashing/mining, transaction rejection, and tampering detection.
Amounts are illustrative integers, not currency units. A valid chain here only means its local structure and proof-of-work checks pass; it does not imply that transactions are authorized or economically valid.