Interacting With Chaintool Managed Applications

Tooling

chaintool uses a protobuf-based protocol tunneled over the standard Fabric chaincode protocol. You may find that chaintool proto and chaintool inspect commands are helpful to translate from CCI to .proto files for your client’s consumption.

Protocol

Input Protocol

The standard Fabric protocol consists of an array of byte “args”. This protobuf schema for the standard chaincode protocol is:

message ChaincodeInput {

    repeated byte args  = 1;

}

Chaintool deterministically maps functions declared within a CCI to an encoded function name, and expects the corresponding input parameter to be a serialized protobuf message as the first and only arg string.

Example:

["org.hyperledger.chaincode.example02/fcn/3",<Buffer>"CgNmb28="]

Function Encoding

Function naming follows the convention interface-name/fcn/method-index. For instance, invoking MakePayment from our example would be org.hyperledger.chaintool.example02/fcn/1. Because its function #1 in the org.hyperledger.chaintool.example02 interface.

Output Protocol

Standard chaincode protocol allows chaincode applications to return a byte-array payload to a caller. Chaintool managed applications will encode this payload with a serialized protobuf structure (when applicable).

Protobuf “hints”

The .proto file generated from chaintool (such as chaintool proto) contains hints to help developers understand the protocol. For instance, see the comments at the bottom of this .proto generated from example02:

//
// Generated by chaintool.  DO NOT EDIT!!
//

syntax = "proto3";

package org.hyperledger.chaincode.example02;

message BalanceResult {
         int32 balance = 1;
}

message Entity {
         string id = 1;
}

message PaymentParams {
         string partySrc = 1;
         string partyDst = 2;
         int32 amount = 3;
}

//
// Available RPC functions exported by this interface
//
// void MakePayment(PaymentParams) -> org.hyperledger.chaincode.example02/fcn/1
// void DeleteAccount(Entity) -> org.hyperledger.chaincode.example02/fcn/2
// BalanceResult CheckBalance(Entity) -> org.hyperledger.chaincode.example02/fcn/3

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License. s