Hyperledger sample flows

Node-red Hyperledger Chaincode

Those nodes developed in order to act as integration points for nodered

Deployment

npm install node-red-contrib-hyperledger

[{"id":"3be84111.248b9e","type":"inject","z":"9c3ae754.6e5768","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":173.9333038330078,"y":122.4000186920166,"wires":[["5368719b.db55"]]},{"id":"5368719b.db55","type":"function","z":"9c3ae754.6e5768","name":"enroll-id","func":"msg.payload = {\"enrollId\": \"admin\", \"enrollSecret\":\"<your-secret>\"};\nmsg.peer = 'bluemix-peer-url';\nmsg.port = '5004';\nreturn msg;\n\n","outputs":1,"noerr":0,"x":346.13330078125,"y":133.2000217437744,"wires":[["b13f394b.c53058","372258f.12027a8"]]},{"id":"b13f394b.c53058","type":"enroll","z":"9c3ae754.6e5768","name":"","x":587.1333160400391,"y":143.46671867370605,"wires":[["664becac.8e2204"]]},{"id":"664becac.8e2204","type":"debug","z":"9c3ae754.6e5768","name":"","active":true,"console":"false","complete":"false","x":772.1333618164062,"y":99.80004501342773,"wires":[]},{"id":"372258f.12027a8","type":"debug","z":"9c3ae754.6e5768","name":"","active":true,"console":"false","complete":"payload","x":479.6999206542969,"y":63.00000190734863,"wires":[]},{"id":"4673e0ac.0dec8","type":"deploy","z":"9c3ae754.6e5768","name":"","x":485.93328857421875,"y":277.0666904449463,"wires":[["b3bfa4bc.818b28"]]},{"id":"52e6578.43acca8","type":"function","z":"9c3ae754.6e5768","name":"deploy-code","func":"msg.peer = 'bluemix-peer-url';\nmsg.port = '5004';\nmsg.payload = \n{\n  \"params\": {\n    \"type\": 1,\n    \"chaincodeID\": {\n      \"path\": \"https://github.com/<your github>/learn-chaincode/finished\"\n    },\n    \"ctorMsg\": {\n      \"function\": \"init\",\n      \"args\": [\n        \"hi there\"\n      ]\n    },\n    \"secureContext\": \"admin\"\n  },\n  \"id\": 1\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":346.9666290283203,"y":281.00004386901855,"wires":[["4673e0ac.0dec8"]]},{"id":"1759694a.399217","type":"inject","z":"9c3ae754.6e5768","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":154.76663208007812,"y":286.1999988555908,"wires":[["52e6578.43acca8"]]},{"id":"b3bfa4bc.818b28","type":"debug","z":"9c3ae754.6e5768","name":"","active":true,"console":"false","complete":"false","x":684.6999206542969,"y":282.00000190734863,"wires":[]},{"id":"b8b04034.cc11","type":"inject","z":"9c3ae754.6e5768","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":156.699951171875,"y":411.99999380111694,"wires":[["bbcf6c3e.58b2"]]},{"id":"29f50251.277cae","type":"debug","z":"9c3ae754.6e5768","name":"","active":true,"console":"false","complete":"false","x":677.6999206542969,"y":401.9999713897705,"wires":[]},{"id":"5c178e4.14d2d7","type":"query","z":"9c3ae754.6e5768","name":"","x":560.9332885742188,"y":520.4666843414307,"wires":[["29f50251.277cae"]]},{"id":"bbcf6c3e.58b2","type":"function","z":"9c3ae754.6e5768","name":"query-code","func":"msg.peer = 'bluemix-peer-url';\nmsg.port = '5004';\nmsg.payload ={\n   \"params\":{\n      \"type\":1,\n      \"chaincodeID\":{\n         \"name\":\"your retrned code\"\n      },\n      \"ctorMsg\":{\n         \"function\":\"read\",\n         \"args\":[\n            \"hello_world\"\n         ]\n      },\n      \"secureContext\":\"admin\"\n   },\n   \"id\":2\n};\n\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":363.6999206542969,"y":432.00000190734863,"wires":[["5c178e4.14d2d7"]]},{"id":"151dad43.e59e43","type":"invoke","z":"9c3ae754.6e5768","name":"","x":510.93328857421875,"y":617.3333835601807,"wires":[["a81bdc38.854b9"]]},{"id":"83ec5219.91975","type":"function","z":"9c3ae754.6e5768","name":"invoke-code","func":"msg.peer = 'b744f666ac4841868fb5e1c665f6aa1f-vp0.us.blockchain.ibm.com';\n//msg.peer = 'localhost';\nmsg.port = '5004';\nmsg.payload ={\n  \"params\": {\n    \"type\": 1,\n    \"chaincodeID\": {\n      \"name\":\"your retrned code\"\n    },\n    \"ctorMsg\": {\n      \"function\": \"write\",\n      \"args\": [\n        \"hello_world\", \"go away\"\n      ]\n    },\n    \"secureContext\": \"admin\"\n  },\n  \"id\": 3\n};\nreturn msg;\n\n","outputs":1,"noerr":0,"x":334.7666015625,"y":585.9999713897705,"wires":[["151dad43.e59e43"]]},{"id":"4b351a3b.e67684","type":"inject","z":"9c3ae754.6e5768","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":127.76663208007812,"y":565.9999632835388,"wires":[["83ec5219.91975"]]},{"id":"a81bdc38.854b9","type":"debug","z":"9c3ae754.6e5768","name":"","active":true,"console":"false","complete":"false","x":719.6999206542969,"y":564.9999713897705,"wires":[]}]
ahmadsayed

Flow Info

created 5 months, 3 weeks ago

Node Types

Core
  • debug (x5)
  • function (x4)
  • inject (x4)
Other
  • deploy (x1)
  • enroll (x1)
  • invoke (x1)
  • query (x1)

Tags

  • blockchain
  • hyperledger
  • bluemix
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option