Short Linkblog: 10 Technology Elements of a Blockchain

The blockchain and its various implementations are a wonderful example of technology changing the world. By using a distributed ledger that rewards more people maintaining a true copy, a viable replacement to fiat currencies is now possible.

When I first heard about blockchains, I thought it must use some esoteric technology. This view was easily reinforced by how frequently academic terms like “white paper” and “proof of work” are referenced in the blockchain world. When I started digging deeper into the bitcoin stack however, I found that most of the concepts used were very simple. In fact, I now think that Satoshi was a genius not in that he advanced the state of the art in computer science, but as befits a great engineer, he combined several widely disparate but simple concepts in the computer science & engineering world to create something truly unique & compelling.

What are these concepts? I’ll try to list down 10.

  1. Public-Private Key Cryptography: for blockchain identify & signing.
  2. Peer to Peer & Multicast: Easily find and talk to other nodes. First pioneered by P2P file sharing way back!
  3. Unspent Transaction Output (UTXO) [more detail]: for simplified ledgers.
  4. Merkle Trees: for efficient storage & verification of transactions.
  5. Proof of Work Mining: Algorithmic Problem Solving as a reward mechanism.
  6. Block Creation [more detail]: Use previous block hash + transactions to create block.
  7. Building a Blockchain: Distributed order creation to avoid double spends.
  8. Blockchain Forks & Resolution: Longest chain wins.
  9. Difficulty Adjustment [more detail]: to increase difficulty with mining power, and ensure that blocks are generated in uniform time.
  10. Independent Transaction Validation: Every node independently verifies transactions before storing in pool. There is no trusted actor!

So there you go! 10 concepts that you have to grok, and then combine to form the foundations of blockchain-based payment networks like Bitcoin. This should easily be a good weekend read 🙂


Replr: Easy Command-line REPLs

I built a small utility this week to help anybody start a REPL in any language stack[1], with any libraries of their choosing. It’s built on top of docker, and it was a fun exercise for a couple of days to build something that’s I’ll personally use quite a lot when trying out new Ruby gems.

So instead of creating a Gemfile, making sure that its syntax is correct, installing the version of Ruby you’d like via rvm, instead, you just type in a single command:

replr ruby chronic

& your REPL is ready!

Do check it out at Github and gem install replr

A few things I learnt while building this:

  • I wanted to keep dependencies low (because this is something people will install as a binary into their machines), so I did all the argument parsing et. al. manually. It’s not that hard or clumsy at all. replr currently has 0 dependencies.
  • I used Visual Studio Code as the editor for building this, and its quickly becoming my go-to editor for every kind of code editing. I was one of the last few folks holdouts at Textmate 2, and while VSCode is still not native enough for my tastes, the breadth & depth of its editor and tooling integration is hard to live without now.
  • Speaking of VSCode integration, I’ve heavily used the Ruby editor integration to make sure code conforms to Rubocop​ guidelines. It’s nowhere near as good as Prettier​ on JavaScript though. Prettier just has you spoilt with its auto-formatting & opinionated code rewriting. I feel Ruby can really use a tool like that.

[1]: Well, it currently just supports Ruby, but am planning to add new stacks soon!