{"id":19270123,"url":"https://github.com/hyperledger-labs/hlf-connector","last_synced_at":"2025-10-24T08:17:05.975Z","repository":{"id":38196910,"uuid":"458257707","full_name":"hyperledger-labs/hlf-connector","owner":"hyperledger-labs","description":"Integrate with Hyperledger Fabric using REST and Kafka with Block and Chaincode Event emitter.","archived":false,"fork":false,"pushed_at":"2025-03-12T05:37:06.000Z","size":416,"stargazers_count":14,"open_issues_count":11,"forks_count":24,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-01T16:05:42.970Z","etag":null,"topics":["blockchain","connector","hacktoberfest","hacktoberfest-accepted","hyperledger","hyperledger-fabric","java","kafka","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperledger-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-11T16:19:25.000Z","updated_at":"2025-03-12T05:37:09.000Z","dependencies_parsed_at":"2024-02-05T13:31:58.386Z","dependency_job_id":"86a71318-f96f-49a2-bef5-08b914822d32","html_url":"https://github.com/hyperledger-labs/hlf-connector","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-labs%2Fhlf-connector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-labs%2Fhlf-connector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-labs%2Fhlf-connector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-labs%2Fhlf-connector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperledger-labs","download_url":"https://codeload.github.com/hyperledger-labs/hlf-connector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250128469,"owners_count":21379518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","connector","hacktoberfest","hacktoberfest-accepted","hyperledger","hyperledger-fabric","java","kafka","rest-api"],"created_at":"2024-11-09T20:23:26.758Z","updated_at":"2025-10-24T08:17:00.917Z","avatar_url":"https://github.com/hyperledger-labs.png","language":"Java","funding_links":[],"categories":["Blockchain"],"sub_categories":["FreeSWITCH"],"readme":"# Hyperledger Fabric REST Integration\n\n## Description:-\n\u003cp\u003eThis artifact provides a mechanism to invoke and query fabric chaincode using a REST-based API interface.\u003c/br\u003e\nAdditionally, it can also invoke chaincode using a asynchronous method and can publish chaincode events to Kafka/Event-Hub topics.\u003c/p\u003e\n\n## Key Feature:-\u003c/br\u003e\n1. Invoke Chaincode with REST.\u003c/br\u003e\n2. Query Chaincode with REST.\u003c/br\u003e\n3. Invoke Chaincode with Kafka/Event-Hub.\u003c/br\u003e\n4. Publish chaincode events from multiple channels to Kafka/Event-Hub.\u003c/br\u003e\n\n## Prerequisites:-\u003c/br\u003e\n1. Fabric 2.x network.\u003c/br\u003e\n2. Connection Profile YAML file.\u003c/br\u003e\n3. Wallet (.id) file.\u003c/br\u003e\n4. Java and Maven is installed.\n5. (Optional) Kafka/Event-Hub configuration for invoking chaincode asynchronously.\u003c/br\u003e\n6. (Optional) Kafka/Event-Hub configuration for publishing chaincode events.\u003c/br\u003e\n\n## Running Locally:-\u003c/br\u003e\n1. Download/Clone the repository and build the project using ``mvn clean install``\n2. Create a folder \u003ci\u003ewallet\u003c/i\u003e in the root directory of the project.\u003c/br\u003e\n3. If using [fabric-getting-started](https://github.com/anandbanik/fabric-getting-started) script, note the path to CA Pem file for Org1.\u003c/br\u003e Usually located in ``fabric-getting-started/test-network/organizations/peerOrganizations/org1.example.com/ca`` folder.\n4. Open [EnrollAdmin.java](https://github.com/blockchain-wmt/hlf-connector/blob/main/src/test/java/hlf/java/rest/client/util/EnrollAdmin.java) and set the ``pemFilePath`` variable with value noted above and run. This will create ``admin.id`` in the \u003ci\u003e wallet \u003c/i\u003e folder.\n5. Open [RegisterUser](https://github.com/blockchain-wmt/hlf-connector/blob/main/src/test/java/hlf/java/rest/client/util/RegisterUser.java) and set the ``pemFilePath`` variable with value noted above and run. This will create ``clientUser.id`` in the \u003ci\u003e wallet \u003c/i\u003e folder.\n2. Add the ``connection-org1.yaml`` file, located at ``fabric-getting-started/test-network/organizations/peerOrganizations/org1.example.com`` to the wallet folder.\u003c/br\u003e\n3. Make sure the Peer URL and CA URL in ``connection-org1.yaml`` are reachable.\u003c/br\u003e If using [fabric-getting-started](https://github.com/anandbanik/fabric-getting-started), change the peer URL in ``connection-org1.yaml`` to ``peer0.org1.example.com:7051`` and CA URL to ``ca-org1:7054``.\n4. Run, \u003ci\u003ehlf.java.rest.client.FabricClientBootstrap\u003c/i\u003e java file or jar file.\n5. You can also run as container using ``docker-compose up``.\u003c/br\u003e If the fabric network is running local, make sure the docker-compose.yml file is configured to use the correct network.\u003c/br\u003e\n```\nnetworks:\n  default:\n    external:\n      name: \u003cfabric's network\u003e\n```\n\n## Event-driven Design\n\n### Asynchronous Integration to invoke chaincode\nThis component supports event-based architecture by consuming transactions through Kafka \u0026 Azure EventHub. \nTo configure it, use the below configuration in the application.yml file.\n```\nkafka:\n  integration-points:\n  -\n    brokerHost: \u003cHostname1 with Port\u003e\n    groupId: \u003cGroup ID\u003e\n    topic: \u003cTopic Name\u003e\n  -\n    brokerHost: \u003cHostname2 with Port\u003e\n    groupId: \u003cGroup ID\u003e\n    topic: \u003cTopic Name\u003e\n    # For Azure EventHub\n    jaasConfig: org.apache.kafka.common.security.plain.PlainLoginModule required username=\"$ConnectionString\" password=\"Endpoint=sb://\u003cHostname\u003e/;SharedAccessKeyName=\u003ckey-name\u003e;SharedAccessKey=\u003ckey-value\u003e\";\n    # For SOX compliant Kafka Clusters\n    ssl-enabled: true\n    security-protocol: SSL\n    ssl-keystore-location: \u003cYOUR_SSL_KEYSTORE_PATH\u003e\n    ssl-keystore-password: \u003cYOUR_SSL_PASSWORDH\u003e\n    ssl-truststore-location: \u003cYOUR_SSL_TRUSTSTORE_PATH\u003e\n    ssl-truststore-password: \u003cYOUR_SSL_TRUSTSTORE_PASSWORD\u003e\n    ssl-key-password: \u003cYOUR_SSL_KEY_PASSWORD\u003e\n```\nThe component accepts JSON payload and 3 headers to invoke the chaincode.\nPlease find below the keys for the headers:-\n```\n1. channel_name\n2. function_name\n3. chaincode_name\n```\n\n### Capture Chaincode events:-\nThis component supports capturing chaincode events and publish it to Kafka or Azure EventHub. This can be useful for integrating with offchain DB.\nTo configure it, use the below configuration in the application.yml file.\n```\nfabric:\n  events:\n    enabled: true\n    chaincode: mychannel1,mychannel2  #Comma-separated list for listening to events from multiple channels \nkafka:\n  event-listener:\n    brokerHost: \u003cHostname with Port\u003e\n    topic: \u003cTopic Name\u003e\n    # For Azure EventHub\n    jaasConfig: org.apache.kafka.common.security.plain.PlainLoginModule required username=\"$ConnectionString\" password=\"Endpoint=sb://\u003cHostname\u003e/;SharedAccessKeyName=\u003ckey-name\u003e;SharedAccessKey=\u003ckey-value\u003e\";\n    # For SOX compliant Kafka Clusters\n    ssl-enabled: true\n    security-protocol: SSL\n    ssl-keystore-location: \u003cYOUR_SSL_KEYSTORE_PATH\u003e\n    ssl-keystore-password: \u003cYOUR_SSL_PASSWORDH\u003e\n    ssl-truststore-location: \u003cYOUR_SSL_TRUSTSTORE_PATH\u003e\n    ssl-truststore-password: \u003cYOUR_SSL_TRUSTSTORE_PASSWORD\u003e\n    ssl-key-password: \u003cYOUR_SSL_KEY_PASSWORD\u003e\n```\nThe component will send the same JSON payload sent by the chaincode and add the following headers.\n\n```\n1. fabric_tx_id\n2. event_name\n3. channel_name\n4. event_type (value: chaincode_event)\n```\n\n### Capture Block events:-\nThis component supports capturing block events and publish it to Kafka or Azure EventHub. This can be useful for integrating with offchain DB where adding events to chaincode is not possible (for ex - Food-Trust anchor channel).\nTo configure it, use the below configuration in the application.yml file.\n```\nfabric:\n  events:\n    enabled: true\n    block: mychannel1,mychannel2  #Comma-separated list for listening to events from multiple channels \nkafka:\n  event-listener:\n    brokerHost: \u003cHostname with Port\u003e\n    topic: \u003cTopic Name\u003e\n    # For Azure EventHub\n    jaasConfig: org.apache.kafka.common.security.plain.PlainLoginModule required username=\"$ConnectionString\" password=\"Endpoint=sb://\u003cHostname\u003e/;SharedAccessKeyName=\u003ckey-name\u003e;SharedAccessKey=\u003ckey-value\u003e\";\n    # For SOX compliant Kafka Clusters\n    ssl-enabled: true\n    security-protocol: SSL\n    ssl-keystore-location: \u003cYOUR_SSL_KEYSTORE_PATH\u003e\n    ssl-keystore-password: \u003cYOUR_SSL_PASSWORDH\u003e\n    ssl-truststore-location: \u003cYOUR_SSL_TRUSTSTORE_PATH\u003e\n    ssl-truststore-password: \u003cYOUR_SSL_TRUSTSTORE_PASSWORD\u003e\n    ssl-key-password: \u003cYOUR_SSL_KEY_PASSWORD\u003e\n```\nThe component will send the same JSON payload sent by the chaincode and add the following headers.\n\n```\n1. fabric_tx_id\n2. channel_name\n3. chaincode name\n4. function_name\n5. event_type (value: block_event)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger-labs%2Fhlf-connector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperledger-labs%2Fhlf-connector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger-labs%2Fhlf-connector/lists"}