1

I am building a hyperledger fabric blockchain application where several users interact. It seems to be working. Using hyperledger explorer I can also view the blocks and transactions in the blockchain.

However, it is not clear to me how to see get the transaction history for 1 user (based on his / her identity key)?

Basically, like for a customer of a bank, I would like to get only the transactions relevant to a particular user to provide him/her with a transaction overview.

Is there a tool for this? Is it integrated into Fabric?

Ferran Buireu
  • 28,630
  • 6
  • 39
  • 67
Mike
  • 3,775
  • 8
  • 39
  • 79

1 Answers1

0

There are several different ways to go about this.

  1. On-chain: You'd write a chaincode function to return the corresponding transactions. To do this you need to keep track of each user's submitted transactions by storing the transaction UUIDs in the chaincode state (stub.PutState). With stub.getState you can later retrieve the state and return the transaction list. (inspired by this StackOverflow answer)

  2. Peer SDK: As far as chaincode-independent transaction history goes I'm not aware of any API calls that support this. You can only get a transaction by its UUID.

  3. Off-chain: Since you're already using Hyperledger Explorer, you should have a Postgres database containing indexed transaction data. You can query the transactions table from your application by filtering for the creator_id_bytes. Since Hyperledger Explorer needs to fetch new transactions from the peer first, there is some additional latency with this approach compared to 1/2.

Sigmatics
  • 615
  • 4
  • 17