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,370 points
812 views

1 answer to this question.

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
• 69,220 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
1,027 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
• 17,100 points
2,043 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
• 17,100 points
713 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
+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
1,127 views
+1 vote
1 answer
0 votes
1 answer
0 votes
2 answers

Why is network already up to date while trying to deploy a contract on truffle?

I guess you have ganache running already ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,400 points
4,566 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP