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:

Function name Permission to invoke Description
requestTrade

Importer

Requests a trade agreement

acceptTrade

Exporter

Accepts a trade agreement

requestLC

Importer

Requests a letter of credit

issueLC

Importer

Issues a letter of credit

acceptLC

Exporter

Accepts a letter of credit

requestEL

Exporter

Requests an export license

issueEL

Regulator

Issues an export license

prepareShipment

Exporter

Prepares a shipment

acceptShipmentAndIssueBL

Carrier

Accepts a shipment and issue a bill of lading

requestPayment

Exporter

Requests a payment

makePayment

Importer

Makes a payment

updateShipmentLocation

Carrier

Updates shipment location

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

Function name Permission to invoke Description
getTradeStatus

Exporter/ExportingEntity/Importer

Gets current state of a trade agreement

getLCStatus

Exporter/ExportingEntity/Importer

Get current state of a Letter of Credit

getELStatus

ExportingEntity/Regulator

Get current state of an Export License

getShipmentLocation

Exporter/ExportingEntity/Importer/Carrier

Get current location of a shipment

getBillOfLading

Exporter/ExportingEntity/Importer

Get the bill of lading

getAccountBalance

Exporter/ExportingEntity/Importer

Get current account balance for a given participant

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.144.108