How do I validate the presence of participant owner in Asset transfer transaction?

0 votes

In the "basic-sample-network" or "trade-network" or "marbles-demo" sample of Hyperledger Fabric Composer - once the transaction is submitted then it checks for the presence of the asset ID in the database. However, it does not check if the new owner (participant) is actually present. How to check that the new owner is actually present in the database created?

Aug 8, 2018 in Blockchain by Shashank
• 10,330 points
168 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

I found the exact solution and syntax.. This is for the marbles trading demo and it checks for presence of both participant and the asset

/**
  * Trade a marble to a new player
  * @param {org.hyperledger_composer.marbles.TradeMarble} tradeMarble - the trade marble transaction
  * @transaction
  */
 function tradeMarble(tradeMarble) {
   return getParticipantRegistry('org.hyperledger_composer.marbles.Player')
     .then(function(playerRegistry) {
       return playerRegistry.exists(tradeMarble.newOwner.getIdentifier())
     })
      .then(function(exists) {
       if(!exists) {
         throw Error('Invalid participant id')
       } else {
        return getAssetRegistry('org.hyperledger_composer.marbles.Marble')
         .then(function (assetRegistry) {
          tradeMarble.marble.owner = tradeMarble.newOwner;
          return assetRegistry.update(tradeMarble.marble);
      });
       }
     })
 }
answered Aug 8, 2018 by ariaholic
• 7,320 points

Related Questions In Blockchain

+1 vote
1 answer

How do i change the names of validating peers in IBM Bluemix blockchain?

IBM Bluemix Blockchain service Hyperledger Fabric v0.6 will ...READ MORE

answered Apr 10, 2018 in Blockchain by Perry
59 views
0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 16,450 points
171 views
0 votes
1 answer

How do I get the balance of an account in Ethereum?

On the Web: (Not programmatic, but for completeness...) ...READ MORE

answered Nov 14, 2018 in Blockchain by Perry
• 16,450 points
38 views
0 votes
1 answer

Hyperledger Composer rest server NPM versions

The Hyperledger Composer pre-requisites can be installed ...READ MORE

answered Jul 13, 2018 in Blockchain by Christine
• 15,790 points
55 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
61 views
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.