How to get TimeStamps in Hyperledger Composer

0 votes

How to get timestamo in a deterministic way in transaction function. I want something similar to stub.GetTxTimestamp() that can be used in Go version of Fabric's chaincode. Any idea?

Oct 26, 2018 in Blockchain by digger
• 26,740 points
1,351 views

1 answer to this question.

0 votes

Here's an example that works with basic-sample-network network:

asset SampleAsset identified by assetId {
  o String assetId
  --> SampleParticipant owner
  o String value
  o DateTime timestamp
}
function onSampleTransaction(sampleTransaction) {
  sampleTransaction.asset.value = sampleTransaction.newValue;
  sampleTransaction.asset.timestamp = sampleTransaction.timestamp;
  return getAssetRegistry('org.acme.sample.SampleAsset')
       .then(function (assetRegistry) {
               return assetRegistry.update(sampleTransaction.asset);
        });
}
answered Oct 26, 2018 by Omkar
• 69,220 points

Related Questions In Blockchain

0 votes
1 answer

How to get the already existing channels in Hyperledger v1.0?

You cannot see all available channels,  but you ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,100 points
2,528 views
0 votes
1 answer

How to solve EACCES:permission denied error in Hyperledger Composer?

It seems like there is no required ...READ MORE

answered Jul 11, 2018 in Blockchain by digger
• 26,740 points
2,472 views
0 votes
1 answer

Can i use HTTP GET to call external service in Hyperledger Composer?

Right now, the Hyperledger Composer supports only ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,370 points
586 views
0 votes
1 answer

How to solve "error trying install composer runtime" in Hyperledger composer?

I think the docker-compose tool is not ...READ MORE

answered Jul 17, 2018 in Blockchain by slayer
• 29,370 points
909 views
0 votes
1 answer

Network issue while testing Chaincode.

You can do the following things: You can ...READ MORE

answered Jul 3, 2018 in Blockchain by Omkar
• 69,220 points
616 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
868 views
0 votes
1 answer

Hyperledger composer: How to allow create in transaction? Access Control

This is how you can do it: /** @returns ...READ MORE

answered Nov 8, 2018 in Blockchain by Omkar
• 69,220 points
968 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