I am following Balance transfer from Hyperledger Fabric samples from this link. I have modified it a bit, now I have 3 Orgs with 1 Peer each. All goes fine till I enroll users to Org1 and Org2 but, when I try to enroll a user to my 3rd Org I get following error
Failed to get registered user: xyz with error: Error: fabric-ca request register failed with errors [[{"code":63,"message":"Failed to get Affiliation: sql: no rows in result set"}]]
My Binaries of Hyperledger Fabric are from version 1.1.0 Alfa
Please pay attention to this line in helper.js,
let secret = await caClient.register({ enrollmentID: username, affiliation: userOrg.toLowerCase() + '.department1' }, adminUserObj);
Are you sure you are lowercasing for Org3 (in config yaml files) ?
The issue is that the fabric-ca being used in the sample does not know about the affiliation. By default, fabric-ca only has the following affiliations:
org1.department1 org1.department2 org2.department1
The code which registers and enrolls users in the sample takes the org name and concatenates it with "department1" :
So when you pass in Org3, it tries to register the user with the affiliation org3.department1 which does not exist.
Since you are using 1.1.0-alpha, you are in luck as this version of fabric-ca supports has an API for adding new affiliations. The easiest way is to use the fabric-ca-client to do this:
You can look at the fabric-ca docs ( http://hyperledger-fabric-ca.readthedocs.io/ ) for more details. You'll need to first enroll the admin user which has the password "adminpw" with the fabric-ca-client and then run the above commands.
This may be useless (and very late), but I'd like to add to Gari's answer. You can also add affiliations using the node client SDK's AffiliationService class.
To do this in the balance transfer code, modify
helper.js
with:Note:
The above code only adds the affiliations (which I think is the only thing missing in your case). To successfully enroll a user for Org3, you'll also have specify org3 in
artifacts/channel/cryptogen.yaml
,artifacts/channel/configtx.yaml
,artifacts/docker-compose.yaml
,artifacts/network-config.yaml
andconfig.json
. And create anorg3.yaml
file.I built a chaincode sample app with the balance transfer sample as a base which has 3 orgs. You can take a look at it to see the necessary changes.
I had seen the same problem in fabric 1.3, I have changed the names and configured my own. by removing below statement helped me
just comment the below line in 'helper.js' helped me.
//affiliation: userOrg.toLowerCase() + '.department1'