Building a cryptocurrency from scratch
Building a proof-of-work coin from scratch teaches you something no tutorial does: how much of a currency is not the cryptography.
Where the work actually goes #
The hashing is the easy part. SHA-256 is a library call. What took months was everything around it.
Consensus and difficulty #
A chain has to agree with itself. Difficulty adjustment is a feedback loop, and feedback loops overshoot.
- Retarget too often and the difficulty oscillates.
- Retarget too rarely and a hash-rate spike empties the schedule early.
- Clamp the adjustment and you get stability at the cost of responsiveness.
Peer discovery #
Nodes have to find each other before they can disagree productively. Seed nodes first, then gossip:
addr -> version -> verack -> getblocks
What I would do differently #
Start with the network layer, not the block format. The block format is a data structure you can change in an afternoon; the network is a distributed system you will be debugging for weeks.
The chain is not the hard part. The agreement is.
Anyone building one of these should expect the split to be roughly 20% cryptography and 80% distributed-systems plumbing.
No account, no cookie — one clap per reader.
New posts, by email
Occasional writing about building things. No tracking pixels, one click to leave.