Hyperledger Composer: How to update a contract after it is saved?

0 votes

I have a saved contract and now I want to update it. I tried:

document.contract.totalSigners = 3;

return getAssetRegistry(NS + '.Document')
  .then(function (documentRegistry) {
    return documentRegistry.update(document);
  });

But it didnt work. My architecture is as follows:

participant Owner extends Business { 
}

asset Contract identified by contractId {
  o String contractId
  --> Owner owner
}

asset Document identified by documentId {
  o String documentId
  o DocumentStatus status
  --> Contract contract
}
Nov 9, 2018 in Blockchain by slayer
• 29,040 points
23 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

Try this and see if this works:

/**
* Track the trade of a commodity from one trader to another 
* @param {org.acme.trading.Trade} trade - the trade to be processed
* @transaction
*/
async function tradeCommodity(trade) { // eslint-disable-line no-unused-vars

// set the new owner of the commodity
trade.commodity.owner = trade.newOwner;
const assetRegistry = await getAssetRegistry('org.acme.trading.Commodity');

// persist the state of the commodity
await assetRegistry.update(trade.commodity);
}
answered Nov 9, 2018 by Omkar
• 67,000 points

Related Questions In Blockchain

0 votes
1 answer

In a Blockchain, how difficult is it to modify the third to last block?

Technically, it's not difficult at all, all ...READ MORE

answered Apr 20, 2018 in Blockchain by Christine
• 15,790 points
45 views
0 votes
1 answer

How to read a state after writing it into a chaincode?

Data that is 'written' in chaincode is ...READ MORE

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

How is a request sent from an app to a smart contract?

Yes, the contract is distributed by every node ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 16,450 points
33 views
0 votes
1 answer
+1 vote
1 answer

I am unable to change port of composer-rest-server. Please help!

Use full format for running a business ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,790 points
231 views
+1 vote
1 answer
0 votes
1 answer
0 votes
2 answers

© 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.