How does a Blockchain work?

Crypto & Coin Database

Blockchains are based on simple peer to peer databases. Users can interact with each other directly with no intermediates because blockchains are decentralized. This means that there is no central institution that controls and maintains the system.

A blockchain is a chain of blocks that contains information. Every block on the chain contains a number of accepted transactions (or other informations) and a hash of the previous block. When enough transactions are added to the block, the block will be added to the blockchain and then distributed to the network of communicating nodes running the software. The nodes need to save the whole blockchain and check every block against consensus rules. Some nodes are mining nodes. They add blocks to the blockchain by solving a mathematical puzzle and including the answer in the block. For solving this puzzle, miners receive rewards in form of coins.

 

What are nodes?

A node can be any electronic device including phones or computers, as long as they are connected to the internet and have an IP address. Nodes are the foundation for a functioning and healthy blockchain. They have a variety of tasks that they must fulfill in order for a blockchain to work correctly. Nodes support the network by maintaining a copy of the blockchain and sometimes process and verify transactions or other data. Every node on the network is considered equal, however certain nodes have different tasks than others. Not every node verifies transactions and not every node stores a full copy of the blockchain. A full node keeps a full copy of the blockchain and checks any new transaction or other data that is added to the blockchain after the consensus rules. Every node on the network follows the consensus protocol to remain compatible to each other.

 

What is consensus?

Consensus means a general agreement among the members of a group or community. In centralized systems, the consensus is reached by the central institution itself. However, in a decentralized system consensus must be reached through the whole community. In a blockchain, this mechanism is used to confirm transactions and produce new blocks to the chain. There are two widespread consensus mechanisms.

is the oldest and most commonly used consensus mechanism. Miners create new blocks by solving a mathematical puzzle. The first miner to complete this task gets rewarded. There are advantages and disadvantages to this system. One advantage is that it is the most tested mechanism and therefore the least error-prone. However, mining becomes more and more power consuming. This makes it not only expensive but also harmful to the environment. The two most well-known cryptocurrencies Bitcoin and Ethereum utilize proof of work.

is a consensus algorithm where the validation of new blocks depends on a validator’s economic stake in the network. The blockchain keeps track of validators and anyone who holds the blockchain’s base currency can become a validator. To become a validator you have to send a special transaction that locks up your “stake” in a deposit. The higher your stake is, the easier it is to create new blocks as a validator. The biggest advantage of this type of consensus algorithm is that it is not power consuming like proof of work. Ethereum has announced that they are slowly switching their consensus algorithm from proof of work to proof of stake.

 

Cryptography and Hashing

Interactions on the blockchain are made using cryptographic addresses of sender and recipient. Each entity on the network is identified by a cryptographic combination of a public address and a private key. For each transaction or interaction on a blockchain, the sender generates the transaction using public address of the recipient and digitally signs it with his own private key. This digital signature is unique for each transaction because both the public address of the recipient and the private key of the sender are unique. This transaction ID makes sure that no transaction on the blockchain can be copied or falsified.

Every blockchain user has both a private key and a public address. The public address is for receiving transactions or other data over the network. The private key is for initiating transactions on the network. Your private key is mathematically related to your public address. It is easy to generate the public address from a private key. However, it is impossible to generate a private key from a public address.

Each block on the blockchain creates a hash and uses this hash to link to the next block in the chain. The hash is created by a mining node. They validate transactions and put them into blocks. The hashing algorithms differ from blockchain to blockchain. Bitcoin for example uses SHA-256. There are certain hashing algorithms that take advantage of powerful graphic processing units (GPUs) and others which take advantage of memory. To mine more efficiently, there are dozens of firms that sell so called ASICs (application-specific integrated circuit). ASICs are small processing units which are far better for mining than normal computers.

 

A fork is a change to the protocol of a blockchain. The changes in the protocol are so significant that the consensus splits in two parts. When the protocol of a cryptocurrency gets updated a soft or hard fork has to be initiated so that the changes become effective.

A soft fork is an update of the existing protocol. The old version of the protocol will still be accepted, however it doesn’t feature the functions of the new protocol. This means that a soft fork is backwards compatible.

A hard fork is like an upgrade of the blockchain. This upgrade is not backwards compatible, which means that the old version of the blockchain will not be supported after a hard fork. Furthermore, after a hard fork the community is split in two sides. The one side with users of the old blockchain and the other side with users of the upgraded blockchain.