ChainMetric: Smart Contracts
Overview
Chainmetric Smart Contracts are designed to grand access to blockchain-stored data while implementing such data validation, aggregation, and management functionality.
Being a part of a permissioned blockchain network based on Hyperledger Fabric stack, such Contracts are written in Go and configured to be deployed as Kubernetes services communicating with each other, blockchain peers, and external applications via gRPC protocol and event streaming.
Requirements
- Kubernetes cluster with previously deployed Chainmetric network (see network deployment procedure)
- Helm binaries must be presented on a local machine from which deployment script will be used.
Deployment
Bash-script from network repository provides a straightforward way of deployment and further upgrading of Smart Contracts, which are essential for a current blockchain solution.
Chaincodes (alternative to Smart Contracts) in Hyperledger Fabric infrastructure can be deployed both by embedding their source code into the blockchain peers and by deploying them as external services, which is a way more versatile option especially for Kubernetes cluster environment where such Chaincodes can be deployed as a pods.
To deploy Smart Contract for the first time it is required to pack its configuration in an archive and then use it with peer lifecycle commands
. All required steps are conveniently aggregated in a single command of network.sh
script from the network repository. To perform Chaincode's initial deployment use deploy
command with cc
action as following:
$ ./network.sh deploy cc --cc_name=`chaincode name` --channel='channel name' --peer='peer subdomain name' --org='organization name'
After this whenever an upgrade must be performed simply add --upgrade
flag to the previously executed command. That will rebuild the docker image, send it to the dedicated registry and redeploy the Helm chart.
Roadmap
- Requirements violation event streaming
- Violations rule engine
- Transaction for assets changes history retrieving
- Devices location management business logic
- Users contract
Wrap up
Chainmetric's Smart Contracts are the accumulation of this project's business logic in the form of distributed, atomically granulated on-chain services, where each is responsible only for its entities, use cases, and transactions handling.
They are exposing access to the data stored on blockchain immutable ledger by publishing their contracts as gRPC remote procedures and continuously emitted event streams.
Other parts of the Chainmetric project, such as embedded sensor-equipped IoT devices and cross-platform mobile application utilizes exposed contacts by remote procedure calling and subscribing to event streams.
License
Licensed under the Apache 2.0.