Blog

Basics of Blockchain

Imagine two people — Jack and Susan. Jack has an apple. They meet in the street and Jack gives that apple to Susan. They both know what happened and they don’t need the third party to help them with the transfer of that apple.

Now, let’s say that Jack has a digital apple. The problem with digital apples is that no one can guarantee Jack won’t make multiple copies of that apple and send it to Susan, Samantha, and Jasmine.

That is the main problem we need to solve if we intend to transfer digital assets. The problem is commonly known as the double-spending problem. We need some kind of digital ledger to solve that problem. The term ledger has historically been associated with accounting, denoting a book where all transactions are tracked.

A blockchain is precisely that, a digital public ledger that is available to everyone. It stores every transaction that ever happened on a blockchain network.

In our story, Apples represent Bitcoins (the first and still the most widely-known application of blockchain). At a certain point, we have the exact number of Bitcoins in our network. Any time we exchange those bitcoins, the transaction is saved on the blockchain, our digital ledger. That way, we can track every Bitcoin on the network and see to which account it belongs. Of course, we can see the balance of a certain account, but we are not allowed to see who the owner of that account is.

That would be an explanation of blockchain in simple terms. Now, let’s dive deeper, from the technical point of view.

Blockchain represents a decentralized database and a peer-to-peer network.

A decentralized database, because it stores all transactions that happened on the network and it doesn’t have a central authority. Transactions are grouped into blocks whose size cannot exceed 1MB. A block takes the hash value of the last block in blockchain and puts it into the header. Then, miners calculate the hash of the current block and when the proof of work problem is solved, the new block is added at the end of the blockchain.

Peer-To-Peer network in the sense the network doesn’t have a centralized organization. The copy of blockchain is stored on many nodes in the network. The nodes that store the whole blockchain are called full nodes. Another name for full nodes is miners and they are in charge of the process called mining.

Mining is a process of adding new blocks in the blockchain. It works like this:

  1. Miners check the validity of transactions. They are in charge of preventing double-spending and refusing invalid transactions.
  2. After checking the validity, the transactions are bundled in a block.
  3. Hash value of the previous block is added to the header of the new block.
  4. Miners solve the proof of work problem.
  5. After the proof of work problem is solved, the block is added to local blockchain of a miner who solved the problem first.
  6. The miner who solves the problem propagates that block to the network.
  7. If 51 percent of the network confirms that block is valid, the block is added to the blockchain and the blockchain on every node is updated.
  8. The miner who solved the puzzle receives transaction fees and Bitcoins.

In the steps described above, we mentioned the proof of work problem.

Proof of work is work that miners do when they calculate the hash value of a block.

They try to find a hash value of the block that starts with a certain number of zeros. The proof of work difficulty recalculates every 2016 blocks (around two weeks) and increases/decreases with the goal of adjusting the difficulty so that new blocks are added to the blockchain with the average time of 10 minutes.

As more miners join the network, the computing power increases, and the average time for the creation of a block decreases. Mining difficulty is then increased and the average block time creation goes back to normal.

In the early days of Bitcoin, home computers were used for mining and they could mine 2–3 bitcoins a day. Today you would need a 100 years to mine one Bitcoin with an average home computer.

Proof of work is a way of reaching consensus in blockchain network. Besides proof of work, we have proof of stake. It is a different way to validate transactions and achieve the distributed consensus. Creator of the new block is chosen in a deterministic way, depending on its stake in the network.

In cryptocurrencies which are using proof of stake, all coins are supplied in advance during the creation of that cryptocurrency, so the creator of the block doesn’t receive coin reward, and only receives transaction fees.

Ethereum, for example, is planning to make a transition from proof of work to proof of stake as a greener and cheaper distributed form of consensus. Why greener and cheaper? Annualized estimated global mining costs are more than 3 billion dollars. It is a lot of power spent on mining.

The blockchain technology is very complex and the concept cannot be explained in a single article, but I tried to introduce some basic concepts of the blockchain.

It is a young technology, and it will most probably take a while before it transforms the IT industry as well as the rest of the world, but it will happen one day.