How to return data on execution of invoke function

0 votes
I have a chaincode in which i have a invoke function. Now i want to return certain data like Transaction id, time stamp etc. How can i implement this?
Jul 23, 2018 in Blockchain by slayer
• 29,350 points
435 views

1 answer to this question.

0 votes

You can do this using a response object. You can create a response object, store whatever information you need

(Transaction id, time stamp), marshal it into json and then you can return it.

Ex:

type ChaincodeResponse struct {

      txID string

      time *timestamp.Timestamp

  }

// whatever code you have goes here

resp, err := json.Marshal(ChaincodeResponse{

      txID: stub.GetTxID(),

      time: stub.GetTxTimestamp(),

})

//the below code is used to return

return shim.Success(resp)

answered Jul 23, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer

How to check the data integrity logic in proof of work mining?

The proof of work is actually works ...READ MORE

answered May 8, 2018 in Blockchain by Johnathon
• 9,090 points
597 views
0 votes
1 answer

Solidity: How can I return a list of user-defined function?

You can do it with something like ...READ MORE

answered Sep 26, 2018 in Blockchain by digger
• 26,740 points
1,127 views
0 votes
1 answer

How to run smart contract function using nethereum to return a result?

Try this: var result = getUserAtIndex.CallAsync<byte[]>(123) ...READ MORE

answered Oct 24, 2018 in Blockchain by Omkar
• 69,210 points
1,876 views
0 votes
1 answer

Hyperledger Fabric: How to access transaction ID in invoke function?

You can access transaction ID in Invoke ...READ MORE

answered Nov 5, 2018 in Blockchain by Omkar
• 69,210 points
2,155 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,215 views
0 votes
1 answer

How to get return value of external function?

You can do this. I have shared ...READ MORE

answered Aug 13, 2018 in Blockchain by digger
• 26,740 points
1,632 views
0 votes
1 answer

How to limit execution of smart contract only to my dapp?

You can use modifiers to do it ...READ MORE

answered Jul 17, 2018 in Blockchain by digger
• 26,740 points
486 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