1

Is it possible to return a value in a transaction method in Hyperledger? such as

/**
 * @param {org.n.blockchaindemo.GetCreditScoreUser} GetCreditScoreUser - 
the GetCreditScoreUser transaction
 * @transaction
 */
async function getCreditScoreUser(user) {
  return 0;
}

If this is not possible, would this mean that the return value would have to be put as a property in a participant or asset?

AshT
  • 535
  • 1
  • 8
  • 20

1 Answers1

2

No, you cannot 'return' out of a transaction - you would have to set something else up to 'emit' something of value.

To return something from your transaction to a client, you would either use Events (see example here, eg. emitting a commodity relationship id) or use a call-out (see here for code examples.

Note also we have an Improvement proposal to address returning data to the client app which you can track for progress info etc-> https://github.com/hyperledger/composer/issues/4165

Paul O'Mahony
  • 6,740
  • 1
  • 10
  • 15