{"id":29227466,"url":"https://github.com/kfsoftware/plugin-hlf-api","last_synced_at":"2025-07-03T09:31:31.306Z","repository":{"id":301332213,"uuid":"979014418","full_name":"kfsoftware/plugin-hlf-api","owner":"kfsoftware","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-26T09:55:56.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-26T10:34:54.757Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kfsoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-06T21:32:52.000Z","updated_at":"2025-06-26T09:56:00.000Z","dependencies_parsed_at":"2025-06-26T10:45:24.945Z","dependency_job_id":null,"html_url":"https://github.com/kfsoftware/plugin-hlf-api","commit_stats":null,"previous_names":["kfsoftware/plugin-hlf-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kfsoftware/plugin-hlf-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfsoftware%2Fplugin-hlf-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfsoftware%2Fplugin-hlf-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfsoftware%2Fplugin-hlf-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfsoftware%2Fplugin-hlf-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kfsoftware","download_url":"https://codeload.github.com/kfsoftware/plugin-hlf-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfsoftware%2Fplugin-hlf-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263300114,"owners_count":23445187,"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":[],"created_at":"2025-07-03T09:30:58.756Z","updated_at":"2025-07-03T09:31:31.274Z","avatar_url":"https://github.com/kfsoftware.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hyperledger Fabric API\n\nThis is a REST API service that provides endpoints to interact with a Hyperledger Fabric network using the fabric-gateway library.\n\n## Features\n\n- Invoke transactions on the blockchain\n- Evaluate transactions (queries) without writing to the blockchain\n- Multi-peer support with random peer selection for load balancing\n- CLI-based configuration\n- Chi router for efficient HTTP routing\n- Proper error handling and JSON responses\n\n## Prerequisites\n\n- Go 1.19 or later\n- Access to a Hyperledger Fabric network\n- Valid certificates and private keys for authentication\n\n## Installation\n\n```bash\ngo get github.com/kfsoftware/chainlaunch-plugin-hlf\n```\n\n## Usage\n\n### Starting the Server\n\nThe server requires several parameters to connect to your Fabric network. You can specify multiple peers for load balancing:\n\n```bash\n./plugin-hlf-api serve \\\n  --port 8080 \\\n  --mspid \"Org1MSP\" \\\n  --cert \"/path/to/cert.pem\" \\\n  --key \"/path/to/key.pem\" \\\n  --peers \"localhost:7051,localhost:8051,localhost:9051\" \\\n  --tlscerts \"/path/to/peer1-tls.pem,/path/to/peer2-tls.pem,/path/to/peer3-tls.pem\" \\\n  --channel \"mychannel\" \\\n  --chaincode \"basic\"\n```\n\nThe API will automatically distribute requests across the configured peers using random selection.\n\n### Configuration Parameters\n\n- `--port`: Port to run the API server (default: 8080)\n- `--mspid`: MSP ID of the organization\n- `--cert`: Path to the client certificate\n- `--key`: Path to the client private key\n- `--peers`: Comma-separated list of peer endpoints (host:port)\n- `--tlscerts`: Comma-separated list of paths to peer TLS certificates (one per peer)\n- `--channel`: Channel name\n- `--chaincode`: Chaincode name\n\nNote: The number of peer endpoints must match the number of TLS certificates provided.\n\n### API Endpoints\n\n#### Invoke Transaction\n\n```http\nPOST /api/invoke\nContent-Type: application/json\n\n{\n  \"chaincode_name\": \"basic\",\n  \"function\": \"CreateAsset\",\n  \"args\": [\"asset1\", \"blue\", \"5\", \"tom\", \"100\"]\n}\n```\n\n#### Evaluate Transaction (Query)\n\n```http\nPOST /api/evaluate\nContent-Type: application/json\n\n{\n  \"chaincode_name\": \"basic\",\n  \"function\": \"GetAllAssets\",\n  \"args\": []\n}\n```\n\n### Response Format\n\nSuccess Response:\n```json\n{\n  \"status\": \"success\",\n  \"result\": \"transaction result here\"\n}\n```\n\nError Response:\n```json\n{\n  \"status\": \"error\",\n  \"error\": \"error message here\"\n}\n```\n\n## Load Balancing\n\nThe API implements a random peer selection strategy for both invoke and evaluate transactions. This helps distribute the load across all available peers in the network. Each request will be randomly assigned to one of the configured peers.\n\n## Development\n\nTo build the project:\n\n```bash\ngo build -o plugin-hlf-api\n```\n\n## Docker Support\n\n### Building the Docker Image\n\nBuild the Docker image using:\n\n```bash\ndocker build -t fabric-api:latest .\n```\n\n### Running with Docker\n\nThe API can be run in a Docker container. You'll need to mount your certificates and private keys into the container:\n\n```bash\ndocker run -d \\\n  --name fabric-api \\\n  -p 8080:8080 \\\n  -v /path/to/certs:/app/crypto \\\n  fabric-api:latest \\\n  serve \\\n  --mspid \"Org1MSP\" \\\n  --cert \"/app/crypto/cert.pem\" \\\n  --key \"/app/crypto/key.pem\" \\\n  --peers \"peer1:7051,peer2:7051,peer3:7051\" \\\n  --tlscerts \"/app/crypto/peer1-tls.pem,/app/crypto/peer2-tls.pem,/app/crypto/peer3-tls.pem\" \\\n  --channel \"mychannel\" \\\n  --chaincode \"basic\"\n```\n\n### Environment Variables\n\nYou can also configure the API using environment variables:\n\n```bash\ndocker run -d \\\n  --name fabric-api \\\n  -p 8080:8080 \\\n  -v /path/to/certs:/app/crypto \\\n  -e FABRIC_MSPID=\"Org1MSP\" \\\n  -e FABRIC_CERT_PATH=\"/app/crypto/cert.pem\" \\\n  -e FABRIC_KEY_PATH=\"/app/crypto/key.pem\" \\\n  -e FABRIC_PEERS=\"peer1:7051,peer2:7051,peer3:7051\" \\\n  -e FABRIC_TLS_CERTS=\"/app/crypto/peer1-tls.pem,/app/crypto/peer2-tls.pem,/app/crypto/peer3-tls.pem\" \\\n  -e FABRIC_CHANNEL=\"mychannel\" \\\n  -e FABRIC_CHAINCODE=\"basic\" \\\n  fabric-api:latest\n```\n\n### Docker Compose Example\n\nHere's an example docker-compose.yml for running the API:\n\n```yaml\nversion: '3.8'\nservices:\n  fabric-api:\n    build: .\n    ports:\n      - \"8080:8080\"\n    volumes:\n      - ./crypto:/app/crypto\n    environment:\n      - FABRIC_MSPID=Org1MSP\n      - FABRIC_CERT_PATH=/app/crypto/cert.pem\n      - FABRIC_KEY_PATH=/app/crypto/key.pem\n      - FABRIC_PEERS=peer1:7051,peer2:7051,peer3:7051\n      - FABRIC_TLS_CERTS=/app/crypto/peer1-tls.pem,/app/crypto/peer2-tls.pem,/app/crypto/peer3-tls.pem\n      - FABRIC_CHANNEL=mychannel\n      - FABRIC_CHAINCODE=basic\n    networks:\n      - fabric-network\n\nnetworks:\n  fabric-network:\n    external: true\n```\n\nNote: Make sure to adjust the volume mounts and network configuration according to your Fabric network setup.\n\n## License\n\nThis project is licensed under the Apache License 2.0. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfsoftware%2Fplugin-hlf-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkfsoftware%2Fplugin-hlf-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfsoftware%2Fplugin-hlf-api/lists"}