While using Hyperledger Fabric, a user wants to define an asset named "vehicle" in chain code.Which of the following code formats can he use?Type Vehicle struct {<br /> Make string ‘json:”make”’ <br /> Category string ‘json:”category”’<br /> Model string ‘json:”model”’<br /> Color string ‘json:”color”’<br /> }Type Vehicle struct {<br /> Make string: “make” <br /> Category string: “category”<br /> Model string: “model”<br /> Color string: “color”<br /> }Type Vehicle struct {<br /> String Make :”make” <br /> String Category :”category”<br /> String Model :”model”<br /> String Color: ”color”<br /> }Type Vehicle struct {<br /> String Make ‘xml:”make”’ <br /> String Category ‘xml:”category”’<br /> String Model ‘xml:”model”’<br /> String Color ‘xml:”color”’<br /> }
Question
While using Hyperledger Fabric, a user wants to define an asset named "vehicle" in chain code.Which of the following code formats can he use?Type Vehicle struct {<br /> Make string ‘json:”make”’ <br /> Category string ‘json:”category”’<br /> Model string ‘json:”model”’<br /> Color string ‘json:”color”’<br /> }Type Vehicle struct {<br /> Make string: “make” <br /> Category string: “category”<br /> Model string: “model”<br /> Color string: “color”<br /> }Type Vehicle struct {<br /> String Make :”make” <br /> String Category :”category”<br /> String Model :”model”<br /> String Color: ”color”<br /> }Type Vehicle struct {<br /> String Make ‘xml:”make”’ <br /> String Category ‘xml:”category”’<br /> String Model ‘xml:”model”’<br /> String Color ‘xml:”color”’<br /> }
Solution
The correct format to define an asset named "vehicle" in chain code using Hyperledger Fabric would be:
Type Vehicle struct {
Make string `json:"make"`
Category string `json:"category"`
Model string `json:"model"`
Color string `json:"color"`
}
This is because in Go (the language used in Hyperledger Fabric), we define a struct with the type keyword followed by the name of the struct (in this case, Vehicle). Then, in curly braces {}, we define the fields of the struct. Each field has a name and a type. The json:"name" part is called a struct tag and it's used to associate the struct field with the JSON field.
Similar Questions
While using Hyperledger, a user can represent the assets in which of the following formats?[i] XML[ii] JSON[iii] BinaryOnly i and iiOnly i and iiiOnly ii and iiiAll i, ii, and iii
Architecture of Hyperledger Fabric
In Hyperledger Fabric, the SDKs are written in which of the following programming languages?(This question has multiple correct answers; choose all that apply)Node.jsRESTPerlC++
Examine the components and workflow of Hyperledger fabric
A user set up the network and created the channel for an Hyperledger application named "Sales_Fabric". Then he writes the required chaincode. After writing the chaincode, he needs to deploy it.Which of the following commands can he use for it?Consider that the chaincode name is sac, he is using GoLang, and the init function is InitSales../network.sh deployCC -ccname sac -ccp ../chaincode -ccl go -cci InitSales./network.sh deployCC -ccname sac -ccp --chaincode -language go -cci InitSales./network.sh deploy CC sac -ccl go -ccp ../chaincode -cci InitSales./network.sh deployCC -ccn sac -ccl go -ccp ../chaincode -cci InitSales
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.