Mapping the asset model

Chaincode results in the creation of assets (key-value pairs) on the ledger, as HLF represents assets as key-value pairs. Assets state changes are recorded as transactions on the channel's ledger. There are few ways to represent assets—in binary or JSON form. For the university use case in this book, two assets are defined:

  • One for student information
  • Another for the certificate generated

This chapter includes the creation of basic assets and chaincode to enable quick learning of the development process. The inclusion of more assets and a comprehensive set of operations might lead to the investment of time in the modeling of the use case itself. Later, when you've experimented more with the use case, you can add more complexity to it.

Using the Go language, the following are the definitions of the two assets:

  1. An asset to define a certificate receiver:

Parameter

Description

assetType

The type of asset, for example, a receiver

receiver_id

The ID of a receiver/student

receiver_name

The name of the receiver/student

upload_org

The organization/department of the certificate uploaded

  1. An asset to define a certificate:

Parameter

Description

assetType

The type of asset, for example, a certificate.

Cert_id

The ID of the certificate.

Cert_no

The number of the certificate.

Cert_name

The name of the certificate.

Cert_receiver

The receiver of the certificate. This will be fetched from the ledger by the given Cert_receiver_id parameter.

Cert_receiver_id

The ID of the receiver/student to whom this certificate is assigned.

Cert_issuer

The issuer of the certificate.

Cert_industry

The industry/department of the certificate.

Cert_create_time

The time the certificate was created at.

Cert_update_time

The time the certificate was changed if any changes are made.

Cert_remark

Remarks or comments on the certificate, if any.

Cert_url_image

The certificate image URL.

Cert_learning_processing

Certificate learning proceeding.

Cert_status

The status of the certificate.

 

Chaincode is a software program (a group of smart contracts) or business logic that defines an asset and allows modifications to an asset (aka state changes). Any transaction (as allowed by chaincode) will result in a new set of an asset's key-value pair or the modification of an asset's key-value pair, or the deletion of an asset's key-value pair.

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

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