# README
Hyperledger Fabric chaincode kit (CCKit)
Overview
A smart contract is code, invoked by a client application external to the blockchain network – that manages access and modifications to a set of key-value pairs in the World State. In Hyperledger Fabric, smart contracts are referred to as chaincode.
CCKit is a programming toolkit for
- developing and testing Hyperledger Fabric golang chaincodes
- generating access layer for query / invoke chaincodes and chaincode event streaming
It enhances the development experience while providing developers components for creating more readable and secure smart contracts. Getting started
CCKit features
- Chaincode method router with invocation handlers and middleware capabilities
- Chaincode state modeling (like ORM for chaincode data) using protocol buffers or plain golang struct with private data support
- Chaincode state serializing customization
- Designing chaincode in gRPC service notation with code generation of chaincode SDK, gRPC and REST-API
- MockStub testing, allowing to immediately receive test results
Extensions
- Encryption data on application level
- Implementation of UTXO and account balance storage model token balance models
- Chaincode method access control
- Signing and verifying chaincode method payload with envelope
Examples
There are several chaincode "official" examples available:
- Commercial paper from official Hyperledger Fabric documentation
- Blockchain insurance application (testing tutorial: how to write tests for "insurance" chaincode)
and others
Main problems with existing examples are:
- Working with chaincode state at very low level
- Lots of code duplication (JSON marshalling / unmarshalling, validation, access control, etc)
- Chaincode methods routing appeared only in HLF 1.4 and only in Node.Js chaincode
- Uncompleted testing tools (MockStub)
Examples based on CCKit
- Cars - car registration chaincode, simplest example
- Commercial paper, service-oriented approach - recommended way to start new application. Code generation radically simplifies building on-chain and off-chain applications.
- Commercial paper - faithful reimplementation of the official example
- Commercial paper extended example - with protobuf chaincode state schema and other features
- ERC-20 - tokens smart contract, implementing ERC-20 interface
- ERC-20 UTXO - tokens smart contract, implementing ERC-20 interface with UTXO state keys
- Cars private - car registration chaincode with private data
- Payment - a few examples of chaincodes with encrypted state
Publications with usage examples
- Service-oriented Hyperledger Fabric application development using gRPC definitions
- Hyperledger Fabric smart contract data model: protobuf to chaincode state mapping
- Hyperledger Fabric chaincode test driven development (TDD) with unit testing
- ERC20 token as Hyperledger Fabric Golang chaincode
- CCKit: Routing and middleware for Hyperledger Fabric Golang chaincode
- Developing and testing Hyperledger Fabric smart contracts [RUS]
Installation
CCKit requires Go 1.16+
Standalone
git clone [email protected]:hyperledger-labs/cckit.git
go mod vendor
As dependency
go get github.com/hyperledger-labs/cckit
# Packages
No description provided by the author
No description provided by the author
Package gateway is a reverse proxy.
Package access contains structs for storing chaincode access control information.
Package router provides base router for using in chaincode Invoke function.
No description provided by the author
Package serialize for transforming between json serialized []byte and go structs.
No description provided by the author
No description provided by the author