In order to understand how Endorsements work, lets talk about how trades work in stock market. The seller of the stock wants to sell the stock to a buyer, the clearing house is the intermediary that ensures that the seller is the real owner of the stocks that s/he is trying to sell.

This is how a trustworthy and a safe stock marketplaces is created. The third party entities are referred to as the Trust Authorities. The trust authorities job is to evaluate the transaction and then accept or reject it. This process of acceptance or rejection is the Endorsement process.

The scenario depicted in the illustration below, the trust authority is the clearing house that is managing a database of ownership of stocks. When a request for sale comes, the trust authority (i.e., clearing house) checks against the database if the seller is the owner. In fact the Trust Authority can apply multiple rules before endorsing the transfer ownership transaction e.g., is the buyer a foreign national from restricted country. So as you can see the Trust Authority may apply multiple rules and check against common centralized knowledge to approve or reject the trade i.e., endorse with “accept” or endorse with “reject”

Now lets assume for a moment that the market place is to be implemented on Hyperledger Fabric. In that scenario all of the Endorsement Peers for the “Stock transfer ownership” will be hosted by the member organization that is the Trust Authority. The scenario is depicted below:

The Seller and Buyer may be institutions e.g., pension funds management. The three members involved in the transaction will host the Fabric Peers and for “Stock transfer ownership” transaction the members will use the Trust Authority Peer (Clearing House) for endorsement of transaction. Since the endorsement services will be provided by the clearing house, it will host the Endorsing Peers. Other members that will participate in the transaction will also host the (non endorsing) peers. In this setup all members will need to install the smart contract (or chaincode) on their Peers so as to query the

“Stock transfer ownership” transactions but not for invoking the transaction.

Can there be only one Trust Authority?

Short answer is NO. The endorsement process may involve multiple trust authorities. It all depends on the transactions. E.g., if the transaction involves a foreign entity then another trust authority may be engaged in addition to the clearing house. In the illustration below, we have a Transaction#1 that needs one trust authority to endorse whereas Transaction#2 requires two trust authorities to endorse.

How does the Smart contract know about Endorsers?

Short answer is that chaincode does NOT have any in-built knowledge of the network members that will be used for endorsement, that is the code in smart contract is independent of the endorsement information. This is done because endorser organizations may be changed over a course of time and if that happens then the code for the transaction will need to change!!

Fabric has a very elegant design for associating the chaincode with information about the Endorsing process. It is done by way of Endorsement Policy.

Endorsement Policies

Endorsement Policies are expressions that are associated with the smart contract at the time of deployment/instantiation of the chaincode. The expression has two parts:

It identifies the network members who will act as endorser for the transaction Rules for marking the transaction as valid or not

I am sure you are clear about number one. So lets talk about number two – some transactions may require multiple members to be involved in the endorsement process. Consider a scenario in which the Stock sale can happen only after the approval by Clearing House and one of the two Government agencies lets say IRS and Foreign Affairs. This is a complex scenario but can easily be declared as an expression.

EP Expressions

Policy expressions are created with Logical operators. Complex expressions may be created by mixing these operators.

AND – requires a list of member orgs ALL of which must endorse

OR – requires a list of member orgs, ANY of which may endorse

OUTOF – uses a number to determine how many members must endorse

These expressions are associated with the chaincode at the time of instantiation. The expressions may be upgraded with chaincode upgrade.

How are the policies used?

Endorsement policies are used at every stage of the transaction. Client gets the information Endorsing Peers and sends the proposal to the endorsers. Endorsing peers checks the policies to see if they are the endorsers. Peers on receiving the transaction in a block validates if the transaction has been endorsed as per the rules in the policy.



What happens if a Endorsement Policy is NOT set for a chaincode?

All chaincodes when instantiated without a Endorsement Policy are assigned a default policy. This default policy states that any member of the organization initiating the transaction can be the endorser.

The following scenario depicts the use of a default policy. When the transaction with default endorsement policy is initiated within the Acme Organization, any peer in the Acme organization can act as the endorser.