loading...

A blockchain for dummies

zohaibility profile image Zohaib Sibte Hassan ・1 min read

While crypto-currencies are having bad time financially these days, it obviously has inspired and spun up a lot of applications. Blockchain and proof-of-work are fundamental concepts for the buzz that surrounds crypto-currency. While I see many people discussing the applications and possibilities, the serious lack of understanding among common developers prompted me to do a "Blockchain for dummies" implementation. So here it is:

Here are the goals I've tried to achieve:

  • I wanted to implement it in most popular language, so I selected Javascript.
  • Wanted to show clear separation between proof-of-work and actual chain itself.
  • For proof-of-work I selected floating numbers and hex string matching. Rather than having random string generation or something complicated it allows a simpler implementation that won't irritate your eyes but still shows the difficulty you can achieve.
  • For blockchain I stored everything in memory again for simplicity.
  • No comments! If code can't explain itself I would call it useless.
  • Use everything builtin (no external packages), because you don't need anything else!

I would be more than happy to improve it based upon feedback. Let me know what you think!

Discussion

pic
Editor guide
 

Thanks for this. I've only understood blockchain enough to have a general idea of how it works, this helps me understand it well enough to explain it to others.

Now I'm wondering how close this is to actual implementations; also why on earth people put their money into this...

 

In terms of fundamental concept it should describe core concepts really well; however this is still far from being production ready. I've not implemented stuff like verify and syncing chains across the nodes. If you imagine this chain is distributed across machines around the world it's really hard for someone to do a fake entry in it without really doing a proof of work.

This is expensive for clients mining (or trying to add entry) however it's really cheap to verify it (just look at the proof and proof_claim); which leads to multiple applications including putting virtual currency in it.

 

... have you just gotten us to mine blockchain for you?
Clever.
Not very nice, but clever.