Applied Blockchain Center (ABC)
  • System requirements for ABC
  • Hedera
    • ๐Ÿ…ฐ๏ธAbout Hedera
    • ๐Ÿ–ฅ๏ธEnvironment Setup
    • Tutorials
      • Accounts
        • Get My Account Info
        • Get Other Account Info
        • Transfer HBAR
      • Consensus Service
        • Create Topic
        • Subscribe to a topic
        • Submit a message
      • File Service
        • Create a File
        • Retrieve File
      • Scheduled_TX
        • Create Scheduled Transaction
        • Scheduled Transaction Info
        • Delete Scheduled Transaction
        • Submit Signature
      • SmartContract Service
        • Deploy to Hedera
        • Seal Document
        • Get Seal
        • Check Seal Revocation Status
        • Revoke Document
      • Token Service
        • Fungible Token
        • Non-fungible Token
  • Hyperledger Fabric
    • ๐Ÿ“‘About Hyperledger Fabric
    • ๐Ÿ’ปPrerequisite Installation
    • Fabric Installation
      • ๐ŸงชInstallation & Test
      • โœˆ๏ธLaunch Network
      • โ›“๏ธChannel Creation
      • ๐ŸššChaincode Deployment
      • โ–ถ๏ธChaincode Execution
  • Hyperledger Besu
    • Besu Network Set
Powered by GitBook
On this page

Was this helpful?

  1. Hyperledger Fabric
  2. Fabric Installation

Channel Creation

Here we will understand the Confixtx.yaml file and learn how to create channel.

Create Channel

  1. Set the Config Path

export PATH=${PWD}/../bin:${PWD}:$PATH
export FABRIC_CFG_PATH=${PWD}/configtx
export CHANNEL_NAME=mychannel
  1. Create the System Genesis Block and Channel Genesis block

configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/${CHANNEL_NAME}.block -channelID $CHANNEL_NAME
  1. Convert Block to JSON format to understand the data inside it.

configtxgen -inspectBlock ./channel-artifacts/mychannel.block > dump.json
  1. Copy some prerequisites

cp ../config/core.yaml ./configtx/.
  1. Create the Channel

Let's Export the Environment variables to provide Orderer access to our terminal.

export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
export ORDERER_ADMIN_TLS_SIGN_CERT=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
export ORDERER_ADMIN_TLS_PRIVATE_KEY=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key

Let's create a channel using "OSNADMIN" binary file.

osnadmin channel join --channel-id $CHANNEL_NAME --config-block ./channel-artifacts/${CHANNEL_NAME}.block -o localhost:7053 --ca-file "$ORDERER_CA" --client-cert "$ORDERER_ADMIN_TLS_SIGN_CERT" --client-key "$ORDERER_ADMIN_TLS_PRIVATE_KEY"
  1. Join the Organizational peers in the channel

First Let's join Org1 Peer.

To join the channel, our terminal needs access to peer, for that let's write a script which will set the environment variables.

Script Name: setOrgPeerContext.sh

#!/bin/bash

# import utils
source scripts/envVar.sh

ORG=$1

setGlobals $ORG

Now let's source the script.

source ./scripts/setOrgPeerContext.sh 1

Let's join the peer now

peer channel join -b ./channel-artifacts/mychannel.block

Join Org2 Peer Now

source ./scripts/setOrgPeerContext.sh 2
peer channel join -b ./channel-artifacts/mychannel.block
  1. Update Anchor peer for Org1

source ./scripts/setOrgPeerContext.sh 1
docker exec cli ./scripts/setAnchorPeer.sh 1 $CHANNEL_NAME
  1. Update Anchor peer for Org2

source ./scripts/setOrgPeerContext.sh 2
docker exec cli ./scripts/setAnchorPeer.sh 2 $CHANNEL_NAME

That's it!

PreviousLaunch NetworkNextChaincode Deployment

Last updated 1 year ago

Was this helpful?

โ›“๏ธ