Chapters
Chapter 1 - Blockchain 101
Contents
- What is blockchain?
- How are blocks connected?
- Blockchains and decentralization
- The Byzantine Generals Problem
- Why do blockchains need to be decentralized?
- What’s the peer-to-peer network?
- What are blockchain nodes?
- Public vs. private blockchains
- How do transactions work?
- How to make Bitcoin transactions
- Who invented blockchain technology?
- Pros and cons of blockchain technology
What is blockchain?
A blockchain has certain unique properties. There are rules about how data can be added, and once the data has been stored, it's virtually impossible to modify or delete it.
To analogize, suppose that you have a spreadsheet with two columns. In the first cell of the first row, you put whatever data you want to hold.
A database where each entry is linked to the last.
How are blocks connected?
The hashes used in blockchains are interesting, in that the odds of you finding two pieces of data that give the exact same output are astronomically low. Like our identifiers above, any slight modification of our input data will give a totally different output.
Let's illustrate with SHA256, a function used extensively in Bitcoin. As you can see, even changing the capitalization of letters is enough to completely scramble the output.
Input data | SHA256 output |
---|---|
Binance Academy | 886c5fd21b403a139d24f2ea1554ff5c0df42d5f873a56d04dc480808c155af3 |
Binance academy | 4733a0602ade574551bf6d977d94e091d571dc2fcfd8e39767d38301d2c459a7 |
binance academy | a780cd8a625deb767e999c6bec34bc86e883acc3cf8b7971138f5b25682ab181 |
Each block contains a fingerprint of the previous.
Blockchains and decentralization
We've explained the basic structure of a blockchain. But when you hear people talking about blockchain technology, they’re likely not just talking about the database itself, but the ecosystems built around blockchains.
The Byzantine Generals Problem
Each must decide whether to attack or retreat. It doesn't matter whether they attack or retreat, as long as all generals agree on a common decision. If they decide to attack, they will only be successful if they move in at the same time. So how do we ensure that they can pull this off?
Sure, they could communicate via messenger. But what if the messenger is intercepted with a message that says "we’re attacking at dawn," and that message is replaced with “we're attacking tonight”? What if one of the generals is malicious and intentionally misleads the others to ensure they're defeated?
All generals are successful when attacking (left). When some retreat while others attack, they will be defeated (right).
We need a strategy wherein consensus can be reached, even if participants turn malicious or messages get intercepted. Not being able to maintain a database isn't a life-and-death situation like attacking a city without reinforcements, but the same principle holds. If there's no one to oversee the blockchain and to give users “correct” information, then the users must be able to communicate amongst themselves.
Why do blockchains need to be decentralized?
You could, of course, operate a blockchain by yourself. But you'd end up with a database that's clunky in comparison to superior alternatives. Its real potential can be exploited in a decentralized environment – that is, one where all users are equal. That way, the blockchain can’t be deleted or maliciously taken over. It's a single source of truth that anyone can see.
What's the peer-to-peer network?
The peer-to-peer (P2P) network is our layer of users (or the generals in our previous example). There's no administrator, so instead of phoning into a central server anytime they want to exchange information with another user, the user sends it directly to their peers.
Consider the graphic below. On the left, A needs to route their message through the server to get it to F. On the right-hand side, however, they're connected without an intermediary.
A centralized network (left) vs. a decentralized one (right).
Normally, the server holds all the information that users need. When you access Binance Academy, you're asking its servers to feed you all the articles. If the website goes offline, you won't be able to see them. However, if you downloaded all of the content, you could load it on your computer without querying Binance Academy.
In essence, that's what every peer does with the blockchain: the entire database is stored on their computer. If anyone leaves the network, the remaining users will still be able to access the blockchain, and share information with each other. When a new block is added to the chain, the data is propagated across the network so that everyone can update their own copy of the ledger.
What are blockchain nodes?
Nodes are simply what we call the machines connected to the network – they're the ones that store copies of the blockchain, and share information with other machines. Users don't need to manually handle these processes. Generally, all they need to do is download and run the blockchain’s software, and the rest will be taken care of automatically.
Public vs. private blockchains
As you may know, Bitcoin laid the foundation for the blockchain industry to grow into what it is today. Ever since Bitcoin has started proving itself as a legitimate financial asset, innovators have been thinking about the potential of the underlying technology for other fields. This has resulted in an exploration of blockchain for countless use cases outside of finance.
Looking to get started with cryptocurrency? Buy Bitcoin on Binance!
How do transactions work?
This isn’t too dissimilar to what goes on with a blockchain. After all, it’s also a database. The key difference is that there isn’t a single party performing the checks and updating the balances. All of the nodes must do it.
How to make Bitcoin transactions
To illustrate how you can make Bitcoin transactions, let’s imagine two different scenarios. The first consists of you withdrawing bitcoins from Binance, and the second of sending funds from your TrustWallet to your Electrum wallet.
How to withdraw bitcoins from Binance
How to send bitcoins from Trust Wallet to Electrum
Alternatively, you can go back to Trust Wallet and tap on the [–] icon to scan the QR code pointing to your Electrum address.
Looking to get started with cryptocurrency? Buy Bitcoin on Binance!
Who invented blockchain technology?
Blockchains make heavy use of hash functions and cryptography, which were in existence for decades prior to the release of Bitcoin. Interestingly, the blockchain’s structure could be traced back to the early 1990s, though it was merely used for timestamping documents such that they couldn’t be altered later.
Pros and cons of blockchain technology
Properly-engineered blockchains solve a problem that plagues stakeholders in a number of industries, ranging from finance to agriculture. A distributed network presents many advantages over the traditional client-server model, but it also comes with some trade-offs.
Pros
One of the immediate benefits noted in the Bitcoin white paper is that payments could be transmitted without involving an intermediary. Subsequent blockchains have taken this even further, allowing users to send all kinds of information. Eliminating counterparties means that there’s less risk for users involved, and results in lower fees as there is no intermediary taking a cut.
As we mentioned earlier, a public blockchain network is also permissionless – there’s no barrier to entry since there’s no one in charge. If a prospective user can connect to the Internet, then they’re able to interact with other peers on the network.
Many would argue that the most important quality of blockchains is that they have a high degree of censorship-resistance. To cripple a centralized service, all that a malicious actor would need to do is target a server. But in a peer-to-peer network, every node acts as a server of its own.
A system like Bitcoin has over 10,000 visible nodes scattered around the world, making it virtually impossible for even a well-resourced attacker to compromise the network. It should be noted that there are many hidden nodes, too, which aren’t visible to the broader network.
Cons
Blockchains are not silver bullets to every problem. In being optimized for the advantages in the previous section, they end up lacking in other areas. The most obvious obstacle to mass adoption of blockchains is that they don’t scale very well.
This is true of any distributed network. Since all participants must stay in sync, new information can’t be added too fast as nodes would be unable to keep up. Therefore, developers tend to intentionally limit the speed at which the blockchain can update to ensure that the system remains decentralized.
For users of a network, this can manifest itself in lengthy waiting periods if too many people are trying to make transactions. Blocks can only hold so much data, and they’re not added to the chain instantly. If there are more transactions than can fit in the block, then any additional ones must wait for the next block.
Another possible con of decentralized blockchain systems is that they can’t easily be upgraded. If you’re building your own software, you can add new features as you please. You don’t need to work with others or ask for permission to make modifications.
In an environment with potentially millions of users, making changes is considerably more difficult. You could change some of the parameters of your node software, but you’d eventually find yourself separated from the network. If the modified software is incompatible with other nodes, they will recognize this and refuse to interact with your node.
Suppose you wanted to change a rule about how big blocks can be (from 1MB to 2MB). You could try sending this block to nodes you’re connected to, but they have a rule that says “do not accept blocks over 1MB”. If they receive anything bigger, they will not include it in their copy of the blockchain.
Chapter 2 - How does blockchain work?
Contents
- How are blocks added to the blockchain?
- Mining (Proof of Work)
- Staking (Proof of Stake)
- Other consensus algorithms
- Can I revert blockchain transactions?
- What is blockchain scalability?
- Why does blockchain need to scale?
- What is a blockchain fork?
How are blocks added to the blockchain?
We’ve covered a lot so far. We know that nodes are interconnected and that they store copies of the blockchain. They communicate information about transactions and new blocks to each other. We’ve already discussed what nodes are, but you might be wondering: how are new blocks added to the blockchain?
There’s no single source to tell users what should be done. Because all nodes have equal power, there needs to be a mechanism for fairly deciding who can add blocks to the blockchain. We need a system that makes it expensive for users to cheat but rewards them for acting honestly. Any rational user will want to act in a way that is economically beneficial to them.
Because the network is permissionless, block creation needs to be accessible to anyone. Protocols often ensure this by requiring the user to put some “skin in the game” – they must put their own money at risk. Doing so will allow them to participate in block creation, and if they generate a valid one, they’ll be paid out a reward.
Mining (Proof of Work)
The puzzle requires users to hash transactions and other information included in the block. But for the hash to be considered valid, it must fall below a certain number. Since there’s no way of predicting what a given output will be, miners have to keep hashing slightly modified data until they find a valid solution.
Remember how we said earlier that it’s practically impossible to reverse a hash, but it’s easy to check it? When a miner sends a new block to the rest of the network, all the other nodes use it as the input in a hash function. They simply need to run it once to verify that the block is valid under the rules of the blockchain. If it isn’t, the miner doesn’t receive the reward, and they’ll have wasted electricity for nothing.
The first Proof of Work blockchain was Bitcoin’s. Since its creation, many other blockchains have adopted the PoW mechanism.
Pros of Proof of Work
- Tried-and-tested – to date, Proof of Work is the most mature consensus algorithm and has secured hundreds of billions of dollars’ worth of value.
- Permissionless – anyone can join the mining competition or simply run a validating node.
- Decentralization – miners compete against each other to produce blocks, which means that the hash power is never controlled by a single party.
Cons of Proof of Work
- Wasteful – mining consumes a tremendous amount of electricity.
- Increasingly high barriers to entry – as more miners join the network, protocols increase the difficulty of the mining puzzle. To remain competitive, users must invest in better equipment. This might price out a lot of miners.
- 51% attacks – though mining promotes decentralization, there is the possibility that one miner acquires the majority of the hash power. If they do, they can theoretically undo transactions and undermine the security of the blockchain.
Staking (Proof of Stake)
In Proof of Work systems, the thing that incentivizes you to act honestly is the money you’ve paid for mining computers and electricity. You won’t get a return on your investment if you don’t mine blocks correctly.
Different implementations have different variations, but once a validator stakes their units, they can be randomly selected by the protocol to announce the next block. In doing so correctly, they’ll receive a reward. Alternatively, there might be multiple validators that agree on the next block, and a reward is distributed proportionately to the stake each has put forward.
Pros of Proof of Stake
- Environmentally-friendly – the carbon footprint of PoS is a fraction of that of PoW mining. Staking removes the need for resource-intensive hashing operations.
- Faster transactions – since there’s no need for spending additional computing power on arbitrary puzzles set by the protocol, some proponents of PoS argue that it could increase transaction throughput.
- Staking rewards and interest – instead of going to miners, rewards for securing the network are paid directly to token holders. In some cases, PoS allows users to make passive income in the form of airdrops or interest, simply by staking their funds.
Cons of Proof of Stake
- Relatively untested – PoS protocols are yet to be tested on a large scale. There may be some undiscovered vulnerabilities in its implementation or cryptoeconomics.
- Plutocracy – there are concerns that PoS encourages a “rich get richer” ecosystem, as validators with a large stake tend to earn more rewards.
- Nothing-at-stake problem – in PoW, users can only “bet” on one chain – they mine on the chain they believe to be the most likely to succeed. During a hard fork, they can’t bet on multiple ones with the same hash power. However, validators in PoS can work on multiple chains with little added costs, which might cause economic problems.
Other consensus algorithms
We won’t get into them here, but if you’re interested, check out the following articles:
- Delayed Proof of Work Explained
- Leased Proof of Stake Consensus Explained
- Proof of Authority Explained
- Proof of Burn Explained
Can I revert blockchain transactions?
With that said, many different implementations of blockchain exist, and the most fundamental difference between them is how they reach consensus within the network. This means that, in some implementations, a relatively small group of participants may garner enough power within the network to effectively revert transactions. This is especially concerning for altcoins that run on small networks (with low hash rates due to little mining competition).
What is blockchain scalability?
A number of different solutions have been either proposed or implemented to mitigate some of the performance drawbacks of blockchains. At this point, however, there isn’t a clear best approach. It’s likely that many different solutions need to be trialed until there are more straightforward answers to the scalability problem.
There may be clear advantages to both. On-chain scaling solutions could be reducing the size of transactions, or even just optimizing how data is stored in blocks. On the other hand, off-chain solutions involve batching transactions off of the main blockchain, and only adding them later. Some of the most notable off-chain solutions are called sidechains and payment channels.
Why does blockchain need to scale?
If blockchain systems are to compete with their centralized counterparts, they need to be at least as performant as them. Realistically, though, they’ll probably have to perform even better to incentivize developers and users to switch over to blockchain-based platforms and applications.
This means that when compared to centralized systems, using blockchains needs to be faster, cheaper, and easier both for developers and users. Not an easy feat to achieve while maintaining the defining characteristics of blockchains we’ve discussed earlier.
What is a blockchain fork?
Bear in mind that blockchains are distributed networks. Once the software is upgraded, thousands of nodes scattered around the world need to be able to communicate and implement the new version. But what happens if participants can’t agree on what upgrade to implement? Typically, there isn’t an organization with an established decision flow to decide. This leads us to soft and hard forks.
Soft forks
If there’s a general agreement on how an upgrade should look like, it’s a relatively simple matter. In a scenario like this, the software is updated with a backward-compatible change, meaning that nodes that are updated can still interact with nodes that aren’t. In reality, though, it’s expected that nearly all nodes will upgrade over time. This is called a soft fork.
Hard forks
A hard fork is more complicated. Once implemented, the new rules will be incompatible with the old rules. So, if a node that’s running the new rules tries to interact with a node that’s running the old rules, they won’t be able to communicate. This results in the blockchain splitting into two – in one, the old software is running, in the other, the new rules are implemented.
After the hard fork, there are essentially two different networks running two different protocols in parallel. It’s worth noting that at the time of the fork, the balances of the blockchain’s native unit are cloned from the old network. So, if you had a balance on the old chain at the time of the fork, you’ll also have a balance on the new one.
Chapter 3 - What is blockchain used for?
Contents
- Blockchain for supply chains
- Blockchain and the gaming industry
- Blockchain for healthcare
- Blockchain remittance
- Blockchain and digital identity
- Blockchain and the Internet of Things (IoT)
- Blockchain for governance
- Blockchain for charity
- Blockchain for speculation
- Crowdfunding with blockchain
- Blockchain and distributed file systems
Blockchain for supply chains
Efficient supply chains are at the core of many successful businesses and concern themselves with the handling of goods from the supplier to the consumer. The coordination of multiple stakeholders in a given industry has traditionally proven difficult. However, blockchain technology could allow for new levels of transparency in many industries. An interoperable supply chain ecosystem that revolves around an immutable database is just what many industries need to become more robust and reliable.
Blockchain and the gaming industry
The gaming industry has become one of the biggest entertainment industries in the world, and it could greatly benefit from blockchain technology. Typically, gamers tend to be at the mercy of game developers. In most online games, gamers are forced to rely on the developers’ server space and follow their ever-changing sets of rules. In this context, blockchain could help decentralize the ownership, management, and maintenance of online games.
Blockchain for healthcare
Storing medical records in a reliable manner is vital for any healthcare system, and the reliance on centralized servers leaves sensitive information in a vulnerable position. The transparency and security of blockchain technology make it an ideal platform on which to store medical records.
In cryptographically securing their records on a blockchain, patients could maintain their privacy, while being able to share their medical information with any healthcare institution. If all participants of the currently fragmented healthcare system could tap into a secure, global database, information flow would be much faster between them.
Blockchain remittance
Sending money internationally is a hassle with traditional banking. Predominantly due to a convoluted network of intermediaries, the fees and settlement times make using traditional banks both expensive and unreliable for urgent transactions.
Cryptocurrencies and blockchains eliminate this ecosystem of middlemen and can allow for cheap, rapid transfers around the world. While blockchains undoubtedly sacrifice performance for some of their desirable properties, a range of projects are harnessing the technology to allow for cheap, near-instant transactions.
Looking to get started with cryptocurrency? Buy Bitcoin on Binance!
Blockchain and digital identity
Blockchain technology allows users to take ownership of their data and selectively reveal information to third parties only when it’s needed. This type of cryptographic magic could allow for a smoother experience online without sacrificing privacy.
Blockchain and the Internet of Things (IoT)
Blockchain for governance
Distributed networks can define and enforce their own forms of regulation in the shape of computer code. It’s unsurprising then that blockchain may have a chance at disintermediating various governance processes on the local, national, or even international level.
Blockchain for charity
Charity organizations are often impeded by the limitations of how they can accept funds. Even more frustratingly, the ultimate destination of the donated funds can be hard to precisely track, which undoubtedly discourages many from supporting these organizations.
Blockchain for speculation
Undoubtedly, one of the most popular uses of blockchain technology is speculation. Frictionless transfers between exchanges, non-custodial trading solutions, and a growing ecosystem of derivatives products make it an ideal playing field for all types of speculators.
Due to its inherent properties, blockchain is an excellent instrument for those willing to take the risk of participating in such a sprouting asset class. Some even think that once the technology and the surrounding regulation matures, the global speculative markets may all be tokenized on the blockchain.
Crowdfunding with blockchain
Blockchain and distributed file systems
Distributing file storage on the Internet has many benefits compared to conventional centralized alternatives. Much of the data stored in the cloud relies on centralized servers and service providers, which tend to be more vulnerable to attacks and data loss. In some cases, users may also face accessibility problems due to censorship from centralized servers.
From the user perspective, blockchain file storage solutions work just like other cloud storage solutions – you can upload, store, and access files. What’s going on in the background, however, is quite different.
When you upload a file to a blockchain storage, it’s distributed and replicated across several nodes. In some cases, each node will store a different portion of your file. They can’t do much with the partial data, but you can later request the nodes to provide each part, so you can combine them to get the complete file back.
The storage space derives from the participants who provide their storage and bandwidth to the network. Typically, these participants are economically incentivized to provide those resources, and economically punished if they don’t follow the rules or fail to store and serve files.
You could think of this type of network as one similar to Bitcoin. In this case, however, the main goal of the network isn’t to support monetary value transfers but to enable censorship-resistant, decentralized file storage.