How to find chaincode id in fabric? - hyperledger

How to find chaincode id after running peer chaincode install and peer chaincode instantiate commands.
While running peer chaincode query I need to pass the chaincode id. Otherwise I am getting this error in peer console:
ChaincodeId: test_cc does not exist on channel: testchainid(err:chaincode not found test_cc)

Usage:
peer chaincode install [flags]
Flags:
-h, --help help for install
Global Flags:
--cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
-C, --chainID string The chain on which this command should be executed (default "testchainid")
-c, --ctor string Constructor message for the chaincode in JSON format (default "{}")
-E, --escc string The name of the endorsement system chaincode to be used for this chaincode
-l, --lang string Language the chaincode is written in (default "golang")
--logging-level string Default logging level and overrides, see core.yaml for full syntax
-n, --name string Name of the chaincode
-o, --orderer string Ordering service endpoint
-p, --path string Path to chaincode
-P, --policy string The endorsement policy associated to this chaincode
--test.coverprofile string Done (default "coverage.cov")
-t, --tid string Name of a custom ID generation algorithm (hashing and decoding) e.g. sha256base64
--tls Use TLS when communicating with the orderer endpoint
-u, --username string Username for chaincode operations when security is enabled
-v, --version string Version of the chaincode specified in install/instantiate/upgrade commands
-V, --vscc string The name of the verification system chaincode to be used for this chaincode
the -n or --name option that you use is the chaincode id.

Related

Error: chaincode argument error: invalid character 'â' looking for beginning of value

I'm trying to query my installed chaincode on hyperledger fabric 2.2 network.
I'm trying test-network . I'm using this command
peer chaincode query -C mychannel -n fabcar -c ‘{“Args”:[“queryAllCars”]}’
but I'm getting this error.
Error: chaincode argument error: invalid character 'â' looking for beginning of value
Usage:
peer chaincode query [flags]
Flags:
-C, --channelID string The channel on which this command should be executed
--connectionProfile string Connection profile that provides the necessary connection information for the network. Note: currently only supported for providing peer connection information
-c, --ctor string Constructor message for the chaincode in JSON format (default "{}")
-h, --help help for query
-x, --hex If true, output the query value byte array in hexadecimal. Incompatible with --raw
-n, --name string Name of the chaincode
--peerAddresses stringArray The addresses of the peers to connect to
-r, --raw If true, output the query value as raw bytes, otherwise format as a printable string
--tlsRootCertFiles stringArray If TLS is enabled, the paths to the TLS root cert files of the peers to connect to. The order and number of certs specified should match the --peerAddresses flag
Global Flags:
--cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
--certfile string Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint
--clientauth Use mutual TLS when communicating with the orderer endpoint
--connTimeout duration Timeout for client to connect (default 3s)
--keyfile string Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint
-o, --orderer string Ordering service endpoint
--ordererTLSHostnameOverride string The hostname override to use when validating the TLS connection to the orderer.
--tls Use TLS when communicating with the orderer endpoint
--transient string
Transient map of arguments in JSON encoding
As commented out by #alpha peer chaincode query -C mychannel -n fabcar -c '{"Args":["queryAllCars"]}' will work. the difference is to replace ’ with ' while passing the arguments.
Please replace quotes ‘ with ' and “ with " . The problem here is it can't able to detect the quotes.

Hyperledger Fabric: Orderer Client failed to connect to orderer.example.com

I am new to hyperledger fabric and I am trying to create a sample blockchain network from scratch using hyperledger fabric. In order to do so, I configured "crypto-config.yaml" file, and generated the respective organization's certificates by running it against the "cryptogen" tool. I also generated the respective "channel-artifacts" by configuring the "configtx.yaml" file and running it against the configtxgen tool. I then modified the "docker-compose-cli.yaml" file and "docker-compose-base" file.
Now, in order to bootstrap the network, I ran the following docker command:
docker-compose -f docker-compose-cli.yaml up
I then executed the following commands:
docker exec -it cli bash
export CHANNEL_NAME=testChannel
peer channel create -o orderer.example.com:7050 -c testChannel -f ./channel-artifacts/testChannel.tx
On executing the "peer channel create" command I received the following error:
Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded
I am not sure as to why this error is occurring. My configuration for the Address section in OrdererDefaults (in configtx.yaml file) is:
Ordertype:
- solo
Addresses:
- orderer.example.com:7050
Hence, please let me know if I am missing something in order to clear the "peer channel create" issue.
do a docker ps and see if the orderer is up and running
if not do a docker logs orderer.example.com and check orderers logs
usually the orderer logs give clear clues on what has happened
read the logs and fix the issue . that's what i did
and instead of creating a peer first going inside it and creating a channel ,i suggest you create the channel first and join the peer to it afterwards
Create the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer0.org1.tracexyz.com peer channel create -o orderer.tracexyz.com:7050 -c cheeseproduction -f /etc/hyperledger/configtx/channel.tx
Add peer 0 to the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer0.org1.tracexyz.com peer channel join -b cheeseproduction.block
Fetch from peer 1
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" peer1.org1.tracexyz.com peer channel fetch config -o orderer.tracexyz.com:7050 -c cheeseproduction
Join peer 1 also to the channel
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin#org1.tracexyz.com/msp" -e "CORE_PEER_ADDRESS=peer1.org1.tracexyz.com:7061" peer0.org1.tracexyz.com peer channel join -b cheeseproduction.block
this is how i connected two peers to a single channel. my org name was tracexyz (tracexyz instead of example ) and my channel name was cheeseproduction
I guesss you can replace those with your own values
after doing these go inside the peer with
docker exec -it cli bash
it will take you inside the default peer which is peer0.org1
then do a peer channel list to see the channels to which peer0 has joined
you will see it will list cheeseproduction

