In the chain code for Hyperledger Fabric, is it possible to check if an identity exists with a given name? that is, something like this:
func (c *SmartContract) UserExists(ctx contractapi.TransactionContextInterface, username string) bool {
// if an identity exists with the username, then return true, otherwise return false.
}
You can do it with the
IdentityServiceprovidedcontractapi.TransactionContextInterface. However, in fact identities in Hyperledger Fabric are typically managed by the MSP and not directly accessible within the chaincode. If you use identity-based access control within your Fabric network, then you can try the following approach.