4

I am new to hyperledger and bit confused about hyperledger composer & nodejs api. I saw using composer we can create assets, transactions, participants and chaincode and in last we have to archive it this all into .bna file and finally we deploy this chaincode into network using admin card

But at other end using NodeJs API we can also write chaincode by overiding init & invoke methods.

How can we relate these all.

zubair
  • 175
  • 3
  • 15

3 Answers3

10

The best way to think about this is the following:

1) Hyperledger Fabric v1.1 supports writing chaincode in two languages: Golang and JavaScript via Node.js

If you want to do all of the heavy lifting yourself, you can write straight chaincode.

2) Hyperledger Composer provides a higher-level model-driven language for developing smart contracts. It currently only allows deployment of these artifacts to Hyperledger Fabric. It also happens to support writing functions in JavaScript as well.

So if you want to start from a higher-level model-driven approach, Hyperledger Composer is the way to go. If you want to write all of the plumbing yourself or use very low-level chaincode features, then using chaincode itself is the way to go.

Moving forward, we are looking at a better way to move between the two and not force a decision / direction up front.

Gari Singh
  • 7,804
  • 2
  • 12
  • 31
  • Is there a performance difference between JavaScript and GoLang implementation of the chaincode ? – Bilbo Baggins May 25 '18 at 13:20
  • The cop out answer is "it depends on what you are doing" but in general Go will be faster in there is a lot of computational logic in your chaincode. If the logic is fairly simple, the communication between the peer and chaincode will negate any performance differences – Gari Singh May 25 '18 at 18:33
  • hmmm, interesting, but if the performance difference is there then why they are allowing two different languages to implement chaincode? – Bilbo Baggins May 25 '18 at 18:59
  • 1
    People have different skills and preferences. If you take into account the overall processing flow, the performance differences between chaincode written in one language versus another will be negligible – Gari Singh May 26 '18 at 10:08
2

There is another option, we develop a framework called Convector to be in the middle of Composer (high abstraction, low control) and raw code (low abstraction, high control, therefore high risk). We open sourced it a few days ago. At WorldSibu we don't like loosing so much control over our code like with Composer but as Gari Singh was saying, doing all the heavy lifting for each project is crazy. It is like a Mongoose for Hyperledger Fabric. It may help to check it out.

0

It is also worth noting that, according to IBM, Composer is no longer recommended as a production solution, but only for prototyping. In HLF 1.3, chaincode can now be written in Go, Javascript and Java.

Paul Russell
  • 505
  • 3
  • 8