code: func (h *Handler) HandleRegister(msg *pb.ChaincodeMessage) {
  	chaincodeLogger.Debugf("Received %s in state %s", msg.Type, h.state)
  	chaincodeID := &pb.ChaincodeID{}
  	err := proto.Unmarshal(msg.Payload, chaincodeID)
  	if err != nil {
  		chaincodeLogger.Errorf("Error in received %s, could NOT unmarshal registration info: %s", pb.ChaincodeMessage_REGISTER, err)
  		return
  	}
  
  	// Now register with the chaincodeSupport
  	h.chaincodeID = chaincodeID
  	err = h.Registry.Register(h)
  	if err != nil {
  		h.notifyRegistry(err)
  		return
  	}
  
  	// get the component parts so we can use the root chaincode
  	// name in keys
  	h.ccInstance = ParseName(h.chaincodeID.Name)
  
  	chaincodeLogger.Debugf("Got %s for chaincodeID = %s, sending back %s", pb.ChaincodeMessage_REGISTER, chaincodeID, pb.ChaincodeMessage_REGISTERED)
  	if err := h.serialSend(&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTERED}); err != nil {
  		chaincodeLogger.Errorf("error sending %s: %s", pb.ChaincodeMessage_REGISTERED, err)
  		h.notifyRegistry(err)
  		return
  	}
  
  	h.state = Established
  
  	chaincodeLogger.Debugf("Changed state to established for %+v", h.chaincodeID)
  
  	// for dev mode this will also move to ready automatically
  	h.notifyRegistry(nil)
  }
docs: // handleRegister is invoked when chaincode tries to register.