Hands-On Blockchain with Hyperledger
上QQ阅读APP看书,第一时间看更新

Implementing chaincode functions

At this point, we now have the basic building blocks of chaincode. We have the Init method, which initiates the chaincode and the Invoke method, which receives request from the client and the access control mechanism. Now, we need to define the functionality of the chaincode.

Based on our scenario, the following tables summarize the list of functions that record and retrieve data to and from the ledger to provide the business logic of the smart contract. The tables also define the access control definitions of organization member, which are needed in order to invoke the respective functions.

The following table illustrates the chaincode modification functions, that is, how to record transactions on the ledger:

The following table illustrates the chaincode query functions, that is, those needed to retrieve data from the ledger: