Need for Service discovery in Hyperledger Fabric

The SDK needs a lot of information in order to allow applications to connect to the relevant network nodes.

  1. The CA and TLS certificates of the orderers and peers on the channel.
  2. IP addresses and port numbers of the orderers and peers.
  3. Relevant endorsement policies as well as which peers have the chaincode installed (so the application knows which peers to send chaincode proposals to)

How service discovery works in Fabric?

The application is bootstrapped knowing about a group of peers which are trusted by the application developer/administrator to provide authentic responses to discovery queries.

Note that in order for peers to be known to the discovery service, they must have an EXTERNAL_ENDPOINT defined.

To define these endpoints, you need to specify them in the core.yaml of the peer.


It also fetches information, such as any relevant endorsement policies, from the peer’s state database.

With service discovery, applications no longer need to specify which peers they need endorsements from. The SDK can simply send a query to the discovery service asking which peers are needed given a channel and a chaincode ID.

Capabilities of the discovery service

The discovery service can respond to the following queries:

  • Configuration query: Returns the MSPConfig of all organizations in the channel along with the orderer endpoints of the channel.
  • Peer membership query: Returns the peers that have joined the channel.
  • Endorsement query: Returns an endorsement descriptor for given chaincode(s) in a channel.
  • Local peer membership query: Returns the local membership information of the peer that responds to the query. By default the client needs to be an administrator for the peer to respond to this query.

Suffering from Knowledge Quest

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store