March 2019
Intermediate to advanced
636 pages
27h 50m
English
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"` ...Read now
Unlock full access