Channel creation failed

I am a complete newbie on Hyperledger Fabric and as described in the docs I installed all the prerequisites and set up the Network Artifacts. But after i want to bring Up the Network. I get this error and i don't know what to do:
Error: failed to create deliver client: orderer client failed to connect to orde
rer.example.com:7050: failed to create new connection: x509: certificate signed
by unknown authority (possibly because of "x509: ECDSA verification failure" whi
le trying to verify candidate authority certificate "tlsca.example.com")
Usage:
peer channel create [flags]
Flags:
-c, --channelID string In case of a newChain command, the channel ID to crea
te.
-f, --file string Configuration transaction file generated by a tool su
ch as configtxgen for submitting to orderer
-t, --timeout int Channel creation timeout (default 5)
Global Flags:
--cafile string Path to file containing PEM-encoded
trusted certificate(s) for the ordering endpoint
--certfile string Path to file containing PEM-encoded
X509 public key to use for mutual TLS communication with the orderer endpoint
--clientauth Use mutual TLS when communicating wi
th the orderer endpoint
--keyfile string Path to file containing PEM-encoded
private key to use for mutual TLS communication with the orderer endpoint
--logging-level string Default logging level and overrides,
see core.yaml for full syntax
-o, --orderer string Ordering service endpoint
--ordererTLSHostnameOverride string The hostname override to use when va
lidating the TLS connection to the orderer.
--tls Use TLS when communicating with the
orderer endpoint
-v, --version Display current version of fabric pe
er server
!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========
ERROR !!!! Test failed
OS: Windows 7
Hyperledger Fabric: 1.1
Latest Docker installation
After multiple attempts to get the network running i created containers which i had to delete with the command docker ps -aq. Also i had to get the network down before that with the command ./byfn.sh -m down. Then i restarted everything by using byfn.sh -m generate -c mychannel and byfn.sh -m up -c mychannel -s couchdb Then everything worked as in the docs described.

How can I specify canonical server name in composer connection profile?

We need to run "composer" command outside of docker container's network.
When I specify orderer and peer host name (e.g. peer0.org1.example.com) in /etc/hosts file, "composer" command seems to work.
However, if I specify server's IP address, it does not work. Here is sample.
$ composer network list -p hlfv1 -n info-share-bc -i PeerAdmin -s secret
✖ List business network info-share-bc
Error trying to ping. Error: Error trying to query chaincode. Error: Connect Failed
Command succeeded
This is a command example when I specify host name in /etc/hosts.
$ composer network list -p hlfv1 -n info-share-bc -i PeerAdmin -s secret
✔ List business network info-share-bc
name: info-share-bc
models:
- org.hyperledger.composer.system
- bc.share.info
<snip>
I believe when the server name can not be resolved, we will specify the option called "ssl-target-name-override", hyperledger node.js SDK as described here.
https://jimthematrix.github.io/Remote.html
- ssl-target-name-override {string} Used in test environment only,
when the server certificate's hostname (in the 'CN' field) does not
match the actual host endpoint that the server process runs at,
the application can work around the client TLS verify failure by
setting this property to the value of the server certificate's hostname
Is there any option to specify host name in connection profile (connection.json) ?
Found a work around: hostnameOverride option in connection profile resolved the connection issue.
"eventURL": "grpcs://<target-host>:17053",
"hostnameOverride": "peer0.org1.example.com",

Decentralised Docker Trust carbonchain

I need to use carbonchain to store/retrieve docker image keys into bitcoin blockchains. The issue is, how do I even specify the private key, key id and image:tag in the command. Bringing up the -help option gives this only:
ddt-master -help
2017/05/14 13:53:19 testnet: false
2017/05/14 13:53:19 datadir:
2017/05/14 13:53:19 app datadir: /home/ubuntu
2017/05/14 13:53:19 GOMAXPROCS: 4
Distributed Docker Trust
(c)2017 Faruq Rasid
SignAndSubmit <private key> <key id> <image:tag>
Verify <image:tag>
Options:
-datadir string
Bitcoin data path
-gomaxprocs int
Number of threads to use (default -1)
-help
Show help
-host string
Host for SignAndSubmit/Verify commands to connect to (default "localhost")
-loglevel int
Set log level: 0-4; Default: 4 (default 3)
-port string
Port to run daemon on. For SignAndSubmit/Verify commands, port to connect to (default "1323")
-rpcip string
Bitcoind RPC IP
* REQUIRED ONLY FOR STORE COMMAND
-rpcpassword string
Password for bitcoind RPC
* REQUIRED ONLY FOR store COMMAND
-rpcport string
Bitcoind RPC Port (Default for testnet set to append 1 to this variable)
* REQUIRED ONLY FOR store COMMAND
-rpcuser string
User for bitcoind RPC
* REQUIRED ONLY FOR store COMMAND
-testnet
Use testnet
I have no issues setting the other variables as I can refer to this page to refer to: https://en.bitcoin.it/wiki/Running_Bitcoin
The github site has no information at all regarding how to run the program
(https://github.com/ruqqq/carbonchain)

Resources