DEV Community

Cover image for Your first Hyperledger Fabric network

Your first Hyperledger Fabric network

Damien Cosset on June 22, 2018

Introduction In this article, we will build a simple blockchain network with Hyperledger Fabric. Fabric allows us to build a private blo...
Collapse
 
jean507 profile image
Jean Le Bouthillier • • Edited

Did you test this code before posting?

You generate the genesis block as "genesis.block" and later on use "orderer.genesis.block"

../bin/configtxgen -profile OrdererGenesis -outputBlock ./channel-artifacts/genesis.block

...

  • ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block

You also require "Template" in crypto-config.yaml, otherwise the crypto is not fully generated.

PeerOrgs:

  • Name: Microsoft Domain: microsoft.cool-network.com EnableNodeOUs: true Template: Count: 2 Users: Count: 1

It's also illegal to use capital letters in the naming of channel! The ordered will crash.

Collapse
 
danionita profile image
danionita •

Actually, changing
'ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block'
to
'ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/genesis.block'
breaks the code, because '/var/hyperledger/orderer/genesis.block' does not exist.

The original code was correct because in docker-compose-base.yaml, you mount the following volume:
../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block

Collapse
 
saifdeveloper profile image
Saif Ali •

can you please share you github link for this code ? It will be very helpful

Collapse
 
danionita profile image
danionita •

However, after fixing this, Ithe orderer fails to start with the following error:
' Error creating configtx manager and handlers: Error deserializing key Capabilities for group /Channel: Unexpected key Capabilities'

Collapse
 
danionita profile image
danionita •

Using the latest fabric images (i.e. removing all instances of ':x86_64-1.0.0-rc1') fixed this.

Collapse
 
damcosset profile image
Damien Cosset •

Thank you for your comment. I had no idea about the capital letters in the channel name causing problems! Thanks!

Collapse
 
danionita profile image
danionita • • Edited

Not sure if this is an error, but shouldn't:

CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/microsoft.cool-network.com/peers/peer0.microsoft.cool-network.com/tls/server.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/microsoft.cool-network.com/peers/peer0.microsoft.cool-network.com/tls/server.key
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/peers/peer0.apple.cool-network.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp

be

CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/microsoft.cool-network.com/peers/peer0.microsoft.cool-network.com/tls/server.crt
CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/microsoft.cool-network.com/peers/peer0.microsoft.cool-network.com/tls/server.key
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/**microsoft**.cool-network.com/peers/peer0.**microsoft**.cool-network.com/tls/ca.crt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/**microsoft**.cool-network.com/users/Admin@**microsoft**.cool-network.com/msp
Collapse
 
tharinducs profile image
Tharindu Sandaruwan •

when I try to create a channel after setting up this network It is giving me an error of like this.

2019-01-19 12:05:06.702 UTC [msp] getMspConfig -> WARN 001 Intermediate certs folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp/intermediatecerts]. Skipping. [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp/intermediatecerts: no such file or directory]
2019-01-19 12:05:06.712 UTC [msp] getMspConfig -> WARN 002 TLS intermediate certs folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp/tlsintermediatecerts]. Skipping. [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp/tlsintermediatecerts: no such file or directory]
2019-01-19 12:05:06.713 UTC [msp] getMspConfig -> WARN 003 crls folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp/crls]. Skipping. [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp/crls: no such file or directory]
2019-01-19 12:05:06.714 UTC [msp] getMspConfig -> INFO 004 MSP configuration file not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp/config.yaml]: [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/apple.cool-network.com/users/Admin@apple.cool-network.com/msp/config.yaml: no such file or directory]
Error: Error connecting due to rpc error: code = Unavailable desc = grpc: the connection is unavailable
Usage:
peer channel create [flags]

Flags:
-c, --channelID string In case of a newChain command, the channel ID to create.
-f, --file string Configuration transaction file generated by a tool such 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
--logging-level string Default logging level and overrides, see core.yaml for full syntax
-o, --orderer string Ordering service endpoint
--test.coverprofile string Done (default "coverage.cov")
--tls Use TLS when communicating with the orderer endpoint
-v, --version Display current version of fabric peer server

I tried it with this command.

peer channel create -o orderer.cool-network.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.t
x --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/cool-network.com/orderers/orderer.cool-network.com/ms
p/tlscacerts/tlsca.cool-network.com-cert.pem

Can you help me to solve this problem? Thank you.

Collapse
 
venki208 profile image
duddu venkatesh •

I m also facing same issue.

Collapse
 
jbgodilo profile image
Jeson Godilo •

Hi, Thanks for this very good article of you. Though seems like you've got a wrong pattern of configuration in configtx.yaml. When I tried your configuration I've got an error. And so I put the Profiles at the very end of the file and it works. I think you should put the Profile then at the very end part of the file. Thank you.

Collapse
 
jbgodilo profile image
Jeson Godilo •

Hi Damien,

I successfully started the network created using your tutorial above. Now, what I am trying to do is install a business network archive file in one of 3 organizations but unfortunately I encountered an error doing that. I don't if it is because of the version. Because I also followed the one that use the first-network and I successfully install the file in the network. Version used in first-network is 1.2.0.

Collapse
 
marcelloromani profile image
Marcello Romani •

Thanks for the well written article.

My question is what is the role of MicrosoftAnchor.tx

I don't see it referenced in the docker compose files.

Thanks

Collapse
 
_aisahihoonmain profile image
Swapnil K. Deshmukh • • Edited

Hey Damian, thanks for this article. Now, where can I find the next article related to this?

Collapse
 
chudamaniestam profile image
chudamani •

very helpful article

Collapse
 
planetsamee profile image
Samee Shah •

How can we write chaincode and maintain ledger after this? Please guide.