March 2019
Intermediate to advanced
636 pages
27h 50m
English
Last but not least, we will add the main function: the initial point of a Go program. When an instance of the chaincode is deployed on a peer, the main function is executed to start the chaincode.
In line 2 of the following snippet, the chaincode is instantiated. The function shim.Start starts the chaincode in line 4 and registers it with the peer, as follows:
func main() {
twc := new(TradeWorkflowChaincode)
twc.testMode = false
err := shim.Start(twc)
if err != nil {
fmt.Printf("Error starting Trade Workflow chaincode: %s", err)
}
}
Read now
Unlock full access