Chapter 1. What is Blockchain? We start with the motivations of Blockchain - the trust issues we face today and how we can solve that using decentralization. We will use a real-life example to bring about the discussion. Next, we will talk about Blockchain and how it fits into the decentralized model. By the end of this chapter readers would have a pretty solid understanding of the main Blockchain terminologies, such as mining, PoW, Merkele Tree/Root, etc. Trust Today Placement of Trusts Centralization - Problems with Trust Today Solving Trust Issues with Decentralization Blockchain - A Huge Chain of Blocks Chaining usng Hashing Functions Assembling the Transactions Mining the Blocks using Proof of Work Structure of a Blockchain Blockheaders Merkle Tree and Root Types of Nodes Confirmations Consensus Rewards for Mining Chapter 2. Implementing Your Own Blockchain This chapter basically reinforces the concept covered in Chapter 1. By implementing your own Blockchain, it makes it very useful to understand concepts like transactions, mining, consensus, etc.
Here, we implement the blockchains using Python and C#. Implementing your own Blockchain using Python Implementing your own Blockchain using C# Chapter 3. Connecting to the Ethereum Blockchain For this book, I will primarily use geth, an Ethereum client, to connect to the Ethereum blockchain. Readers will learn how to download and install geth, and use it to connect to the various Ethereum blockchains (mainnet, testnet, etc). Readers will learn about the various sync modes - fast, full, and light. Installing Geth Getting Started with Geth Connecting to the various Ethereum Blockchains Syncing with the Ethereum Blockchain Chapter 4. Creating Your Private Ethereum Test Network One feature of geth is that you can use it to create your own private test network, without connecting to the real blockchain. This makes development work much easier, and allow you to explore the Ethereum blockchain without needing to acquire ether.
Creating the Genesis Block Creating a folder for storing Blockchain Data Initiating a Blockchain Node Starting Nodes Creating Accounts Checking the Balance of an Account Ethereum Units Pairing the Nodes Performing Mining Transferring Ethers between Nodes Chapter 5. Using the Metamask Chrome Extension In order to connect to the Ethereum blockchain to deploy and consume contracts, you need to hold Ether. An easy way would be to use the MetaMask Chrome extension. The MetaMask Chrome Extension is an Ethereum wallet. This chapter will show how you can use it to obtain Ethers for testing on the Ethereum testnet. What is MetaMask? Creating Accounts Recovering Accounts Getting Ethers Transferring Ethers Connecting MetaMask to Geth Chapter 6. Introduction to Smart Contracts Now that readers are familiar with the Ethereum blockchain, it is now time to explore the most exciting feature of it - Smart Contracts. Smart contracts are written using the Solidity programming language.
This chapter goes through the syntax of the language and explores the most salient parts of the language. Solidity Hello, Solidity Comments Data Types Integer Literals Ether and Time Units Arrays Structures Enums State Variables Control Structures Functions Fallback Functions Special Variable Cryptographic Functions Inheritance Modifiers and Events Storage Layout Chapter 7. Developing and Deploying Smart Contracts This chapter dives into the details of developing and deploying the Smart contract using the Remix IDE. It also discusses how Smart Contracts can be called and tested from the command line. Using the Remix IDE Application Binary Interface (ABI) Bytecode Deploying the Smart Contract onto an Ethereum Node using Geth Invoking the Contract from a Local Node Invoking the Contract from a Another Node Calling a Smart Contract from Another Deploying a Contract Dynamically Chapter 8. Testing Smart Contracts using ganache Another tool that is useful for Smart Contract developers is Ganache. Ganache simulates an Ethereum network, and it comes with 10 pre-created accounts each credited with 100 Ethers. Using Ganache, developers can deploy their smart contract without needing to connect to the real Ethereum network.
What is ganache (formerly testrpc)? Installing ganache Deploying Smart Contracts to ganache Connecting MetaMask to ganache Importing the accounts in ganache into MetaMask Chapter 9. Using the Web3.js API Once a Smart contract is deployed, how does the end user use it? In this chapter, readers will learn how to use the Web3.js APIs in their Web application to consume Smart contracts. Readers will learn how Web3.js works and the techniques for connecting to the different Ethereum in the background. What is Web3.js? Installing Web3.
js Consuming a contract using Web3.js Loading the page using file:/// Loading the page using http:// Chapter 10. Smart Contract Events When a Smart Contract has finished performing a task, how does it inform the user? This is achieved using events. In this chapter, readers will extend some of the contracts developed in the earlier chapters to use events to extend the usefulness of the application. What are events? Defining events in your contract Handling events in your web Application Chapter 11. Project - Online Lottery Now that readers have learned all the fundamental building blocks of blockchain, it is now time to put them into a working example. This chapter implements an online betting system using Smart Contracts. How the Game Works Creating the contract Testing the Contract using the Remix IDE Creating the Web Frontend Testing the App Chapter 12.
Creating Your Own ERC20 Tokens ICOs are all the rage these days! This bonus chapter talks about tokens and how you can create tokens using Smart Contracts. Once readers have learned how to create tokens, I will show them how to use tokens to pay for services in Smart Contracts. What are Tokens? Tokens Standards - ERC20 and ERC223 Creating Token Contracts Deploying the Token Contracts Adding Tokens to MetaMask Paying for Smart Contracts using Tokens.