Skip to content

Instantly share code, notes, and snippets.

@vitiko
Created May 20, 2018 15:04
Show Gist options
  • Save vitiko/e8bed460f7784445c8ade4001e83faf7 to your computer and use it in GitHub Desktop.
Save vitiko/e8bed460f7784445c8ade4001e83faf7 to your computer and use it in GitHub Desktop.
Chaincode "constructor"
func New() *Chaincode {
r := router.New(`cars`) // also initialized logger with "cars" prefix
r.Group(`car`).
Query(`List`, cars). // chain code method name is carList
Query(`Get`, car, p.String(`id`)). // chain code method name is carGet, method has 1 string argument "id"
Invoke(`Register`, carRegister, p.Struct(`car`, &CarPayload{}), // 1 struct argument
owner.Only) // allow access to method only for chaincode owner (authority)
return &Chaincode{r}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment