{"id":34131559,"url":"https://github.com/s7techlab/hyperledger-fabric-samples","last_synced_at":"2026-03-09T16:07:18.399Z","repository":{"id":48160182,"uuid":"200252441","full_name":"s7techlab/hyperledger-fabric-samples","owner":"s7techlab","description":"Hyperledger Fabric sample applications","archived":false,"fork":false,"pushed_at":"2022-07-28T13:46:26.000Z","size":736,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-17T11:54:06.591Z","etag":null,"topics":["blockchain-application","chaincode","golang","hyperledger-fabric","samples"],"latest_commit_sha":null,"homepage":"https://medium.com/@viktornosov/service-oriented-hyperledger-fabric-application-development-32e66f578f9a","language":"Shell","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/s7techlab.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}},"created_at":"2019-08-02T14:51:21.000Z","updated_at":"2024-11-20T05:26:51.000Z","dependencies_parsed_at":"2022-08-25T08:00:43.716Z","dependency_job_id":null,"html_url":"https://github.com/s7techlab/hyperledger-fabric-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/s7techlab/hyperledger-fabric-samples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s7techlab%2Fhyperledger-fabric-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s7techlab%2Fhyperledger-fabric-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s7techlab%2Fhyperledger-fabric-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s7techlab%2Fhyperledger-fabric-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s7techlab","download_url":"https://codeload.github.com/s7techlab/hyperledger-fabric-samples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s7techlab%2Fhyperledger-fabric-samples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30301592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T14:33:48.460Z","status":"ssl_error","status_checked_at":"2026-03-09T14:33:48.027Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-application","chaincode","golang","hyperledger-fabric","samples"],"created_at":"2025-12-15T00:54:27.916Z","updated_at":"2026-03-09T16:07:18.368Z","avatar_url":"https://github.com/s7techlab.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hyperledger Fabric Golang application examples\n\n* [Token foundation](samples/token)\n* [Commercial paper](samples/cpaper)\n\n## How to create HyperLedger Fabric Golang application project\n\n### Main points\n\n* `Protobuf` message and service definitions allows to model chaincode in high level Interface Definition Language (IDL)\n* [Code generation](https://blog.golang.org/generate) allows to automate development process\n  of creating API's, SDK, documentation for chainode\n\n### Development steps\n\n1. Define model using `.proto` file\n2. Generate code and documentation with generators\n3. Implement chaincode as service and tests\n4. Create chaincode binary\n5. Create API\n\n## Prerequisites\n\n### Generators\n\nGenerators allows to automatically build lot of useful code and docs : Golang structures,\nvalidators, gRPC service interface and client, documentation in Markdown format and Swagger specification,\nchaincode gateway for implementing API or SDK and mapper for embedding strong typed gRPC service\nto chaincode implementation.\n\n![img](samples/cpaper/docs/img/cc-code-gen.png)\n\n1. [Protobuf generator](https://github.com/golang/protobuf)\n\nGo support for Protocol Buffers\n\n2. [Validator generator](https://github.com/mwitkow/go-proto-validators)\n\nA `protoc` plugin that generates `Validate() error` functions on Go proto structs based on field options inside\n`.proto` files.\n\n3. [gRPC gateway generator](https://github.com/grpc-ecosystem/grpc-gateway)\n\nProvides HTTP+JSON interface to gRPC service. A small amount of configuration in your service to attach HTTP semantics\nis all that's needed to generate a reverse-proxy with this library. Optionally emitting API definitions for\nOpenAPI (Swagger) v2.\n\n4. [Documentation generator](https://github.com/pseudomuto/protoc-gen-doc)\n\ndocumentation generator plugin for the Google Protocol Buffers compiler (protoc).\nThe plugin can generate HTML, JSON, DocBook and Markdown documentation from comments in your .proto files.\n\n5. [Chaincode gateway generator](https://github.com/s7techlab/cckit/tree/master/gateway)\n\n#### Install generators\n\n`cd geterators \u0026\u0026 ./install.sh`\n\nThis will place five binaries in [generators/bin](generators/bin);\n\n* `protoc-gen-go`\n* `protoc-gen-govalidators`\n* `protoc-gen-grpc-gateway`\n* `protoc-gen-swagger`\n* `protoc-gen-doc`\n\n## Step by step\n\n#### 1. Create a directory for project\n\noutside of your `$GOPATH`\n\n#### 2. Initialize a new module inside this directory\n\n```bash\n# go mod init {put your module name here}  \n```\n\n(for example `github.com/s7techlab/hyperledger-fabric-samples)\n\n#### 3. Create `.proto` definitions\n\ngRPC technology stack natively supports a clean and powerful way to specify service contracts using the Interface\nDefinition Language (IDL):\n\n* messages defines data structures of the input parameters and return types.\n* services definition outlines methods signatures that can be invoked remotely\n\nChaincode [messages and service](samples/cpaper/cpaper.proto) allows to define chaincode interface and\ndata schema.\n\n#### 4. Generate code\n\nCreate [proto/Makefile](samples/cpaper/proto/Makefile) for compiling `.proto` to `Golang` code\n\n```Makefile\n.: generate\n\ngenerate:\n\t@protoc --version\n\t@echo \"commercial paper schema proto generation\"\n\t@protoc -I=./ \\\n\t-I=${GOPATH}/src \\\n\t-I=${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \\\n\t--go_out=plugins=grpc:./ \\\n\t--govalidators_out=./ \\\n\t--grpc-gateway_out=logtostderr=true:./ \\\n\t--swagger_out=logtostderr=true:./ \\\n\t--doc_out=./ --doc_opt=markdown,commercial-paper.md \\\n\t--cc-gateway_out=logtostderr=true:./ \\\n\t./*.proto\n```\n\nand run it. Following files will be generated:\n\n* [commercial-paper.md](samples/cpaper/proto/commercial-paper.md) -documentation\n* [commercial-paper.pb.cc.go](samples/cpaper/proto/commercial-paper.pb.cc.go) - gateway for chaincode\n* [commercial-paper.pb.go](samples/cpaper/proto/commercial-paper.pb.go) - Golang structs and gRPC service\n* [commercial-paper.pb.gw.go](samples/cpaper/proto/commercial-paper.pb.gw.go) - gRPC gateway\n* [commercial-paper.swagger.json](samples/cpaper/proto/commercial-paper.swagger.json) - Swagger specification\n* [commercial-paper.validator.pb.go](samples/cpaper/proto/commercial-paper.validator.pb.go) - validators\n\n#### 5. Load dependencies\n\nStandard commands like `go build` or `go test` will automatically add new dependencies as needed to\nsatisfy imports (updating go.mod and downloading the new dependencies).\n\n`# go mod vendor`\n\nThis command add dependencies to [go.mod](go.mod) file and download it to [vendor](vendor) directory\nGo.mod file will contain:\n\n```\nmodule github.com/s7techlab/hyperledger-fabric-samples\n\ngo 1.12\n\nrequire (\n\tgithub.com/golang/protobuf v1.3.2\n\tgithub.com/grpc-ecosystem/grpc-gateway v1.9.5\n\tgithub.com/hyperledger/fabric v1.4.4\n\tgithub.com/mwitkow/go-proto-validators v0.0.0-20190709101305-c00cd28f239a\n\tgithub.com/onsi/ginkgo v1.8.0\n\tgithub.com/onsi/gomega v1.5.0\n\tgithub.com/pkg/errors v0.8.1\n\tgithub.com/s7techlab/cckit v0.6.9\n\tgoogle.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64\n\tgoogle.golang.org/grpc v1.22.1\n)\n\n```\n\n#### 6. Implement chaincode as service and tests\n\nImplement [chaincode service and chaincode](samples/cpaper/chaincode/chaincode.go) and\n[test](samples/cpaper/chaincode/chaincode_test.go). After that don't forget to call `go mod vendor`\nto download newly added dependencies  (Ginkgo and Gomega)\n\nYou can test chaincode service with command\n\n`#chaincode go test -mod vendor`\n\nCheck test code coverage: chaincode logic must be covered by test to maximum level. Code coverage of 70-80% is a\nreasonable goal for system test of most projects with most coverage metrics\n\n`#chaincode go test -mod vendor -coverage`\n\n#### 7. Implement off-chain application to communicate with chaincode (API)\n\nWith [CCKit gateway](https://github.com/s7techlab/cckit/tree/master/gateway) and generated\n[gRPC service server](samples/cpaper/proto/commercial-paper.pb.go)\nand [gRPC gateway](samples/cpaper/proto/commercial-paper.pb.gw.go)\nquite ease to implement [API](samples/cpaper/api) for chaincode.\n\nYou can run provided mocked example using command\n\n```\n# cd commercial-paper/api/mock\n# go run main.go\n```\n\n![start](samples/cpaper/docs/img/gateway-mocked-start.png)\n\nThen you can use API usage examples and sample payloads:\n\n![example](samples/cpaper/docs/img/gateway-mocked-usage.png)\n\n`grpc-gateway` will automatically converts http request to gRPC call, input JSON payloads to protobuf, invokes chaincode\nservice and then converts returned value from protobuf to JSON. You can also use this service as pure gRPC service.\nChaincode methods can be called with [generated gRPC client](samples/cpaper/proto/commercial-paper.pb.go).\n\nSwagger [specification](samples/cpaper/proto/commercial-paper.swagger.json), service and schema documentation are also\n[auto-generated](samples/cpaper/proto/commercial-paper.md).\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs7techlab%2Fhyperledger-fabric-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs7techlab%2Fhyperledger-fabric-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs7techlab%2Fhyperledger-fabric-samples/lists"}