How to get block info by txid in hyperledger composer? - hyperledger-fabric

In hyperledger composer, I can get transactionId, but I also need block info.

Currently it is not possible to get that information from Composer, but there is an Improvement Proposal issue active in GitHub to provide this functionality in the future.
If you need to provide this information visually there is the Blockchain Explorer I think this has a REST API so you could make calls to it for block information.

Related

How to make a user authentication using hyperledger fabric

i have a current channel of hyperledger fabric with chaincode that does CRUD operations my question is that is there any way to make a method in a chaincode that registers the new user when certain condition match.
You can use one of several methods to get the identity of the user:
GetCreator
GetId
GetMSPId
They are part of the Client Identity Chaincode Library, documented here: https://pkg.go.dev/github.com/hyperledger/fabric-chaincode-go/pkg/cid#section-readme
The Hyperledger Fabric docs provide some help for access control also if you're interested in that: https://hyperledger-fabric.readthedocs.io/en/latest/private-data/private-data.html?highlight=getmspid#private-data-sharing-patterns

Hyperledger Fabric: signing channel update

I am using Hyperledger Fabric v2.2 with multiple organizations setup. I want to join a new organization to an existing channel. The problem is in signing channel update.
Fabric docs says that there are two main implementations of signing:
“pass it along” - admin of Org1 signs channel update and sends in to Org2 admin, Org2 admin signs and sends to Org3 and so on, until enough signatures will be collected.
"The other option is to submit the update to every Admin on a channel and wait for enough signatures to come back. These signatures can then be stitched together and submitted. This makes life a bit more difficult for the Admin who created the config update (forcing them to deal with a file per signer) but is the recommended workflow for users which are developing Fabric management applications."
All samples that I found describes only the first implementation. But how to do it with the second? I found the related code in HLF Node.js SDK v1.4 but can't find the same for v2.2.
I had the same doubt, until I saw this here.
The Fabric v2.x SDKs only support transaction and query functions and event listening. Support for administrative functions for channels and nodes has been removed from the SDKs in favor of the CLI tools.
No more admin function starting from v2.x tho. Not sure if I answered your question.

User transaction history hyperledger fabric

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?
There are several different ways to go about this.
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)
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.
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.

Hyperledger Explorer: how to prevent participants from accessing transaction history

In my Hyperledger-Fabric application (developed with Hyperledger Composer), I want to prevent participants from being able to look at the old transactions.
Old transactions can be viewed either in the Hyperledger Composer Historian or in the Hyperledger Explorer.
I know how to make old transactions non-visible to participants in the case of Hyperledger Composer Historian (namely in the file permissions.acl). But preventing participants from looking at old transactions in the Hyperledger Composer Historian is not of any use, as long as they can instead view the transaction history in the Hyperledger Explorer.
So my question is this: how can I make the transaction history non-visible to participants in the case of the Hyperledger Explorer?
UPDATE:
Is it possible at all for an organisation to use Hyperledger Explorer without the knowledge of other members of the network?
If it is not possible for one member to use Hyperledger Explorer on the network without the other members allowing it, then the problem is gone anyway.
You can't make participants not being able to access data they have already seen, thus you can't make transaction history disappear from the channel members local peers.
I know how to make old transactions non-visible to participants in the
case of Hyperledger Composer Historian (namely in the file
permissions.acl).
Even if you define access control for clients in the application layer:
All peers in the channel can still see the transactions
Every client that has permission to pull blocks from peers or orderers, can still see the transactions via pulling them itself.
But preventing participants from looking at old transactions in the
Hyperledger Composer Historian is not of any use, as long as they can
instead view the transaction history in the Hyperledger Explorer.
Such a fact should instill doubt in the mind of anyone, and make him/her wonder whether the hiding is of any use, to someone that has access to the blockchain itself.

Get transaction's block number in Hyperledger Composer

The GET Endpoints for transactions only return the transactionId but I would like to get the block number too.
Is it possible to get a transaction's block number using the Hyperledger Composer REST API?. Any other workarounds involving other tools are appreciated.
This is not possible via the Composer REST API.
However it should be possible using the Composer Javascript API - using the getNativeAPI() method from the BusinessNetworkConnection class. This calls through to the Fabric SDK and queryTransaction() method of the channel class provides block information. Alternatively queryInfo() method will provide the block height.
The Composer API doc can be found here:
https://hyperledger.github.io/composer/latest/api/api-doc-index
and the Fabric SDK here:
https://fabric-sdk-node.github.io/Channel.html
Note that the getNativeAPI() function available in the Composer Transaction Processor only exposes the chaincodeStub class in the Fabric SDK and so can't find Block information, which is why this is not possible in the REST API.
The Blockchain Explorer, has a REST API which exposes block information, however it is another component to configure and manage.

Resources