Blockchain is a technology that allows you to record and store information, which can not be changed or destroyed afterwards. The result is a large file with a list of records. These records are collected in blocks, and blocks — in a chain. Thus, Blockchain is a chain of blocks with a copy for each user.
The first blockchain was created for Bitcoin, the main idea of which is to do without banks and payment systems. Bitcoin is the unit of information there. This blockchain keeps data on all the Bitcoin transactions.
There are a lot of different blockchains except the ones which are considered as currency.
What advantages does blockchain have?
In traditional systems, special centers store and manage information, and all the operations are based on trust. Hackers can attack such centers and change or destroy the data. Thus, valuable information is lost, and then it is difficult to restore it. These and many other shortcomings are taken into account in blockchain.
Information can not be unnoticeably removed or recorded
Blocks are connected like puzzles — each next contains a part of the previous one using unpickable cryptography methods. If you slightly change one entry, the rest will be invalid. Blockchain members will immediately notice it and take action.
There is no need for the intermediary to convey information
Users support the system operation themselves. The list is maintained according to the program rules. Everybody knows its code and can check its security.
Records cannot be destroyed
Every time you connect to the network, the program restores the last version of the chain from copies, stored by others. If you want to prevent it, you need to erase every copy in the whole world.
Its work doesn’t depend on the number of participants
The operation is similar to a file-sharing network. To get started you need to connect to one of the participants. This system will operate even if one or more computers are switched off. You can log in or out at any time.
Future is blockchain
The information recorded to the blockchain can be a coin, a license, a signature or another value. It depends on the application field: it can be applications for copyright protection, transfer of real property, identity cards or voting. This technology appeals not only to FinTech projects but also to banks, enterprises, and governments as many of them test and apply it.
How to connect to the blockchain?
To connect to the blockchain, you need to install a particular program, using which you can watch the list and conduct transactions. It takes the part of a wallet in a currency blockchain. The whole blockchain or its part is usually downloaded with this program, and you need to finish loading to start using it.
A computer, connected to a blockchain, is a node. On Bitnodes you can find all the Bitcoin nodes around the world.
How does the Bitcoin blockchain work?
When one person wants to transfer money to another, he asks a bank or a payment system to debit his account with a required amount and transfer it to someone else's, or just hand it in cash personally.
Bitcoins do not exist in the form of coins or codes. They are stored in the wallet program in the form of records which contain the information about someone transferred them one day to someone else. They are moved from one wallet to another without any participation of a bank or payment systems. The wallet address is the account.
Bitcoin blockchain is similar to the ledger, where all Bitcoin transactions can be found. Blocks are the pages of this book, which can not be torn out or corrected without rewriting the entire book.
How to transfer?
The owner creates a transaction in the wallet — an order to transfer a certain number of coins from one address to another. In a simplified form, its record contains:
- the address of the emitter wallet;
the amount of transfer;
the address of the recipient wallet.
The wallet sends the transaction over the network. Nodes check it and include in a new block along with the others which arrived at the same time. When a block containing this transaction is added to the chain, it is considered to be confirmed, and the recipient can spend the transferred amount.
How to add a new block
The process of a new block insertion is called mining, and those, who collect transactions and pack them into blocks, are called miners.
Miners choose transactions spontaneously, so each miner gets his version of the block. To record it in a chain, you must solve the programming task. When the nodes verify the solution, the block is added to the chain and circulated through the network. Having received a block, a miner proceeds to the next one.
Where do they get coins?
Bitcoin creates coins from nothing. Each time a new block is added to the chain, several new coins are sent to the miner who wrote it. Thus, the system reimburses the energy costs spent to solve the problem.
Initially, there were 50 coins, then 25, now 12.5. The award is halved every four years — in such a period about 210 000 blocks are created. There will be even less until the number of Bitcoins reaches 21 million. There will be no new coins after it. It’s written in the program, and you can not change anything.
Ethereum miners receive 5 Ethereum per block. The issue of new coins is not limited.
Mining is similar to the seeding on a torrent tracker. Anyone can upload a movie or a music album, become a distributor, get a rating for it and download files from others. In Bitcoin, miners are distributors. They support the system activity: check transactions and protect the chain from changes receiving Bitcoins, which can be exchanged for fiat money, instead of rating.
Sometimes, new coins are issued only once — at the start of a blockchain, they are distributed among the participants, and then they are just transferred to each other. It is convenient if it’s not a currency blockchain, but a register of lands or licenses.
How does the network test coin availability?
Before transferring money, the bank tests for the required amount on the sender's account. The amount of money and its sources are not important since the bank has performed all the operations and it is confident that they are not spent.
As for Bitcoin, nodes verify transactions. To make sure that Bitcoins are not spent, they need to know all the transaction’s details. This is a reason why all transactions contain inputs and outputs:
- the input contains a link to the transaction, using which Bitcoins were received;
the output contains instruction on how much of them and where to send.
The number of outputs and inputs depends on the amount and number of recipients.
Each input can be used only once. Nodes refer not only to the chain but also to each other. If an input is specified in another transaction, confirmed or not, a new transaction with it will be rejected, and the exchange will be stopped for at least several hours. Thus, no one can spend the same Bitcoins several times.
Transfer amount and change
Bitcoin is changed to satoshi — hundred millionth part, but unlike in a bank system, it is impossible to send coins from the wallet while specifying only a recipient’s address and a required amount.
You need to register inputs and outputs in every transaction — several, if they are small, and one, if it is significant. The deal will have two outputs in case of 1 recipient. Thus, one sends the right amount, the other returns change. Wallets usually do it by themselves, so you need to check and correct information if necessary.
It's like paying cash. To spend one dollar for a box of matches with a 100 dollars note, you have to give your note, and then 99 dollars will be returned as a change.
The block size is limited to 1 Mb. Only 2-3 thousand transactions can be placed in one block, while others are in the queue — the mempool. It does not matter which ones were sent earlier. If you want to do it faster, you need to pay fees. The difference between the sum of the outputs and inputs is usually received as a fee by the miner, who recorded a block with this transaction.
The commission rate depends not on the transfer amount, but on the number of addresses. The more addresses, the more space the transaction takes in the block. Therefore, the miners divide the commission by the size of the transaction and select the transactions with the highest price per byte.
When creating a transaction, wallets offer the best commission. If the transfer is not urgent, it can be lowered, but not too much, otherwise, the transaction won’t be placed into one of the blocks, and Bitcoins will be caught up.
Meanwhile, fees are low and mostly unpaid, since miners receive compensation from the system. But when it disappears, commissions will increase and such transactions won’t be processed.
What tasks do miners solve?
Task solution helps to record blocks systematically and protects the chain from changes by means of hashing — the transformation of the original information using a mathematical algorithm. As the result, we get a hash — a short string with a randomly-typed set of characters. Any record can have only one hash. If you change at least one character, the hash will be changed. You can not get the initial information on the hash, but you can check if it is changed.
For example, the hash of this article’s title is:
It's easy to check it with a calculator.
If you substitute the title of the article in the Data field, the hash will be the same. But if you add a space in the end, you will have another one:
Another advantage of the hash is that it is easily counted.
Miners’ task is to find the nonce number where the hash of the block is less or equal to the number of program targets. It can be done only by the enumeration of possibilities: the program sets 0 in the corresponding field and counts the hash of the block, then 1 and so on, until the hash is less than the target. As soon as the noncе is found, the block is distributed over the network for verification. To test a block any node just needs to count its hash and nonce and compare the result with the target. This algorithm is called Proof-of-Work (PoW).
A hash of the previous block is embedded into a new one. It helps to understand the sequence of block recording and confirms that the previous block existed earlier.
Blocks are inextricably linked by hashes. If you change at least one character in the block, its hash will change and won’t match one, written in the next block. As a result, two chains will be obtained, but the network considers only the longest one to be correct. To overtake it, you must first recalculate all the hashes of the old blocks and then create more new ones faster than everyone else.
How long does it take to solve the task?
The more power your computer has, the faster you will find the nonce. Those with more powerful computers could record blocks and receive coins more often. And if several computers found a nonce simultaneously, there would not be any chain.
But the program complicates the task and selects a target number so that the nonce cannot be found in less than 10 minutes. It happens every two weeks: about 2016 blocks are created within this period. Solution verification takes place immediately, and it doesn't depend on the complexity of the problem.
The total power of the network miners is called hashrate, which is measured in hashes per second. In 2013, Bitcoin's compute capacity exceeded 256 times 500 world’s most powerful supercomputers. Now Bitcoin's hashrate is more than 40 Exahash per second, so it's pointless to compete with the network.
Litecoin blocks are created every 2-3 minutes.
What happens if two miners find a nonce at the same time?
If two miners find a nonce simultaneously, each of them will distribute his or her version of the block over the network. Some nodes will receive the first one, while others — the second. As a result, one half of the system will have one chain, the other part — a different one. Each miner will work on his chain, saving the other just in case, until someone finds a nonce for the next block. A new block will continue one of the chains, making it longer and all nodes will accept it. The second network will be discarded, and the miner won’t receive his reward.
The probability that this new block will appear simultaneously in both chains, and their length will remain the same, is very small. Even less the probability of happening it again. During Bitcoin's work, the most extended chains that existed simultaneously differed in only four blocks. One of the chains always gets longer very soon.
How does the network verify that the owner sends coins himself?
The bank uses personal data, logins, and passwords to identify its owners. Bitcoin stores or uses nothing of the kind, but every node can identify the owner, and no one can spend coins from an unfamiliar wallet. Thus, each wallet has a pair of keys — public and private. All nodes know how they are connected and that they don't have another pair.
A private key is a considerable random number. It is unique as a fingerprint, it is not stored on the network, and nobody except the owner knows it. A public key is calculated from a private one so that it is impossible to restore the latter, that’s why you can show it. It can be used to check the owner without knowing the private key. It is possible due to their main property: a public key decrypts a message encrypted with a private key. The public key is sent along with the message.
In Bitcoin, the hash of the transaction record is encrypted with a private key. The result is a signature, which is different each time. You can not fit or guess it. Your signature and public key are transferred to the network along with the transaction. Any node can count the hash of the transaction, then decrypt the signature with a public key and compare the results. If they coincide, coins were sent by every owner, because only he could put a proper signature.
Since the keys are very long, they are usually shortened for convenience. It turns out to be a short string of letters and numbers, which is convenient and reduces the transaction size.
An address is created from the public key — that’s how it is connected to the private key and its owner with no possibility to restore the public key.
Simplified transaction verification
Bitcoin's blockchain is more than 170 GB. Bitcoin Core, its official wallet, downloads it at a full range. Such wallets are called hardware ones, and their nodes are full. Such nodes check new transactions and blocks and add them to their copy of the chain, ensuring network operation and transfer security. But they can be installed on computers only.
You don’t need to have a hardware wallet to spend your Bitcoins. Transactions occupy the most significant part of the block, and without them, the block can be reduced by 1000 times and placed on the mobile device. Wallets which contain an abbreviated version are called software, and their nodes are lightweight. They can not check transactions thoroughly, but they are safe enough. Hashes are used for verification.
Full nodes have a detailed map, while lightweight ones have only key points. They have to consult full nodes and hope that they will not deceive.
The reference to the transaction (due to them Bitcoins were received) is its hash, that is used to find a block, where it was contained.
To make sure that Bitcoins are not spent, the full node keeps track of the transaction from the containing block to the first one. The lightweight node checks that the operation is actually contained in the block and some more blocks, written after it.
We use a hash of all transactions, obtained according to the principle of the Merkle tree: first, the hash of each transaction is counted, then they are connected in pairs, and a common hash is counted for each pair. It continues until there is only one hash left, which is recorded to the block.
Having found a required block by the reference, a lightweight node asks a full node for a hash subtree. It includes only the hash of the required transaction and paired hashes, recalculating which you can get a hash of all transactions. If it matches the one that is written in the block, then the transaction is contained in it. If some new blocks are recorded after this block, then the Bitcoins are not spent.
A lightweight node cannot check if there are any other transactions with the same input, but it does not matter if it is connected to full nodes, which do not try to deceive it.
The hash tree protects the block from changes. If you change one transaction, the hash of the others and the block itself will be changed.
What do you need for mining?
Not every node can be used for mining. You need a unique program, a lot of energy and powerful equipment.
First miners worked with personal computers, then with video game cards. Farms were assembled out of several video game cards. But there were more and more miners, and the calculations became more complicated. Soon they needed even more powerful equipment which increased the energy costs. Then ASICs appeared — particular devices that deal with nonce counting. They are faster and consume less energy. Currently, it has become unprofitable to mine Bitcoins without ASICs.
Now, miners use ASIC farms or unite into pools to find a nonce together and share the reward. Single mining of Bitcoins on a home computer would take millions of years.
Although Bitcoin is deprived of most of the traditional shortcomings, its blockchain is not perfect. Some disadvantages are a consequence of its structure, and some were manifested because of the high popularity. But without Bitcoin, there would not have appeared other convenient and useful blockchains.
You can not cancel a transfer
You need to have private keys to create transactions. Bitcoin doesn't store them. Only the recipient can return coins. If he is unknown, it will be difficult to find him, therefore, if you send Bitcoins to the wrong address, they are unlikely to be returned.
Bitcoins are lost in case of losing private keys
Since Bitcoins exist only as a chain of transfers, they can be spent only by sending a transaction. Without a private key, the owner cannot create the correct signature, the network will not accept the transaction, and Bitcoins will get hung up in blockchain forever.
To avoid it, you need to keep a copy of the key in a safe place, so that it won’t fall into the wrong hands, but in case of deceasement, the relatives of the owner could get it.
If someone has more than one half of the network capacity, he can add only his blocks, reject any transactions and even rewrite the chain. All the unincluded transactions will disappear along with their Bitcoins. It is impossible to do it alone: you need to possess a lot of energy and computers: so many as they are already on the network. But if three or four largest pools conspire, they will have more than 50%.
In 2013, the BTC Guild pool gained more than 40% of the network capacity and recorded six blocks in a row, but did not use it: such an attack cannot be carried out unnoticed without undermining the trust of network members and hampering its operation. However, many wallets now are waiting for the creation of three-six new blocks before confirming the transaction.
Bitcoin is anonymous and transparent at the same time. On the one hand, its users are not requested to disclose the identity. On the other hand, with the help of the wallet address, it is possible to track when and where money was transferred and how much of it is kept now.
But until the owner of the key declares that the wallet belongs to him, the history of his operations in the blockchain will remain anonymous. Moreover, you can possess several addresses and wallets. If someone discovers one, you can transfer Bitcoins to another address, which nobody knows.
Such cryptos as Monero, Dash and Zcash are completely anonymous.
Limited block size
Bitcoins can be transferred to any country in just a few seconds or minutes. But when there is a lot of transactions in the queue, miners do not have time to process them, and then the transfers are delayed and the commission raises. In November 2017, it reached $ 20. That’s why it is inconvenient to transfer small amounts via Bitcoin.
In 2013, the VISA payment system processed 47 thousand transactions per second. If Bitcoin processes so much, it will grow by 8 GB every 10 minutes: plus 400 TB every year. Most of the miners and nodes will not be able to serve Bitcoin, and it will lose all the advantages over traditional systems.
The SegWit and Lightning Network projects help to close this gap without increasing the block size.
In 2017, it took about 163 kWh of energy for the registration of a single transaction in Bitcoin. It is enough for a family of three persons for a week. In general, Bitcoin and Ethereum mining took more energy than the entire population of Syria.
In other cryptos, users who have more coins, can add new blocks. The process does not depend on the equipment capacity. The owner of 1% of all coins produces 1% of new blocks. This algorithm is called Proof-of-Stake (PoS). It was applied for PeerCoin first.
Blockchain is operated by a program that cannot be interfered. In case of theft or malfunction, there is nobody to complain. You need to negotiate with other network members to change this program, but they speak different languages and live all around the world.
If everyone agrees, the programmers will change the rules, and the chain will be continued. If the opinions are divided, the chain may have a branch — fork, but it will be another blockchain already.
There is built-in voting for changes in new blockchains. But it is contrary to the idea for which the first blockchain was created — to eliminate center dependence. At the result, changes can estrange users no less than zero variations.