Skip to content

Instantly share code, notes, and snippets.

@nosequeldeebee
Created July 5, 2018 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nosequeldeebee/4623fd79479790cd0a899b22a534652f to your computer and use it in GitHub Desktop.
Save nosequeldeebee/4623fd79479790cd0a899b22a534652f to your computer and use it in GitHub Desktop.
func (s *SmartContract) changeCarOwner(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {
if len(args) != 2 {
return shim.Error("Incorrect number of arguments. Expecting 2")
}
carAsBytes, _ := APIstub.GetState(args[0])
car := Car{}
json.Unmarshal(carAsBytes, &car)
car.Owner = args[1]
carAsBytes, _ = json.Marshal(car)
APIstub.PutState(args[0], carAsBytes)
return shim.Success(nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment