IBM Blockchain 101: Quick-start guide for developers
How to set up a blockchain network and start coding
Join the blockchain revolution! This developerWorks quick-start guide is for application developers who are new to blockchain technology and want to quickly get started with building and piloting blockchain networks. Simple instructions show you how to set up an IBM Blockchain network based on the open source Hyperledger Fabric, deploy chaincode (business rules), and write client apps to streamline your business processes and digital interactions.
Before you begin
Blockchain is a technology for a new generation of transactional applications. It establishes trust, accountability, and transparency, while also streamlining business processes. The concept of a blockchain network was popularized by bitcoin, but its practical uses extend far beyond cryptocurrency. With blockchain, IBM is reimagining the most fundamental business exchanges, and opening the door to a new world of digital interactions.
IBM and other companies are collaborating to develop an open source implementation of blockchain technology for business use, called the Hyperledger Fabric, under the Linux Foundation’s Hyperledger Project. The Fabric's modular architecture supports pluggable functionality, and its powerful container technology accommodates any mainstream language for business application development.
Blockchain terms and concepts
To meet the demands of modern markets, the Hyperledger Fabric's industry-focused design fulfills diverse requirements and extends the pioneering work in this field, while also addressing issues like scalability and confidentiality. The Fabric provides a new approach to enable permissioned networks, privacy, and confidentiality on multiple blockchain networks.
Understanding the terms and concepts of how a blockchain network works will help you get started with application development.
Set up a blockchain network and development environment
Now that you have a conceptual background, the first step for application development is to start a blockchain network where you can develop, test, and deploy your code. You can start a blockchain network in any of three ways:
- Blockchain service on IBM Bluemix®
- Hyperledger Fabric images on Docker Hub
- IBM-signed and supported images
Option 1: Using the Blockchain service on Bluemix
With the Blockchain service on Bluemix, you can create and deploy a private blockchain network (a clone of the Hyperledger Fabric) in one click.
Two network plans are available. Both plans unlock features in Hyperledger Fabric v0.6 and provide a four-node network with a Certificate Authority to manage identities and member permissions. The only difference between the two plans is their operating environment and cost.
The Starter Developer Network plan (currently in
beta release) provides a shared, multi-tenant environment running on IBM
This plan is free.
The High Security Business Network (HSBN) plan provides an isolated, single-tenant environment running in a Secure Service Container on an IBM LinuxONE™ z Systems® offering. This plan is subscription based.
Option 2: Using Hyperledger Fabric images on Docker Hub
Alternatively, you can pull Hyperledger Fabric images from Docker Hub to create and manage your own local blockchain network. With this approach, you have several choices for how to run the Fabric on Docker: using Docker Toolbox or one of the new native Docker runtime environments for Mac OSX or Windows.
After you have Docker (1.11 or greater) installed and running, before starting any of the Fabric components, you need to first pull the Fabric images from Docker Hub:
docker pull hyperledger/fabric-peer:latest docker pull hyperledger/fabric-membersrvc:latest
Because running the Fabric requires connecting multiple containers together, using Docker Compose is the simplest approach. Your Docker Toolbox installation or any of the native Docker runtimes also install Compose.
To start your blockchain network using Docker Compose, follow these steps:
- Start up validating peers
- Run Hyperledger Fabric natively on Mac
- Run Hyperledger Fabric natively on Windows
Option 3: Using images that are signed and supported by IBM
A third alternative is to use images that are signed and supported by IBM. The IBM-signed images have been tested for functionality, stability, and performance across the available platforms (x86, Power, and z Systems).
Write, deploy, and test chaincode apps
Chaincode is Go (GoLang) or Java™ code that lets users interact with a blockchain network according to the business rules established in the chaincode. Whenever you invoke a transaction on the network, you're calling a function in chaincode that reads and writes values to the ledger.
For an in-depth course on writing and deploying chaincode that can interact with your network, see the IBM Blockchain for developers learning path: Build your first chaincode.
Option 1: Writing chaincode using Bluemix
Bluemix provides a tutorial to guide you through the steps of building a chaincode application. You will incrementally build a working chaincode that creates generic assets for exchanging on a network. Then, you will interact with your chaincode through the network API. Using The network API will require you to fork the Fabric code on GitHub and install the Go programming language on your local machine.
You can also deploy chaincode on a Bluemix network and work with sample code using the Blockchain dashboard monitor.
In addition to the "Hello Chaincode" app, you can deploy three demos directly on Bluemix: Marbles, Commercial paper, and Car lease. The Marbles demo is the easiest to use, while the Car Lease demo is the most advanced.
- Sample app on Bluemix: Marbles
- Sample app on Bluemix: Commercial paper
- Sample app on Bluemix: Car lease
Option 2: Writing chaincode using Docker
Chaincode developers using Docker can test and debug their chaincode without having to set up a complete peer network. Similar to starting a network, you have several options for development. Using Docker images pulled in Step 2, Option 2 above, you can use the command line to register chaincode with a validating node, and use the CLI, gRPC API, or REST API to invoke transactions. You can also use the HFC SDK.
The following instructions apply to developing and deploying chaincode in Go or Java. They do not apply to running in a production environment.
You can also deploy the Marbles, Commercial paper, and Car lease apps to your local Docker environment.
If you are developing chaincode in Go, follow these instructions:
Write and deploy client-side apps that invoke chaincode apps
Once you have a blockchain network with registered chaincode, you need to build client-side applications that can read, write, and invoke the business rules that you have written into the chaincode. The Hyperledger Fabric Client (HFC) SDK provides a powerful and easy way to use APIs that allow applications to interact with a Hyperledger Fabric blockchain.
Node.js applications that leverage the HFC SDK can be used to perform the following network tasks:
- Securely register and enroll users. A web application administrator with registrar authority can dynamically register and enroll users who have authenticated to the web application.
- Submit transactions to the blockchain network (deploy, invoke, and query). All transactions are anonymous, confidential, and unlinkable without auditor authority.
- Store sensitive private keys and certificates in any location, such as an off-blockchain database. This requires implementing a simple key-value store interface.
Option 1: Writing client apps using Bluemix
Follow these instructions to use the HFC to interact with a blockchain network on Bluemix:
Option 2: Writing client apps using Docker
If you're using the Docker images, follow these steps to use the HFC SDK:
Monitor and manage your blockchain network and apps
A dashboard monitor provides a friendly tool to examine a blockchain network. With the dashboard monitor on Bluemix, you can view network information about peers, logs, ledger state, APIs, and chaincode.
Option 1: Monitoring using Bluemix
Option 2: Monitoring using Docker
Blockchain Explorer provides a user interface for developers using the Hyperledger Docker images. It's currently under development.
Get involved and help build the Hyperledger Fabric
Contributions to the Hyperledger Project are welcome in many forms. RocketChat is used for communication, and Google Hangouts are used for screen sharing between developers. Development planning and prioritization is done in JIRA, and longer running discussions and decisions go to the mailing list.
The Fabric's maintainers are responsible for reviewing and merging all patches submitted for review. They guide the overall technical direction within the guidelines established by the Hyperledger Project's Technical Steering Committee (TSC).
Get help and support
Here's where to go to get support and answers to your questions.
- If you're using the Blockchain service on Bluemix:
Start at the Support and known issues page. In addition to any current abnormalities with the service, you'll also find release notes for new commits of the Hyperledger Fabric code.
- If you're using Hyperledger Fabric community images:
Browse the Fabric channels in the Hyperledger Channel Guide and join the discussion group suited to your question.
- If you don't see an answer to your question:
Reach out to the Blockchain development team via GitHub issues.
New capabilities in v1.0 of the Hyperledger Fabric are under development, with many opportunities for community members to contribute code and curate the Fabric to fit specific business needs. Get a preview in this video:
- Blockchain developer center
- Blockchain basics: Introduction to distributed ledgers
- Blockchain network plan on Bluemix (free)
- Blockchain learning path (3 courses for developers)
- Blockchain videos on developerWorks TV
- Hyperledger Fabric
- Hyperledger community