paint-brush
A 101 Noob Intro to Understanding Smart Contracts on Hyperledger Fabricby@horeaporutiu
2,278 reads
2,278 reads

A 101 Noob Intro to Understanding Smart Contracts on Hyperledger Fabric

by Horea BlockchainNovember 20th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

This is the question I get every time I do a talk about Hyperledger Fabric. So this post will serve as my official answer to those that have asked in the past, and those that will ask in the future ⏳. I will outline <strong>my favorite material that has helped me get a good grasp on Hyperledger Fabric</strong>, and <a href="https://hackernoon.com/tagged/blockchain" target="_blank">blockchain</a> in general. I will first start with general blockchain concepts as implemented by <a href="https://hackernoon.com/tagged/bitcoin" target="_blank">Bitcoin</a> and then move towards more specific Hyperledger reading materials. <strong>Having a solid understanding of how Bitcoin works, and the public key cryptography that Bitcoin uses to transact securely without double-spending is essential to understanding how Hypereledger works.</strong>

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - A 101 Noob Intro to Understanding Smart Contracts on Hyperledger Fabric
Horea Blockchain HackerNoon profile picture

How do I get started with dapp (decentralized app) development on Hyperledger Fabric Platform?

This is the question I get every time I do a talk about Hyperledger Fabric. So this post will serve as my official answer to those that have asked in the past, and those that will ask in the future ⏳. I will outline my favorite material that has helped me get a good grasp on Hyperledger Fabric, and blockchain in general. I will first start with general blockchain concepts as implemented by Bitcoin and then move towards more specific Hyperledger reading materials. Having a solid understanding of how Bitcoin works, and the public key cryptography that Bitcoin uses to transact securely without double-spending is essential to understanding how Hypereledger works.

Blockchain 101

☕️+ 📖= understanding ⛓

  1. Read the holy bible of blockchain — Satoshi’s Bitcoin whitepaper: https://bitcoin.org/bitcoin.pdf
  2. Read Mastering Bitcoin Chapters 1,2,4 by Andreas M. Antonopoulos. You can read the book for free here. Chapter 4 is especially important to understand since it goes over the basics of public key cryptography, and how that applies to cryptocurrency.
  3. Read Blockchain For Dummies — this is a good intro book to understand more industry-specific blockchain use-cases that go outside of the cryptocurrency landscape.
  4. Take the Blockchain Essentials course. This 2-hour course goes over the main concepts to understand when developing applications with Hyperledger for the Enterprise.
  5. Take the Intro to Hyperledger Fabric for Developers course by B9Lab. They do a great job of explaining all the main concepts of the blockchain, and go through code samples to run your first smart contract.
  6. Take the IBM Blockchain Foundation Developer course on Cognitive.ai. This course is great since it goes over Hyperledger Composer, a great tool for building proof-of-concept applications with Hyperledger.
  7. Watch Ivan Vankov YouTube series on Hyperledger Fabric. He has the best videos (other than mine 😉) on Hyperledger Fabric on YouTube. Start with this one, and then finish all of the videos to get some of Ivan’s great knowledge on the subject. Pay special attention to video number 7 (Basic Workflow of Transaction) since that is what you will need to know to program an application with Hyperledger Fabric SDK.

Learn by doing — program applications with Hyperledger Composer and Hyperledger Fabric SDK

Hyperledger Composer

Now that we’ve got the readings/courses out of the way, let’s start programming some applications. Let’s start with Composer, since it is easier to understand, and move up to Hyperledger Fabric SDK as we feel more comfortable.

  1. Run through this intro code pattern — install the necessary NPM modules (composer), run your first smart contract, and see the REST-API that is created from your Composer network.
  2. (Optional) — move to a more complex code pattern that builds on the first, business network and see how to simulate an auction application on Hyperledger Composer.
  3. Move to a full web-app code pattern. See how to build a web-UI, and how to interact with a Hyperlegder Composer backend to populate your web-front end with the assets and data from the ledger.
  4. (Optional) —Code pattern which shows how to deploy a supply-network of a coffee-retailer running on IBM Blockchain Platform, using Hyperledger Composer. Note, to deploy this code pattern, you will need to have an IBM Cloud account + IBM Blockchain Platform Starter Plan. Sign up for a free month trial here.

Hyperledger Fabric SDK

Now that we are more familiar with Hyperledger Composer, we can dive a bit deeper into the Hyperledger architecture, and work with Hyperledger Fabric directly.

  1. Run the marbles demo locally. This will give you a nice understanding of the Hyperledger Fabric architecture, especially how the client app communicates with the peer, orderer, and certificate authority.
  2. Learn the basics of Hyperledger Fabric SDK by deploying this code pattern that simulates a car-auction on the blockchain. Note that you will need to have an IBM Cloud account to run this one. To get a free one-month account, sign up here.
  3. Walk through this tutorial of using VSCode + IBM Blockchain extension + latest Hyperledger Fabric API’s to deploy a local network. (No IBM Cloud account needed here).
  4. (Optional) — A more complex code pattern which features IBM Cloud IoT platform working in conjunction with IBM Blockchain platform to track assets. Note that you will need an IBM Cloud account for this one.

Bonus: EVM smart contract integration into Hyperledger Fabric

As open-source and interoperability are beginning to dominate the tech industry, Hyperledger has followed suit and released features to accept contracts that are compatible with the EVM (Ethereum Virtual Machine). This means that if you wrote a smart contract with Solidity, Viper, or other languages that are used for Ethereum development, you can reuse the same smart contract with Hyperledger Fabric.

  1. This tutorial shows how to get started using EVM smart contracts with a local Hyperledger Fabric network.
  2. This code pattern takes the previous one step further, and build a web-app which mounts EVM smart contracts on a local Hyperledger Fabric network running locally.

Thanks for reading. Don’t be afraid to hold that👏🏼 button if you liked this article. Please leave any comments or concerns down below!