Re: setup multi-org fabric network using peer dev mode

David F. D. Reis

Hello Satheesh. How are you? I hope you are doing well.

My personal dev environment is using the CCAAS builders that came with 2.4+ version with vagrant and connecting remotely using an IDE (VSCODE or IntelliJ).

If you are using fabric samples, you just need change all of your peers to start with --peer-chaincodedev=true ( YAML line with command: peer node start --peer-chaincodedev=true - compose-test-net.yaml) and start your network to be able to debug.

In my case, when I am developing the chaincode, I start the chaincode using my IDE using the command:

-  "start:server-debug": "set -x && NODE_OPTIONS='--inspect=' fabric-chaincode-node server --chaincode-address=$CHAINCODE_SERVER_ADDRESS --chaincode-id=$CHAINCODE_ID",

  • The variable CHAINCODE_SERVER_ADDRESS is the same as "address" key of the connection.json (Ex.: and configure the /etc/hosts to resolve this dns when needed or use solution to get correct DNS resolution).
  • The variable CHAINCODE_ID may be obtained during install command;

The chaincode package that will be installed in all peers, I generate using the following commands (I am using Javascript / Typescript chaincodes):

  • tar cfz code.tar.gz connection.json ../META-INF
  • tar cfz mycoolchaincode.tgz metadata.json code.tar.gz
(I do the install  in all peers if needed);

NOTE: with this setup, all peers will use only one chaincode endpoint (running attached to IDE).

And finally, I change the endorsement rule to need only one endorsement and the peers execute only one time the chaincode. In a multi org, the breakpoint will get accessed a lot of times, turning the debug process a little more difficult:
  • --signature-policy "OR('Org1MSP.member', 'Org2MSP.member')"
To deploy under a test environment or test KUBERNETES cluster (One chanincode by peer), I use the following connection.json:

    "address": "{{.peername}}.mycoolchaincode.cooldomain:9998",
    "dial_timeout": "10s",
    "tls_required": false

The variable {{.peername}} is related to the folllowing PEER environment variable:

    - CHAINCODE_AS_A_SERVICE_BUILDER_CONFIG={"peername":"peer0org2"}

NOTE: with this setup, each of the peers will have his own chaincode container. If you start all of the chaincode containers in debug mode (NODE_OPTIONS='--inspect='), you will be able to remotely connect to the container using the IDE and debug using the port 9229. If you have a lot of peers and orgs, maybe the connected chaincode for debug will not be accessed by the transaction if the other peers endorse the transaction first. (Of Course, you can force the transaction to a specific peer configuring it on the client side).

So, I think that it is almost the same effort to setup a multi org environment setting the peer dev mode to true.

My best regards.


Em ter., 17 de mai. de 2022 às 06:14, satheesh via <> escreveu:

Hello Community,

Using Hyperledger fabric 2.4

While working on a Hyperledger Fabric use case,  realized that setting up a environment where peer can be run in
development mode (peer node start --peer-chaincodedev=true) is quite fast to iterate chaincode development.

Official documentation provides material to setup up such environment but for only one org.
But if we want to setup a multi-org consortium using peer development mode, Is there any reference material
available ? Appreciate any pointers.


Join to automatically receive all group messages.