# Step 4 - Configure a channel

Till now ..

* We have created the docker network with fabric-ca container
* Registered and enrolled the peers and users needed for the app
* Added peer nodes and couch dbs to the docker network

Next

* we will create a channel&#x20;

## Channel

* [Channel](https://hyperledger-fabric.readthedocs.io/en/release-2.2/capabilities_concept.html) is one of the most important concepts in a fabric network
* Inshort - channel is a logical group of organisations in a fabric network which share the same ledger smart contracts
* There can be x number of  channels in a fabric network. Each has its own ledger (& world state) .Each channel can have y number of organisations as its participants
* Here we will create one channel with 2 orgs (investorOrg and managementOrg)
* Peers of each org will need to endorse a transaction before it can be added to the ledger

```
function configureChannel() {
 ......
  createChannelGenesisBlock

  createChannel
  infoln "Channel '$CHANNEL_NAME' created"

  ## Join all the peers to the channel
  infoln "Joining investorOrg peer to the channel..."
  joinChannel investorOrg
  infoln "Joining managementOrg peer to the channel..."
  joinChannel managementOrg
```

�Lets review the script to configure the "votingChannel"&#x20;

* Downloads the fabric helper binaries - most importantly configtxgen
* Create the genesis block for the channel ledger . The configtx.yaml contains the configuration for the channel .

  ```
  ./configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ${BLOCKFILE} -channelID $CHANNEL_NAME
  ```

  * &#x20;Amongst other important configs this has the endorsement [policies](https://hyperledger-fabric.readthedocs.io/en/release-2.2/create_channel/channel_policies.html) for transaction. Majority Endorsement means majority of orgs in the channel have to endorse the transaction to be added to ledger

  �

![](https://2772071924-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MboOdv6KJBicKnSS3td%2F-Mbv55acce-hklFvNii6%2F-Mbv9eSNZF5stfhaxPYj%2Fimage.png?alt=media\&token=5624e461-0edc-42c1-a06d-0bb3f9b9d3f0)

* configure channels on the ordering service

  ```
  ./osnadmin channel join --channelID $CHANNEL_NAME --config-block ${BLOCKFILE} -o localhost:7053 --ca-file "$ORDERER_CA" --client-cert "$ORDERER_ADMIN_TLS_SIGN_CERT" --client-key "$ORDERER_ADMIN_TLS_PRIVATE_KEY" >&log.txt�
  ```
* join both the peers to the channel  . take a note of the environment variables set before invoking peer binary. most importantly (CORE\_PEER\* variable) . this is how we control  for which orgs  peer invoke the peer command.

```
./peer channel join -b $BLOCKFILE >&log.txt
```

�
