Blockchain, the underlying technology of Bitcoin, is also a hot word in 2016. Although Bitcoin is still controversial, its related technology - blockchain is gradually becoming the focus of the financial industry. This book first introduces the basic principles and technologies of blockchain, such as basic cryptography, algorithms, P2P protocols, scripts, and so on. Then it takes Bitcoin and Ethereum blockchain platforms as examples to guide readers to build test environments, compile blockchains, establish private chains and test chains, and help developers create their own private chains to achieve specific programming examples of blockchain, such as smart contracts and mining.