IN THIS CHAPTER
Understanding ether and trading Setting up an Ethereum development environment Developing blockchain applications Blockchain technology is the most disruptive technology introduced in our generation, and Ethereum is by far the most popular blockchain implementation in use today. You canât read many technology articles or blogs without seeing something about how blockchain changes everything. Although some claims seem to be a little far-fetched, blockchain technology really is a game-changer.
Blockchain, which first burst on the scene in 2008, has gained global notoriety for what it has already changed and what is coming. At first, blockchain was all about a new type of electronic currency. But now, partially thanks to Ethereum, blockchain is so much more than a new way to pay for things. Itâs a new way to think about things. It enables people and businesses to conduct business without many of the obstacles that have existed in trade relations for centuries.
In this book you learn about what blockchain is and why it is viewed as so radical. You discover how powerful Ethereum is in diverse domains and how you can harness its promise and power in your own organizations. If you want to learn what Ethereum is and how it can work for you without having to trudge through hundreds of pages of theory and background, this is the book for you.
Describing Blockchain Technology
You learn a lot more about blockchain technology in Chapter 2, but before you meet Ethereum, you need to know a little of Ethereumâs backstory.
If you already know what blockchain is, this section will be like watching yet another depiction of why Bruce Wayne became Batman. Feel free to skim it and move on to the next section. There are only so many ways you can kill Thomas and Martha Wayne.
Blockchain technology was introduced to support a new type of digital currency that you can trade in a trustless environment. Traditional currency exchanges require a trusted third party between the parties. Even if a buyer provides coins or bills to a seller at the point of transaction, some government provides the guarantee of the currencyâs value. There is always a middleman. If the exchange involves a payment card or check, other financial institutions participate to handle the transfer of funds between parties.
In 2008, Satoshi Nakamoto published a paper that changed everything. Nakamotoâs paper described a new way to store and distribute data with verifiable integrity among a group of nodes that donât trust one another. You learn more about how Nakamotoâs proposal works, and about bitcoin, the cryptocurrency proposed in the paper, in Chapter 2. At this point, the most important takeaway is that this paper showed how to take the requirement for a trusted (and omnipotent) central authority out of the mix. Using this new technology, called blockchain, application developers can create environments in which nodes that do not trust one another can share data that they can trust.
The idea is based on several concepts that are simple to consider but difficult to put into practice. First, data is logically presented as a ledger. The data isnât really stored that way; you can just think of it as a ledger. A ledger is a way of recording data as transactions occur. One interesting feature of this ledger is that you can only add data to it. You canât change anything after youâve added it. So, the only two operations you can perform on this ledger are add and read. We refer to the âadd onlyâ property as the immutability property. In short, blockchains are immutable. As youâll see, immutability is crucial for the technique to work.
Another feature is that data is added to this ledger in blocks. Blocks are collections of transactions, each with an ownerâs address. Addresses are the unique IDs of accounts in our ledger system. When there are enough transactions to make a new block, some of the blockchain participants begin a process of adding a new block to the ledger. Each new block is linked to the previous block, making a chain. Thatâs where the term blockchain comes from. A blockchain is basically a bunch of blocks where each block is connected to its predecessor.
Then, the entire set of blocks, or the entire blockchain, is shared with other participants. These participants are called nodes. These nodes communicate with one another and each stores an exact copy of the blockchain. Many blockchain networks are made up of thousands of nodes, and keeping all of the copies of the blockchain in sync (that is, ensuring that every copy is the same) is another revolutionary feature of blockchain technology.
Blockchain technology is built on a democracy governance mode. Before any new block is added to the blockchain, a majority of nodes must agree that the new block is valid. All nodes agree to accept the majority decision. Thatâs how the blockchain stays in sync. Nodes essentially vote on all new blocks. Different blockchains use different voting methods, but one of the more common ones requires nodes to solve very hard mathematical puzzles to earn the right to add a new block to the blockchain. As an incentive for doing the hard work, the node that solves the puzzle first gets a reward. The reward encourages nodes to pitch in and help do the hard work of solving verification puzzles.
Part of the puzzle solution involves creating a mathematical hash of the previous block. By storing the previous blockâs hash in the current block, every node can quickly determine if any block has changed. Each node periodically scans the blockchain to ensure that nothing has changed. This is how nodes can be sure that the blockchain is the same across the entire network. And, because no block can change after it is added to the blockchain, you never have to worry about overwriting data.
Putting it all together, a blockchain makes it possible to share a set of data with many nodes that you donât trust. You can trust the democracy of the network, though. As long as you can trust that more than half of the nodes on the blockchain network are going to be honest, you can trust the blockchain.
The last big advantage to blockchain technology is that you can put rules of operation in blocks on the blockchain as well. These rules are called smart contracts. A smart contract is just a program that lives in a blockchain block and governs how data is added to the blockchain. Because all blockchain data is immutable, even the smart contract code is immune from changes. Thatâs how you can exchange currency without a bank. As long as there are rules that dictate how a currency exchange is carried out, transaction data can be recorded on the blockchain and be part of the permanent ledger.
For example, suppose you want to buy a car. You have enough digital currency in your blockchain account to buy the car, and the car owner has the carâs title stored in the blockchain. You can offer to buy the car and if the seller accepts your offer, a smart contract handles the transaction. The smart contract would verify that the title is owned by the seller and that you have enough money in your account to make the purchase. If those two requirements are met, the smart contract would transfer the sales amount into the sellerâs account and transfer the title to your account. Without any middleman, you have purchased a car and paid for it without carrying a wad of cash around.
Of course, you really purchased a title to a car. Blockchain handles digital assets. You still have to physically get the keys and the car from the seller.
Introducing Ethereum
Bitcoin was the first blockchain technology application. It was revolutionary and defined the first widely used digital currency, called cryptocurrency. The crypto part of the name refers to the use of cryptographic hashes to ensure the integrity of the blockchain. The shared ledger literally keeps a copy of every cryptocurrency transaction that gets verified by all nodes. Using this approach, bitcoin created a permanent record of every exchange of their cryptocurrency. And, because account owners are identified only by an address, bitcoin has always enjoyed a measure of anonymity.
Although bitcoin addresses arenât linked directly to people, many exchanges have records of identities that are related to addresses. At some point, you have to exchange your cryptocurrency for real currency. That switchover point is where many law enforcement officials focus when theyâre trying to track down criminals using cryptocurrency.
As bitcoin became more and more popular, researchers began to see more applications for blockchain technology beyond cryptocurrency. In 2013, Vitalik Buterin, the cofounder of Bitcoin Magazine, published a whitepaper that proposed a new, more functional blockchain implementation. This new proposal was for the Ethereum blockchain. After gaining interest and attracting technical and financial support, the Ethereum Foundation, a Swiss non-profit organization, was founded and became the developer of Ethereum.
Ethereum wasnât created just to exchange cryptocurrency. In fact, it was designed from the beginning to be different. The core features of Ethereum are the smart contract and ether. Ether is the native cryptocurrency that Ethereum supports, although you can create your own tokens to exchange value in many other forms. Smart contracts provide an execution environment that ensures integrity across all nodes. Any code that executes on one node executes the same way on all nodes. This guarantee makes it possible to deploy a wide range of applications across untrusted environments.
The foundational guarantees Ethereum provides support many types of value exchanges without the concern about fraud, censorship, or any involvement by a third party. When you interact with an Ethereum application, you donât have to rely on any intermediary to broker your transactions. You donât need a bank, wholesaler, or transaction broker to provide trust. As a result of Ethereumâs disintermediation, you can often complete transactions faster, with far lower service fees and without requiring approval from external authorities.
Ethereum is a comprehensive, decentralized application platform that expands the range of capabilities beyond what was possible before blockchain technology. Whereas legacy solutions to data and p...