Learn Blockchain Programming with JavaScript
Build your very own Blockchain and decentralized network with JavaScript and Node.js
Eric Traub
BIRMINGHAM - MUMBAI
Learn Blockchain Programming with JavaScript
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Kunal Chaudhari
Acquisition Editor: Devanshi Doshi
Content Development Editor: Onkar Wani
Technical Editor: Sachin Sunilkumar
Copy Editor: Safis Editing
Project Coordinator: Kinjal Bari
Proofreader: Safis Editing
Indexer: Priyanka Dhadke
Graphics: Alishon Mendonsa
Production Coordinator: Jyoti Chauhan
First published: November 2018
Production reference: 1291118
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78961-882-2
www.packtpub.com
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Packt.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the author
Eric Traub currently works as a software engineer in New York City. He has extensive experience working as a teacher and instructing people in a variety of different subjects. He changed his career from teaching to software engineering because of the excitement it brings to him and the passion that he has for it. He is now lucky enough to have the opportunity to combine both of these passions software engineering and teaching!
First of all, I would like to thank Packt Publishing for making this book possible. It has been a great experience working with you to bring this project to life. I would also like to thank everyone who has supported me in this process, including my family and friends. Finally, I want to give a special thanks to my parents, who have shown unconditional love and support for me in everything I do.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
With the help of this book, you'll get to build your own blockchain prototype and a decentralized network by using the JavaScript programming language. Building your own blockchain will help you understand various concepts related to blockchains, such as how blockchain technology works under the hood, how decentralized blockchain networks function, and how to code the blockchain and decentralized network using JavaScript. Also, you will get to learn why blockchain is such a secure and valuable technology.
The blockchain that you'll build throughout this book will have functionalities that are similar to those you would find on a real-life blockchain, such as Bitcoin or Ethereum. Your blockchain will have functionalities such as the ability to mine new blocks, create new and immutable transactions, and perform a proof of work to secure the blockchain. In addition to these, your blockchain will consist of many other important features. You'll get to explore those as you read further through the chapters.
When you have completed this book, you will have a thorough understanding of how blockchain technology actually works and why this technology is so secure and valuable. You will also have a deep understanding of how decentralized blockchain networks function and why decentralization is such an important feature for securing the blockchain.
Who this book is for
Learn Blockchain Programming with JavaScript is for JavaScript developers who wish to learn about blockchain programming or build their own blockchain using JavaScript frameworks.
What this book covers
, Setting Up the Project , covers what a blockchain actually is and enables readers to understand how it functions. Then, you'll get to learn how to set up a project in order to create your very own blockchain.
, Building a Blockchain , covers how to add various functionalities to your blockchain. You will implement the functionalities in the blockchain, creating some amazing methods such as createNewBlock, creatNewTransaction, and getLastBlock. Once these methods are added to the blockchain, you will test them to verify that they are working perfectly. Also, you'll get to learn about the hashing method, that is, SHA256 hashing, and then implement a method to generate a hash for your block data. Also, you'll get to explore what a proof of work is, how it benefits the blockchain, and how to implement it.
, Accessing the Blockchain through an API , explains how to set up Express.js in your project, as well as how to use it to build the API/server. Then, you will build various server endpoints for your blockchain and test these endpoints to verify whether or not they are working properly.
Next page