DEV Community

Cover image for Getting started with Hyperledger Composer and private blockchains

Getting started with Hyperledger Composer and private blockchains

Damien Cosset on February 16, 2018

Introduction In my last article, I started to explore what characteristics a blockchain would need to have to be helpful to a business, ...
Collapse
 
prasadraavi profile image
prasadraavi

Hi Damien,

Firstly let me thank you for wonderful guidance on how to create blockchain business network.

I am halfway through but got stuck with deployment. I am getting the following error, could you please help me with the mistake I am doing and how can overcome that issue. Thanks in advance.


Issue :

I am getting the following error when I try to execute the commands for business network deployment. Can somebody help me with a solution for this. I am using ubuntu 16.04 ver.

Error :
dev1@localhost:~/land-registry$ composer archive create -t dir -n .
Creating Business Network Archive

Looking for package.json of Business Network Definition
Input directory: /home/dev1/land-registry
ParseException: Expected "namespace", comment, end of line or whitespace but "*" found. File /home/dev1/land-registry/models/org.acme.landregistry.cto line 19 column 1
Command failed

Collapse
 
eoghanr profile image
EoghanR • Edited

Hi prasadraavi,

I don't know if you still need this, but I'll put it here in case anyone else has this issue. In the .cto file, you need to have the line "namespace org.acme.landregistry". The same would need to be done with any other cto file by having namespace {your .cto file here} without the .cto attached.

I'm not sure if this is a universal solution, but it's the one that worked for me.

Best,
Eoghan

Collapse
 
ahmedmusallam profile image
Ahmed Musallam

Fantastic article! and your other articles on private blockchain are also very good!

I noticed that this article uses "composer runtime install" which is removed in the last release of the composer cli, it should now become "composer network install" with the appropriate options.

Collapse
 
damcosset profile image
Damien Cosset

You are right! Thank you for the catch! I will update the article accordingly.

Collapse
 
mohinimraut profile image
mohinimraut

When I restart my composer Rest Server I faced following error:
mohinir@rpqbsrv001:~/fabric-tools/landregistry$ composer-rest-server
? Enter the name of the business network card to use: admin@landregistry
? Specify if you want namespaces in the generated REST API: never use namespaces
? Specify if you want to use an API key to secure the REST API: No
? Specify if you want to enable authentication for the REST API using Passport: No
? Specify if you want to enable event publication over WebSockets: Yes
? Specify if you want to enable TLS security for the REST API: No

To restart the REST server using the same options, issue the following command:
composer-rest-server -c admin@landregistry -n never -w true

Discovering types from business network definition ...
Connection fails: Error: Error trying to ping. Error: make sure the chaincode landregistry has been successfully instantiated and try again: getccdata composerchannel/landregistry responded with error: could not find chaincode with name 'landregistry'
It will be retried for the next request.
Exception: Error: Error trying to ping. Error: make sure the chaincode landregistry has been successfully instantiated and try again: getccdata composerchannel/landregistry responded with error: could not find chaincode with name 'landregistry'
Error: Error trying to ping. Error: make sure the chaincode landregistry has been successfully instantiated and try again: getccdata composerchannel/landregistry responded with error: could not find chaincode with name 'landregistry'
at _checkRuntimeVersions.then.catch (/home/mohinir/.nvm/versions/node/v8.11.3/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:806:34)
at

Collapse
 
d8bhatta profile image
Deepak

Hello Damien,
This is really very helpful article to start hyperledger composer and understand rest api along with it. I have few questions:

  1. Participants and assets can be deleted as per composer (localhost:3000/explorer/#/) but not transactions. How participants and assets can be deleted if they are stored in blockchain?

  2. I have faced some validation issue like buyer doesn't have enough fund to buy the property, where have you written such validation in code? i dont see it in logic.js file.

  3. Do you have composer + fabric in nodejs rather than in react, It would be easier for me to create api using nodejs.

Thank you so much for such wonderful article.

Collapse
 
damcosset profile image
Damien Cosset

Thanks for the kind words.

1) I could be wrong on this, but I don't think it is possible to remove participants and assets from the blockchain. A distributed ledger is an append-only system. In a permissioned blockchain, you would simply remove the ability from a participant to make any sort of transactions.

2) This error should appear in the buyingRealEstate function. We check if the buyer has enough funds to pay the other participants.

3) I'll see what I can do :)

Collapse
 
gandharav profile image
gandharav

