Get the code
View the demo
By Ishan Gulhane | Last updated October 11, 2018
BlockchainNode.jsPlatform as a Service
Organizations that use blockchain depend on trusted transactions to securely automate processes that were previously completed manually. In this developer pattern, you’ll learn how to use the Hyperledger Composer framework to create and execute smart contracts. Those contracts will run within a blockchain application built on Hyperledger Fabric.
Updated to support Hyperledger Fabric V1.1 and Hyperledger Composer V0.19
Note: This developer pattern is the second in a series of patterns designed to get you started with blockchain. For an overview of the series, see Build your first blockchain application.
In the first pattern of the series, you learned how to build a blockchain network. Now you’re ready to learn how to create and execute a smart contract within your blockchain application.
Blockchain is designed for multi-party business transactions, and organizations that use blockchain depend on trusted automatic transactions to do business. One of the most useful aspects of blockchain is its decentralization. Because it’s a decentralized system that exists between all permitted parties, there’s no need to employ intermediaries. In effect, you “cut out the middleman,” save time, and prevent potential disagreement about transactions.
Blockchain creators realized that the decentralized blockchain ledger could be used for self-executing or smart contracts. Smart contracts are used to exchange money, property, shares, or anything of value in a transparent, conflict-free way. Smart contracts not only define the rules and penalties around an agreement in the same way that a traditional contract does, but they also automatically enforce those obligations. No intermediary is required for a smart contract to be completed.
A good way to understand smart contracts is to compare the technology to a vending machine. Ordinarily, to complete a contract you’d go to an attorney, pay that attorney a fee, and wait to receive the document in question, whether a house closing agreement, a divorce decree, or any other “official” documentation. With the smart contract model, you simply drop a token into the vending machine-that is, the ledger-and your document (or candy bar) is provided to you, or deposited into your account. It’s a straightforward process requiring no additional intervention from anyone.
This developer pattern will show you how to use Hyperledger Composer to create a smart contract. You’ll execute the contracts on the blockchain app that you built in the first pattern of this series. If you’ve already completed the previous pattern, you know how useful Hyperledger Composer is for developing blockchain apps. Now you’ll take your blockchain skills to the next level by embedding and executing smart contract business terms.
Ready to put this code pattern to use? Complete details on how to get started running and using this application are in the README.
Get the Code »
Back to top