Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Build Blockchain Insurance App | 715 | 7 months ago | 37 | apache-2.0 | JavaScript | |||||
Sample insurance application using Hyperledger Fabric | ||||||||||
Blockchain Network On Kubernetes | 256 | 2 years ago | 8 | apache-2.0 | Shell | |||||
Demonstrates the steps involved in setting up your business network on Hyperledger Fabric using Kubernetes APIs on IBM Cloud Kubernetes Service. | ||||||||||
Android_article | 184 | 9 months ago | apache-2.0 | |||||||
Android热更新、异步并发、性能优化、编译打包、适配相关等文档 by yang。huh...The palest ink is better than the best memory. | ||||||||||
Wifimeshraspberrypi | 174 | 2 years ago | apache-2.0 | |||||||
Workshop to create a sensor application over a WiFi Mesh network | ||||||||||
Fabcar Blockchain Sample | 107 | 5 months ago | 53 | apache-2.0 | JavaScript | |||||
Use a Kubernetes cluster to deploy a Fabric network smart contract onto blockchain | ||||||||||
Ibm Container Service | 81 | 5 years ago | 14 | apache-2.0 | Shell | |||||
IBM Blockchain Platform for Developers on IBM Container Service | ||||||||||
Fabric Contract Attribute Based Access Control | 59 | 7 months ago | 29 | apache-2.0 | JavaScript | |||||
A repo to demonstrate how to implement attribute-based-access-control in Hyperledger Fabric for a supply-chain use case using IBM Blockchain Platform VSCode extension. | ||||||||||
Car Auction Network Fabric Node Sdk | 49 | 4 years ago | 1 | apache-2.0 | JavaScript | |||||
WARNING: This repository is no longer maintained :warning: The Blockchain Starter Kit service is going out of service. The repository will be kept available in read-only mode. Refer to https://developer.ibm.com/patterns/category/blockchain/ for other Blockchain patterns. | ||||||||||
Create Blockchainnetwork Ibpv20 | 42 | 3 years ago | apache-2.0 | JavaScript | ||||||
Creating a basic Blockchain network using the IBM Blockchain Platform | ||||||||||
Ansible Collection | 39 | 3 months ago | 24 | apache-2.0 | Python | |||||
Ansible collection for building Hyperledger Fabric networks |
Creating a basic Blockchain network using the IBM Blockchain Platform
Welcome to the first in a series of building a Blockchain application using the IBM Blockchain Platform. Part 1 will show you how to set up your Blockchain network on the IBM Cloud. This will be the "Hello World" of Hyperledger samples using the IBM Blockchain Platform - so beginner developers should be able to manage this. This pattern shows you how to test your network by packaging your smart contract using the IBM Blockchain Platform extension on VS Code and then deploying it onto the network. The network uses Hyperledger Fabric V1.4.
Hyperledger Fabric is a blockchain framework implementation and one of the Hyperledger projects hosted by The Linux Foundation. Intended as a foundation for developing applications or solutions with a modular architecture, Hyperledger Fabric allows components, such as consensus and membership services, to be plug-and-play.
In Part 2, we will explore more about creating a complex network with multiple participants and using Access Control Rules (ACL) to provide them network access permissions. In this journey, you will run Hyperledger Fabric on the Cloud.
When you have completed this code pattern, you will understand how to:
Follow these steps to set up and run this code pattern. The steps are described in detail below.
Clone this repository in a folder your choice:
git clone https://github.com/IBM/Create-BlockchainNetwork-IBPV20
We will use the IBM Blockchain Platform extension on VS Code to package the smart contract.
If you have not done so already, you will need to install the IBM Blockchain Platform VSCode extension — you’ll also need to install the latest version of VSCode to do this. To see if you have the latest version go to Help -> Check for updates. If VSCode exits at this point, it likely means you don’t have the latest version. If so, update your VSCode (using the link provided earlier) and once you’re done, click on extensions in the sidebar on the left side of your screen. At the top, search the extensions marketplace for IBM Blockchain Platform and click on Install. You should see a status of “Installing” and eventually “Installed” — then click on reload.
Open Visual Studio code and open the contract
folder from Create-BlockchainNetwork
repository that was cloned earlier.
It is important that you are opening the contract
folder and not the entire Create-BlockchainNetwork
directory; otherwise you will see an error that states that it doesn't understand what programming language you are using.
Press the F1
key to see the different VS code options. Choose IBM Blockchain Platform: Package Open Project
.
IBM Blockchain Platform
extension button on the left. This will show the packaged contracts on top and the blockchain connections on the bottom.
Next, right click on the packaged contract (in this case, select [email protected]) to export it and choose Export Package
.
Choose a location on your machine and save the .cds
file. We will use this packaged smart contract later to deploy on the IBM Blockchain Platform service.
Now, we will start setting up the different services required for configuring our Hyperledger Fabric network on the IBM Cloud and for running our application using this network.
Catalog
. For this code pattern, we can use the Free
cluster, and give it a name. Note, that the IBM Cloud allows one instance of a free cluster which expires after 30 days. Note: it could take 20 minutes for the IBM Cloud Kubernetes Service setup to complete.
Catalog
, and give it a name.
We will build a network as provided by the IBM Blockchain Platform documentation. This will include creating a channel with a single peer organization with its own MSP and CA (Certificate Authority), and an orderer organization with its own MSP and CA. We will create the respective identities to deploy peers and operate nodes.
Org1 CA
and click Next.admin
and CA Administrator Enroll Secret of adminpw
, then click Next.
admin
and an Enroll secret of adminpw
. Use the default value of Org1 CA Identity
for the Identity display name.
admin
identity that was created for the CA is visible in the table.org1admin
, and Enroll Secret of org1adminpw
. Set the Type for this identity as client
. We can specify to Use root affiliation or uncheck this field and select from any of the affiliated organizations from the drop-down list. We will leave the Maximum enrollments field blank. Click Next.peer1
, and Enroll Secret of peer1pw
. Set the Type for this identity as peer
. We can specify to Use root affiliation or uncheck this field and select from any of the affiliated organizations from the drop-down list. Click Next.
Org1MSP
and an MSP ID of Org1MSP
.Org1 CA
as the root CA for the organization.org1admin
and org1adminpw
. Then, give the Identity name as Org1 Admin
.
Peer Org1
and click Next.Org1 CA
as the Certificate Authority. Then, give the Peer enroll ID and Peer enroll secret for the peer identity that you created for your peer, that is, peer1
, and peer1pw
. Select the Organization MSP as Org1MSP
, from the drop-down list. Leave the TLS CSR hostname blank. Click Next.Org1 Admin
and click Next.
Orderer CA
and click Next.admin
and CA Administrator Enroll Secret of adminpw
, then click Next.
admin
and an Enroll secret of adminpw
. Use the default value of Orderer CA Identity
for the Identity display name.
admin
identity that was created for the CA is visible in the table.ordereradmin
, and Enroll Secret of ordereradminpw
. Set the Type for this identity as client
. We can specify to Use root affiliation or uncheck this field and select from any of the affiliated organizations from the drop-down list. We will leave the Maximum enrollments field blank. Click Next.orderer1
, and Enroll Secret of orderer1pw
. Set the Type for this identity as orderer
. We can specify to Use root affiliation or uncheck this field and select from any of the affiliated organizations from the drop-down list. Click Next.
OrdererMSP
and an MSP ID of OrdererMSP
.Orderer CA
as the root CA for the organization.ordereradmin
and ordereradminpw
. Then, give the Identity name as Orderer Admin
.
Orderer
and click Next.Orderer CA
as the Certificate Authority. Then, give the Ordering service enroll ID and Ordering service enroll secret for the peer identity that you created for your orderer, that is, orderer1
, and orderer1pw
. Select the Organization MSP as OrdererMSP
, from the drop-down list. Leave the TLS CSR hostname blank. Click Next.Orderer Admin
and click Next.
Org1MSP
, as this is the MSP that represents the peer's organization "Org1".
mychannel
.Orderer
from the Ordering service drop-down list.Org1MSP (Org1MSP)
from the drop-down list to add the organization "Org1" as a member of this channel. Click Add button. Set the permissions for this member as Operator.Org1MSP (Org1MSP)
from the dropdown as the Channel creator MSP and select Org1 Admin
from the dropdown under Identity.
Orderer
as the Ordering service and click Next.mychannel
and click Next.Peer Org1
.
[email protected]
), which we packaged earlier using the IBM Blockchain Platform extension for Visual Studio code.
mychannel
on which to instantiate the smart contract. Click Next.Org1MSP
. Click Next.instantiate
and leave Arguments blank. Note: instantiate
is the method in the my-contract.js
contract file that initiates the smart contracts on the peer. Some may name this initLedger
.
Connect with SDK
from the overflow menu on the right side of the row.Org1MSP
.Org1 CA
.
app-admin
and Enroll Secret of app-adminpw
. Set the Type for this identity as client
. We can specify to Use root affiliation or uncheck this field and select from any of the affiliated organizations from the drop-down list. We will leave the Maximum enrollments field blank. Click Next.hf.Registrar.Roles
= *
. This will allow this identity to act as a registrar and issue identities for our app. Click Add attribute.
app-admin
and app-adminpw
.Org1MSP
.{ enabled: true, asLocalhost: false }
to connect to IBM Blockchain Platform. {
"connection_file": "mychannel_blockchain-network_profile.json",
"channel_name": "mychannel",
"smart_contract_name": "blockchain-network",
"appAdmin": "app-admin",
"appAdminSecret": "app-adminpw",
"orgMSPID": "org1msp",
"caName": "169.46.208.151:30404",
"userName": "user1",
"gatewayDiscovery": { "enabled": true, "asLocalhost": false }
}
First, navigate to the application
directory, and install the node dependencies.
cd application
npm install
Run the enrollAdmin.js
script
node enrollAdmin.js
You should see the following in the terminal:
msg: Successfully enrolled admin user app-admin and imported it into the wallet
Run the invoke-transactions.js
script to execute the transactions on the smart contract
node invoke-transactions.js
You should see the following in the terminal:
Wallet path: /Users/snyk/CognitiveApps/code-patterns/Create-BlockchainNetwork-IBPV20/Create-BlockchainNetwork-IBPV20/application/wallet
Submit AddTrader transaction.
addTraderAResponse:
{"traderId":"traderA","firstName":"Carlos","lastName":"Roca"}
addTraderAResponse_JSON.parse:
{ traderId: 'traderA', firstName: 'Carlos', lastName: 'Roca' }
Submit AddTrader transaction.
addTraderBResponse:
{"traderId":"traderB","firstName":"Lisa","lastName":"Smith"}
addTraderBResponse_JSON.parse:
{ traderId: 'traderB', firstName: 'Lisa', lastName: 'Smith' }
Submit AddCommodity transaction.
addCommodityResponse:
{"tradingSymbol":"commodityA","description":"farm-commodity","traderId":"traderA"}
addCommodityResponse_JSON.parse:
{ tradingSymbol: 'commodityA',
description: 'farm-commodity',
traderId: 'traderA' }
Submit Commodity trade transaction.
commodityTradeResponse:
{"description":"farm-commodity","traderId":"traderB","tradingSymbol":"commodityA"}
commodityTradeResponse_JSON.parse:
{ description: 'farm-commodity',
traderId: 'traderB',
tradingSymbol: 'commodityA' }
error: [Client.js]: Channel not found for name mychannel
It is safe to ignore this error because the IBM Blockchain Platform service has service discovery enabled by default. (In order to use service discovery to find other peers, please define anchor peers for your channel in the UI). If you really want the message to go away you can add the channels section to the connection profile, but it is a warning rather than a true error telling the user the channel is found but not in the connection profile.
As an example you can manually add the following json and update the IP address and ports manually:
"channels": {
"mychannel": {
"orderers": [
"169.46.208.151:32078"
],
"peers": {
"169.46.208.151:31017": {}
}
}
},
This application can be expanded in a couple of ways:
invoke.js
node application to execute the transactions.This code pattern is licensed under the Apache Software License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.