Blockchains are the new fad in the word of cryptocurrency; we have witnessed the remarkably growing popularity of Bitcoins. Ethereum uses a technology similar to Bitcoin, and the coin that it trades in is known as ether. There is not much difference between the two except for smart contracts that are nothing but the codes that are written using the Ethereum Virtual Machine (EVM), which automates as well as executes agreements in an immutable ledger. We will get to know more about this later. To dive in further, first we are going to go over some use cases—they're very interesting. Next we will provide an overview of the Ethereum blockchain and blockchain in general. We will look at some of the benefits and limitations of blockchain. Then, we are going to get into setting up an efficient workflow so that we can get into further chapters without anything holding us back.
Topics that we'll be covering in this chapter are as follows:
- Ethereum-based projects
- An overview of blockchain and Ethereum
- Benefits and limitations
- Setting up an efficient workflow
Ethereum is like Bitcoin, but it's for code! It's the blockchain for smart contracts and it stores immutable code and logic in the blockchain. Immutable is a very important word here. That's pretty much all you need to know about Ethereum. So, what's possible right now? Let's have a look in the following sections.
Gnosis is market-driven forecasting technology. It is based on proven scientific research. It has its own platform known as the Gnosis platform and you can build your own platform on top of it. It basically makes trading predictions. And correct predictions are given the tokens that were at stake for incorrect predictions. Visit https://gnosis.pm/ to access Gnosis.
The way it works is that you trade predictions or you bet on predictions. The following is the front page of Gnosis:
Gnosis front page
In the preceding screenshot, do note the question that is being asked on their home page. Will Dubai's world record for the largest New Year's Eve fireworks display get broken? You can vote yes or no, and by voting, your tokens are at stake, and an Oracle is then going to tell you whether the event happened or not. The blockchain will then check on that Oracle. Oracles are nothing but smart contracts that interact with the outside elements. They can store and retrieve data—this is just what an Ethereum transaction needs to make decisions. An Oracle is a trusted source, and after checking with this trusted source, you can determine in a blockchain whether the event really did happen or not, and you can be absolutely certain about it.
The following diagram explains exactly how this happens:
The Gnosis platform layers
FirstBlood is comparable to Gnosis; it is for e-sports. In cases where you are a gamer, you can sign up for a match using tokens. You can put tokens at stake to win tokens, you can put yourself in a queue in a pool of other teams or people, and you can play against them. You can even participate in tournaments. The winner of the game gets the tokens. Oracle is used to decide the outcome of a match. Visit http://firstblood.io to access FirstBlood.
This is a peer-to-peer insurance company, meaning there are no more middlemen. Currently, they are working on unemployment insurance, wherein you get paid to be unemployed! You just have to show people that you are actively looking for a job. The way they verify this is by using an Oracle similar to Gnosis and FirstBlood, but they use it to check LinkedIn and to verify that you have been applying to jobs.
Note
To learn more about Dynamis visit, www.dynamisapp.com.You can also visithttp://blog.dynamisapp.com/p2p-insurance-solutions/to gain further insight.
This is basically a decentralized music store for artists! We all know iTunes, Spotify, and so on. These are companies that are sitting in the middle of artists and their fans, but fans can't know right away how much money artists actually make from each sale. Ujo Music takes care of this by decentralizing the music store. There are no more middlemen, which means that they are a bridge between artists and fan. This certainly means it ensures more power and money for the artists. There are no worries about licensing and it delivers music services only to verified identities. To access Ujo Music, visit https://ujomusic.com/.
The way it works work is described in the screenshot; they have multiple layers and they have their licensing and payments on Ethereum. They have a persistent identity on uPort which is also built on Ethereum:
Ujo Music
The files themselves are stored in decentralized file storage, InterPlanetary File System (IPFS), and the metadata uses constellate which is also built on Ethereum.
The next project is one of my favorites.
It is a decentralized supercomputer! It does off-chain calculations. Off-chain calculations are calculations that do not happen on the blockchain; calculations are done outside of the blockchain. Then on the on-chain, it will verify these calculations. This means you can rent out your spare computing power or you can hire extra computing power if you need it. You can do this for 3D rendering, computational chemistry, AI machine learning—anything you like. To visit Golem, go to https://golem.network/.
In the following screenshot, you can see the Golem GUI. On the left, you can see a basic wallet; you can also see how much CPU, RAM, and disk space are being used. To the right, you can see a little proof of concept of three tasks being put out there, it's three Blender tasks, in this case, 3D rendering tasks:
Golem GUI
Here, we will provide a short overview of Ethereum and blockchain in general. We will have a little look under the hood so that you can get a better understanding of how Ethereum and blockchain make these great products—these great use cases that we've seen are possible.
Bitcoin was the first blockchain, but Bitcoin was only meant for payments. People started discovering that Bitcoin could be used for other scenarios; we call this Colored Coins. Bitcoin had a surprisingly open design and one guy, Vitalik Buterin, decided to start developing Ethereum on top of the Bitcoin blockchain. But, due to limitations in Bitcoin, Ethereum now has its own blockchain.
The following table shows the differences between Bitcoin and Ethereum:
Bitcoin | Ethereum |
Used for payments | Used for code and logic |
It is a digital currency | It is a smart contract platform |
Average block time/transaction processing time of 10 minutes | Average block time/transaction processing time of only 17.5 seconds |
It is not Turing complete | It is Turing complete |
Bitcoin and Ethereum are both blockchains. They both rely heavily on private/public-key cryptography, and even though Bitcoin is primarily a form of payment, both can be used to transfer value, although, with the Ethereum blockchain, value will be processed with logic. Both are completely immutable.
The following are the things to remember for blockchains:
- When something is in the blockchain, it's final. That means there's no rolling back of anything you do, so even with your code, you have to find special way to update it.
- Your private key is your digital identity, so don't lose it!
- Blockchain is not standalone; it's usually used in conjunction with other technologies, mostly frontend technology or backend technology.
Now that we've looked at an overview of blockchain, we will be having a look at some of the benefits of blockchain. We will also have a look at some of the limitations when you are developing a blockchain application, and we will have a look at how we can overcome these limitations or how we can work around them.
The following are some difficulties one can face while using blockchains:
- If you try to use blockchain where you don't need it, it can be very costly.
- Blockchains don't really do private data that well because blockchains are supposed to be public.
- Sometimes, centralization is required, and blockchains are always decentralized; that doesn't fit.
- Most blockchains don't really scale well to high usage.
- Storing big files is not really recommended because more computation means more power and more money on a public blockchain; on a private blockchain it just means more power—and you need to invest more in your infrastructure so that is also more money.
Sometimes, you just can't overcome limitations because you just have to use blockchain where you need it. Some things can be overcome, such as storing private data on a public chain. This can be done by adding some extra encryption to your data. You can store big files on the IPFS which is also decentralized—it is not a blockchain, but it is decentralized file storage and it works really well with Ethereum. The problem of scalability is solved by Ethereum's sharding: sharding means splitting the space of accounts, such as contracts, into smaller subspaces. Private chains are also available if you need them, such as J.P. Morgan's Quorum, Monax, and Bletchley. They are all Ethereum based.
Here, we will be doing some workflow setup so we can get started with developing.
The following are the things we will need for setting up the workflow:
- Google Chrome.
- MetaMask, which is a Chrome extension. We will use this to connect to and to test the blockchain.
- Node Package Manager (NPM).
- Truffle, which is our first framework. We will be using it to develop our first decentralized application.
- Ethereum-JS ganache-cli, which is a test blockchain.
Follow these steps to set up the workflow:
- Get the NPM. It is part of Node.js. You can get it at www.npmjs.com/get-npm, as shown in the following screenshot:
Getting the NPM
- Select the latest version displayed on their web page:
- Install MetaMask. To download MetaMask, visithttps://metamask.io/.
- Click on
GET CHROME EXTENSION
.- Then click on
Add to Chrome
.
- Then click on
- The preceding tool that we will be used to test our blockchain applications. Once you've installed it, a new tab will open up with a video explaining in depth how to use it and what it is.
- It is important for you to remember during this book that you can connect to the main network as well as three test networks, but you can also set up your own network, your own blockchain, and run on that. The following screenshot shows this:
MetaMask Main Network
Command to install Ethereum blockchain simulator
Installing Ethereum Simulator
Once that is done, it will tell you that it has succeeded; quit this for now because I have already reinstalled this. You can go ahead and verify it by typing ganache-cli
into your Command Prompt and verifying that it runs. The following will be the output you will get if you have installed the simulator correctly:
Ethereum Simulator
- Installing and downloading Truffle.
- Truffle also is a simple node package from truffleframework.com that you can install by copying and pasting a command into your terminal, as shown here:
Command for installing Truffle
Truffle
We have discussed different projects running on Ethereum and gained an overview of blockchain; after this, we moved on to its benefits and limitations, and how to overcome the limitations. In the end, we created a setup for our own Ethereum workflow.
In the next chapter, we will be developing our first simple decentralized payment application with Ethereum.