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,050 points
27 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
• 27,620 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 7, 2018 in Blockchain by Johnathon
• 9,070 points
25 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
• 27,620 points
44 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
• 67,120 points
138 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
• 67,120 points
298 views
0 votes
1 answer
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
• 27,620 points
19 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
• 27,620 points
15 views