How it works

Four ideas make a blockchain. Each one is live below: the hashing is real SHA-256, computed in your browser.

1. A hash is a fingerprint

SHA-256 turns any text into 64 hex characters. The same input always gives the same output, but change one letter and the output changes completely. Nobody knows how to work backwards from a hash to its input.

2. Proof of work: find a hash that starts with zeros

A miner adds a number called a nonce to the block and keeps changing it until the hash starts with enough zero bits. There is no shortcut: each extra bit doubles the expected number of tries. ZAK Chain raises or lowers the required bits every 10 blocks to aim for one block every 10 seconds.

Press Mine.

3. Each block includes the previous block's hash

Every block stores the hash of the block before it. Edit any block below and its hash changes, so it no longer has enough zeros and the next block's "previous" link no longer matches. Everything after the edit turns red. To cheat you'd have to re-mine that block and every block after it, faster than the rest of the network adds new ones.

This toy uses 12-bit difficulty and hashes [index, prev, data, nonce]. Real ZAK blocks also commit to the time, difficulty, miner and signed transfers.

4. Transfers are signed and numbered

Each transfer is signed with the sender's private key and carries a nonce: the sender's transfer count plus one. Every node replays every transfer from the genesis block, so it knows each balance and the last nonce. Try to cheat this toy ledger:

Alice

last nonce
Bob
Miner (fees)

The toy checks rules the same way zakchain.mjs does, but shows signatures as "signed by" labels instead of real Ed25519 keys.

And consensus

Nodes pass new transfers and blocks to each other. If two chains disagree, a node keeps the one that is fully valid and has the most total proof of work, so a long chain of easy blocks can't win. The code is short enough to read in one sitting; start with replay() in zakchain.mjs.