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,550 points
286 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
• 67,660 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,020 points
302 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,550 points
435 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,170 points
55 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,170 points
96 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
• 67,660 points
41 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
106 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
• 67,660 points
211 views