Why Programmers Need to be Learning about Blockchain
Maybe you’ve missed your chance to turn a couple hundred dollars into millions with Bitcoin. Fear not — there are nearly one thousand other cryptocurrencies created since, many with real potential. As a developer though, the focus should not only be cryptocurrency investing. More important is blockchain, the software that powers cryptocurrencies and smart contracts.
In simple terms, what is blockchain?
Blockchain is a decentralized, distributed ledger of transactions (blocks), each of which holds a link to the previous block. Hence, the name “blockchain” refers to the linking or chaining of blocks.
Centralized Transactions Economy
This TED Talks presented by Bettina Warburg on blockchain examines a brief history of the role uncertainty plays when making transactions. For instance, when purchasing a product, both the buyer and seller need assurances: that the other person is who she claims to be, that the product is as advertised, that the buyer compensates the seller, that the seller gives the buyer the product, and that there is recourse if any of the terms of the transaction are not met. Currently, our economy relies on institutions — banks, governments, and corporations — as central authorities to reduce uncertainty in transactions.
Our current model of the Internet is also a centralized system. Data is stored on web servers. When we want to receive data on the Internet, such as view a website or download a file, our web browser sends a request to the web server that hosts that data, and the web server responds to that request by providing the requested data. A centralized Internet is not fault tolerant: if a server goes down, the entire system is affected.
In complex terms, what is blockchain?
Blockchain is a cryptographically secure database containing an immutable history of transactions where each transaction contains a digital signature. A block’s digital signature is generated using a cryptographic hash function that links the new block to the previous block. In essence, it’s just a massive ledger of transaction history.
Blockchain from a programmer’s perspective
A Block object would store three fields: the previous block’s hash value, a string array containing the list of transactions, and its own hash value. A new block is created by passing in the previous block’s hash value and the array of transactions to the Block constructor. The block’s hash value is generated by passing in the previous hash value and the transactions array’s hash into the hash code function. The blockchain is immutable in that once constructed, its fields are encapsulated in the block and can only be accessed through getter methods.
A blockchain is simply represented as an ArrayList of blocks. The first block in the blockchain is called the genesis block. To construct the genesis block, we simply pass in 0 as the previous hash value along with the corresponding array of transactions. After constructing the genesis block, we add it to the blockchain. Then, the second block is constructed using the hash value of the genesis block and the transaction array.
Running this program produces the following output:
The idea is, a transaction cannot be altered once it has been created. Changing even just one character, such changing the genesis transaction from 10 coins to 100 coins, would generate entirely different output from the hash code function.
Decentralization through Blockchain
The transaction history of a blockchain is stored across a peer-to-peer network of personal computers. These personal computers both utilize and facilitate the blockchain system, and no individual person or entity owns it. This makes the blockchain network both decentralized and distributed. Unlike in the client-server model, the blockchain does not have a single point of failure. Rather than a single entity providing assurances, transactions are validated by consensus across the network.
Big companies are getting involved
Blockchain technology has the potential to solve problems in the transactional economy. So it’s no surprise that blockchain has captured the attention of major banks and companies. Microsoft is one of many companies getting involved in the Decentralized Identity Foundation (DIF). The project’s mission is to solve problems related to online identity by using blockchain technology. This is just one of many examples. Currently, many companies, including IBM and Microsoft, are looking to hire blockchain developers. Read this article to see a list of other companies getting involved in blockchain technology.
Check out https://blockchaintrainingalliance.com/ to jumpstart your blockchain education.