diff --git a/chaincode/fabcar/go/fabcar.go b/chaincode/fabcar/go/fabcar.go index 01792bf476..4cab706322 100644 --- a/chaincode/fabcar/go/fabcar.go +++ b/chaincode/fabcar/go/fabcar.go @@ -106,13 +106,11 @@ func (s *SmartContract) initLedger(APIstub shim.ChaincodeStubInterface) sc.Respo Car{Make: "Holden", Model: "Barina", Colour: "brown", Owner: "Shotaro"}, } - i := 0 - for i < len(cars) { + for i, car := range cars { fmt.Println("i is ", i) - carAsBytes, _ := json.Marshal(cars[i]) + carAsBytes, _ := json.Marshal(car) APIstub.PutState("CAR"+strconv.Itoa(i), carAsBytes) - fmt.Println("Added", cars[i]) - i = i + 1 + fmt.Println("Added", car) } return shim.Success(nil)