Great Article, While running the composer network start command I am getting some errors. We are running the network behind a corporate proxy and have already resolved DNS related issues , but not able to resolve this issue. Do you have any idea how this can be resolved basically the container creation is getting failed.

node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp ERR! Completion callback never invoked!
node-pre-gyp ERR! System Linux 4.4.0-121-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/chaincode/output/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /chaincode/output/node_modules/grpc
node-pre-gyp ERR! node -v v8.9.4
node-pre-gyp ERR! node-pre-gyp -v v0.10.0
node-pre-gyp ERR! This is a bug in node-pre-gyp.
node-pre-gyp ERR! Try to update node-pre-gyp and file an issue if it does not help:
node-pre-gyp ERR! github.com/mapbox/node-pre-gyp/issues
npm WARN hscdb2@0.0.1 No repository field.
npm WARN The package composer-common is included as both a dev and production dependency.

npm ERR! code ELIFECYCLE
npm ERR! errno 6
npm ERR! grpc@1.11.3 install: node-pre-gyp install --fallback-to-build --library=static_library
npm ERR! Exit status 6
npm ERR!
npm ERR! Failed at the grpc@1.11.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-05-17T05_58_38_825Z-debug.log
"
error starting container

Collapse
 
zainabas profile image
zainabAS

Really helpful article!!
Thank You
I have a question regarding the logic.js file, I couldn't find it in the lib folder. Should I create it?

Collapse
 
damcosset profile image
Damien Cosset

Yes, you should :)

Collapse
 
zainabas profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
zainabAS

Another question.
When I reached to "Deploying" step and open "localhost:3000/explorer" I didn't get the same result. I didn't find the assets, participants and transactions.It is just the "System: General business network methods"that is there.
Any idea what would be my mistake?

Many thanks.

Thread Thread
 
damcosset profile image
Damien Cosset

I'm not sure. Could you check that you are using the same composer version everywhere? When I wrote this article, the composer version was 0.16 I believe. It is now 0.19 or so. If the code is the same as mine, that might be an issue.

Thread Thread
 
zainabas profile image
zainabAS

I was using compser 0.19 with the old fabric version "hlfv1".
I changed it to the new one "hlfv11" and the problem is solved.

Thanks.

Collapse
 
sbtmentor profile image
SBTMentor • Edited

Hello Damien!

Excellent article! However,after buying real estate,sophie's balance is not being updated. Notary balance too is being shown as 0! Can you please tell where the problem is?

Thanks in advance!

Collapse
 
haso71 profile image
haso71

Hallo Damien, hopefully you could help me! As a beginner I have some installation problems: I set up a brand new Ubuntu 16.04 and got far (with so deprecation warnings) throw your guide until:
1.) Starting ./createPeerAdminCard.sh: brings some kind of warning: "Need to have composer-cli installed at v0.19 or greater"

2.) "composer archive create -t dir -n ." brings an error:
module.js:549 throw err; Error: Cannot find module './api' ...

I didn´t find any api-files, so whats wrong?

Collapse
 
damcosset profile image
Damien Cosset • Edited

Hey there.

For the first problem, you most likely need to update your composer-cli package version to 0.19. Or install it if you haven't: npm install -g composer-cli or npm update -g composer-cli should get the job done.

I'm not sure about the second one though. Try again with the updated version of composer. If you still have an error, could you show the entire error message?

Note: I updated the article for the new composer network install command.

Good luck!

Collapse
 
haso71 profile image
haso71

thank you for the fast answer, so I tried to check all versions on my system, for my opinion, i already had composer-cli installed at v0.19.0 before.

// -- version check ----
1.)
haso71@ubuntu:~/hyperledger/fabric-tools$ docker-compose --version
docker-compose version 1.20.1, build 5d8c71b
haso71@ubuntu:~/hyperledger/fabric-tools$ yo --version
2.0.1
haso71@ubuntu:~/hyperledger/fabric-tools$ nodejs -v
v8.11.1
haso71@ubuntu:~/hyperledger/fabric-tools$ node -v
v8.11.1
haso71@ubuntu:~/hyperledger/fabric-tools$ npm -v
5.6.0
haso71@ubuntu:~/hyperledger/fabric-tools$ go version
go version go1.6.2 linux/amd64

haso71@ubuntu:~/hyperledger/fabric-tools$ sudo npm install -g composer-cli
npm WARN deprecated fs-promise@1.0.0: Use mz or fs-extra3.0 with Promise Support
/usr/bin/composer -> /usr/lib/node_modules/composer-cli/cli.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/composer-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

haso71@ubuntu:~/hyperledger/fabric-tools$ sudo ./createPeerAdminCard.sh
Development only script for Hyperledger Fabric control
Running 'createPeerAdminCard.sh'
FABRIC_VERSION is unset, assuming hlfv11
FABRIC_START_TIMEOUT is unset, assuming 15 (seconds)

Need to have composer-cli installed at v0.19 or greater

2.)
haso71@ubuntu:~/hyperledger/fabric-tools/land-registry$ composer archive create -t dir -n .
module.js:549
throw err;
^
Error: Cannot find module './api'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/usr/lib/node_modules/composer-cli/node_modules/node-report/index.js:3:13)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
haso71@ubuntu:~/hyperledger/fabric-tools/land-registry$ ls -l
total 32
drwxrwxr-x 3 admin admin 4096 Apr 2 01:34 features
drwxrwxr-x 2 admin admin 4096 Apr 2 01:46 lib
drwxrwxr-x 2 admin admin 4096 Apr 2 01:43 models
-rw-r--r-- 1 admin admin 878 Apr 2 01:34 package.json
-rw-r--r-- 1 admin admin 356 Apr 2 01:49 permissions.acl
-rw-rw-r-- 1 admin admin 1588 Apr 2 01:49 permissions(original).acl
-rw-r--r-- 1 admin admin 57 Apr 2 01:34 README.md
drwxrwxr-x 2 admin admin 4096 Apr 2 01:34 test
haso71@ubuntu:~/hyperledger/fabric-tools/land-registry$

Collapse
 
pallavrj profile image
pallavrj

Hi Damien,

Great Article :)

Question: Whenever I do Network Install, It gives me below error. Any help will be highly appreciated.

$ composer network install --card PeerAdmin@hlfv1 --archiveFile land-registry@0.0.1.bna
x Installing business network. This may take a minute...
Error: Error trying install business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: 14 UNAVAILABLE: Connect Failed
Command failed

I have Below settings:

Docker Toolbox Version: 18.03.0-ce
Hyperledger fabric Version: 1.1.0
Fabric_Version: hlfv11
Peeradmin card: PeerAdmin@hlfv1

Please let me know in case you need further details to guide me.

Regards,
Pallav Raj

Collapse
 
lokeshgene profile image
lokeshgene

Hi Damien - very good article!, thanks for putting this together!. I have few questions, please do assist.

1) When we create react app, can this be in separate folder?

2) I followed the exact way you did, but after I triggered the react-app. It shows the following error.

Unhandled Rejection (SyntaxError): Unexpected token < in JSON at position 0

it is occured at Client.js while parsing JSON. Do we need to make any other special adjustment

Collapse
 
teckchun profile image
Teckchun

Hi there, I have tried your tutorial and I have one question regarded to the logic of BuyingRealEstate transaction. When I executed the transaction it worked fine. However after buying RealEstate the InsuranceCompany and Notary balance is still 0. Hope to see your reply soon.

Collapse
 
anuj786 profile image
Anuj Thakur

Hi,

This is a fantastic article helped me a lot thank you very much.

There is something wrong in my case, when I am trying to POST ContractingLoan transaction data getting following error in response.

{
"error": {
"statusCode": 500,
"name": "Error",
"message": "Error trying invoke business network. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: transaction returned with failure: Error: Could not find any functions to execute for transaction org.acme.landregistry.ContractingLoan#c6d2b628c7c04ab4ee52116ea5d0d8b4872a850efb0d6e7d8d390f96d97906aa",
"stack": "Error: Error trying invoke business network. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: transaction returned with failure: Error: Could not find any functions to execute for transaction org.acme.landregistry.ContractingLoan#c6d2b628c7c04ab4ee52116ea5d0d8b4872a850efb0d6e7d8d390f96d97906aa\n at HLFConnection.invokeChainCode (/home/anuj/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:1002:30)\n at "
}
}

Collapse
 
mpena211 profile image
mpena211

Did you happen to find an answer to this problem?

Collapse
 
zainabas profile image
zainabAS

Last Question,
How can the code changes in the logic and script files reflect in the rest API server?

Many thanks,

Collapse
 
5thunder profile image
5ong

Thanks a lot for this tutorial, Damien. Everything works great!
Would it be possible for us to have the code of the transaction in the React app?

-5thunder

Collapse
 
zainabas profile image
zainabAS

one more question..
Are all transactions stored in one blockchain?
Can we display the block structure?

Thank you.