18 — Proof of work — mining transaction blocks
A valid transaction is not yet a blockchain. Every new block must commit to the previous block hash, and miners must find candidate data whose hash satisfies a work target.
The pure Korean sentence example reuses the bundled zero-knowledge adapter's SHA-256 Fiat-Shamir challenge as its 256-bit work candidate. It generates fresh nonce/commitment material until the candidate falls below the target.
The advanced examples show conventional proof of work directly: serialize the
height, previous hash, transaction, proof, miner, reward, and work nonce; hash
that payload with hashlib.sha256; increment the work nonce until the hex hash
starts with 00.
The English sentence form exposes the mining loop directly:
while genesismining
genesisrandom save zero knowledge nonce make
genesiscandidatecommitment save genesisrandom zero knowledge commitment make
genesiscandidatehash save mineraddress genesiscandidatecommitment genesiscontext zero knowledge challenge make
add 1 to genesisattempts
if genesiscandidatehash is less than worktarget
genesiscommitment save genesiscandidatecommitment
genesishash save genesiscandidatehash
genesismining save 0
end
end
run it →nme run examples/needmorecoin-advanced.en
Difficulty is intentionally low for learning. Raising it can greatly increase runtime.
Block 1 commits to the genesis hash, and block 2 commits to block 1's hash. If an old transaction changes, its block hash changes and the next block's stored previous hash no longer matches.
Next, 19 — Transaction proofs verifies who authorized a transaction and why the same valid transaction cannot be replayed.