I tried two different tutorials:
This one to deploy docker images locally:
https://github.com/hyperledger/fabric-samples
I tried the fabcar sample. Everything works fine. I'm able to enroll the admin, register a user and invoke transactions using this user identity. Nice.
The second one to deploy a fabric composer playground on bluemix:
https://ibm-blockchain.github.io/setup/
I was able to get into the composer playground and deploy business network examples. I'm also able to upload and deploy my own business networks I designed locally with composer-cli. I exposed the network over a Rest Server with admin rights in order to test the transactions. All works fine.
Now it comes to my problem. I want to combine both examples (just for fun, learning by doing:)). I want to deploy the fabcar samples network to the kubernetes environment on bluemix and interact with the network using the fabric node sdk like in example 1. So I made following changes in the scripts/yaml files of example 2:
adapt the chaincode installation procedure
in the create_all.sh. line 41 (for peer 1) and line 45 (for peer 2). I changed the values of the env variables CHAINCODE_NAME and CHAINCODE_VERSION
echo "=> CREATE_ALL: Running Install Chaincode on Org1 Peer1" CHAINCODE_NAME="fabcar" CHAINCODE_VERSION="1.0" MSP_CONFIGPATH="/shared/crypto-config/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" PEER_MSPID="Org1MSP" PEER_ADDRESS="blockchain-org1peer1:30110" create/chaincode_install.sh
in the chaincode_install.yaml.base line 16, I changed the path of the chaincode. I forked the https://github.com/hyperledger/fabric and added the fabcar.go chaincode from example 1 to the new repository https://github.com/bigbelette/fabric
command: ["sh", "-c", "git clone https://github.com/bigbelette/fabric $GOPATH/src/github.com/bigbelette/fabric/ && peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p github.com/bigbelette/fabric/examples/chaincode/go/fabcar/"]
adapt the chaincode instantiation procedure:
in the create_all.sh. line 49. I changed the values of the env variables CHAINCODE_NAME and CHAINCODE_VERSION:
CHANNEL_NAME="channel1" CHAINCODE_NAME="fabcar" CHAINCODE_VERSION="1.0" MSP_CONFIGPATH="/shared/crypto-config/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp" PEER_MSPID="Org1MSP" PEER_ADDRESS="blockchain-org1peer1:30110" create/chaincode_instantiate.sh
In the chaincode_instantiate.yaml.base, I made the parameter list empty:
command: ["sh", "-c", "peer chaincode instantiate -o blockchain-orderer:31010 -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -c '{\"Args\":[\"\"]}'"]
The deployment on the cluster works without an error. In the fabcar examples node js file enrollAdmin, regiserUser, query and invoke, I changed the channel name (from mychannel to channel1) and the IPs and ports to match to the online kubernetes services:
enrollAdmin.js and registerUser.js work fine so I can get the certificates and store it in the key store. But when I try to invoke a transaction, i get the following error:
It seems the CA which gave me the certificates is not recognized by the peers. But there is only one CA in my network!? Or is it a problem in the MSP definition (something I still dont understand well).
Thanks for your help.
I finally found the error.
My network has 1 CA (the root CA, named ca) and 2 "sub" CAs (ca1 und ca2). I was enrolling admin and user directly by the root CA because I didnt mention the name of the ca in the parameters of the Fabric_CA_Client class:
fabric_ca_client = new Fabric_CA_Client('http://184.173.5.108:30054', tlsOption, crypto_suite)
Without the name, the used CA will be the default CA (Root CA in my case). But the signature of user certificates by the root CA wont be recognized by the peers. Only the signatures from the last hierarchical CA levels will be accepted. So the solution was to refer the name of the CA:
fabric_ca_client = new Fabric_CA_Client('http://184.173.5.108:30054', tlsOptions , 'CA1', crypto_suite)
It works. Now the user can invoke transactions.
Related
I'm trying to deploy the chaincode to a fabric peer using "peer lifecycle install".
It works perfectly. System can build and create the chaincode container as expected.
The images are automatically created after installing chaincode with prefix "dev-peer0.xxx"
I'd like to set the custom name like : pro-peer0.xxx.. instead of default (dev-peer0).
Can you help to advise?
Thank you.
enter image description here
It's a configurable option of a peer to change the network id see https://github.com/hyperledger/fabric/blob/8576508403cd6e3cbb5f7a2ff05dfae123de227b/sampleconfig/core.yaml#L19, you can change the core.yaml file in the peer.
If you are using docker-compose then you can change it using an env var of
CORE_PEER_NETWORKID
I have passed following commands :
mkdir workspace
cd workspace
git clone https://github.com/hyperledger/fabric-samples.git
cd fabric-samples
./scripts/bootstrap.sh 1.4.1 1.4.1 0.4.14
cd reliance-network
What command to be next for project name reln & channel name relianceorgs ?
you need to modify configtx.yaml and crypto-config.yaml for channel name as well as organisation name, configtx.yaml will be used to generate genesis block and channel.tx file, while crypto-config.yaml file will be used to generate crypto material such as tls files and msp (i.e membership service provider) for organization. you can use first-network or basic network in fabric sample as an example. it would be better if you go through Read the docs https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html you will find all the commands and instructions that you need to follow.
I am working with this blockchain application for medics traceability (https://github.com/rastringer/medication-blockchain) based on hyperledger fabric blockchain.
It's exactly the same app as this project (https://github.com/hyperledger/education/tree/master/LFS171x/fabric-material/tuna-app) except that this project is for tuna traceability.
I modify the chaincode file (the file is "drug-chaincode.go"), and now apparently I need to reconfigure all my network in "basic-network" folder so that the modification is add, but I don't how I can do this.
I tried to follow this link without results (How to upgrade a chaincode after modification?)
Anyhelp is welcome, thank you in advance ;)
if u r trying to build hyperledger project similar to drug-app. Then do following things:
Delete node_modules:
drug-blockchain/drug-app/node_modules
Then change every parameter which states the drug blockchain, basically u have to change parameters to Yours on following sources:
drug-chaincode.go
startFabric.sh
server.js
routes.js
registerUser.js
registerAdmin.js
package.json
controller.js
recordDrug.js
queryDrug.js
queryAllDrug.js
changeDrugHolder.js
app.ja
index.html
In the end re-run the network:
cd drug-blockchain/drug-app
$./startFabric.sh
$npm install -g
$node registerAdmin.js
$node registerUser.js
$node server.js
if u do change parameters properly, it should work fine, otherwise recheck, there shouldn't be any data of previous drug-blockchain!
I am trying to enable JWT for hyperledger composer to my blockchain project.
However whilst following the tutorial I came accross the below error. I am not sure what it means:
Error: Can't find end of central directory : is this a zip file ? If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html
when running ./createPeerAdminCard.sh below is the exact output:
Development only script for Hyperledger Fabric control
Running 'createPeerAdminCard.sh'
FABRIC_VERSION is set to 'hlfv11'
FABRIC_START_TIMEOUT is unset, assuming 15 (seconds)
Using composer-cli at v0.19.5
Successfully created business network card file to
Output file: /tmp/PeerAdmin#hlfv1.card
Command succeeded
Successfully imported business network card
Card file: /tmp/PeerAdmin#hlfv1.card
Card name: PeerAdmin#hlfv1
Command succeeded
Error: Can't find end of central directory : is this a zip file ? If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html
Command failed
Hyperledger Composer PeerAdmin card has been imported, host of fabric specified as 'localhost'
Are you running on a Mac ?
This problem has been seen when there is a hidden file present somewhere in the ~/.comoposer folder.
If you have cards you need to keep then try a composer card export to try and export them, then delete the folder ~/.composer and re-run the script to create the Peer Admin card.
There are a few details of the problem in this issue on github.
I'm trying to run the Hyperledger Fabric network, which consists of a single orderer, a single peer, and a cli. To learn the procedure of launching Hyperledger Fabric network, from creating crypto-related artifacts to running cli as a docker container, I execute them one by one.
Everything is okay, but when I try to instantiate the installed chaincode, the peer produces channel [reputationch]: MSP error: channel doesn't exist (reputationch is my channel name) and the instantiation has been failed.
(Check the below screenshot)
I'm not sure that this warning on the peer node causes the failure of the instantiation of chaincode, but I guess it is the reason.
My crypto-config.yaml and configtx.yaml are like below. They are nothing special because I just modified some names based on the official example.
crytp-config.yaml and configtx.yaml
And the script to create crypto-related artifacts based on the above yaml files is:
script to create crypto-related artifacts
My running scripts to launch an orderer, a peer, and a cli are like below. It calls docker commands.
running scripts to launch an orderer, a peer, and a cli
After I launch a cli, I connect the cli using docker exec -it cli bash. Then, I run three commands, which work well without an error or a warning:
peer channel create -o orderer.operator.com:7050 -c reputationch -f ./channel-artifacts/reputation-channel.tx
peer channel update -o orderer.operator.com:7050 -c reputationch -f ./channel-artifacts/Company1anchors.tx
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/
Then, the following command is failed.
peer chaincode instantiate -o orderer.operator.com:7050 -C reputationch -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Company1MSP.peer')"
My version information is:
macOS: macOS High Sierra 10.13.3
Go: 1.10
Docker: Version 18.03.0-ce-mac59 (23608)
Hyperledger Fabric: 1.1
cryptogen: 1.1.0
configtxgen: 1.1.0
Any kind of comment or help will be very great for me. Thanks.
Basically you also need your peers to join your channels. Which it seems like you are not doing here. If your peers do not join any channel, you will be getting this error. Make sure that your peers join channel before installing chaincode.
peer channel join -b $CHANNEL_NAME.block