Defining chaincode assets
We are now going to define the structure of our assets, which will be recorded onto the ledger. In Go, the assets are defined as struct types with a list of attribute names and types. The definitions also need to contain JSON attribute names, which will be used to serialize the assets into the JSON objects. In the following snippet, you will see definitions for four assets in our application. Note that, the attributes of structs can encapsulate other structs and thus allow to create multi-level trees.
type TradeAgreement struct { Amount int `json:"amount"` DescriptionOfGoods string `json:"descriptionOfGoods"` Status string `json:"status"` Payment int `json:"payment"` } type LetterOfCredit struct { Id string `json:"id"` ExpirationDate string `json:"expirationDate"` Beneficiary string `json:"beneficiary"` Amount int `json:"amount"` Documents []string `json:"documents"` Status string `json:"status"` } type ExportLicense struct { Id string `json:"id"` ExpirationDate string `json:"expirationDate"` Exporter string `json:"exporter"` Carrier string `json:"carrier"` DescriptionOfGoods string `json:"descriptionOfGoods"` Approver string `json:"approver"` Status string `json:"status"` } type BillOfLading struct { Id string `json:"id"` ExpirationDate string `json:"expirationDate"` Exporter string `json:"exporter"` Carrier string `json:"carrier"` DescriptionOfGoods string `json:"descriptionOfGoods"` Amount int `json:"amount"` Beneficiary string `json:"beneficiary"` SourcePort string `json:"sourcePort"` DestinationPort string `json:"destinationPort"` }