fabric-sdk-go icon indicating copy to clipboard operation
fabric-sdk-go copied to clipboard

how to use this to create channel at fabric2.4 without orderer system channel

Open jianlu8023 opened this issue 1 year ago • 5 comments

when 
 i use this sdk to create channel at fabric2.4.3 test-network has err mains without orderer system channel

jianlu8023 avatar Aug 25 '23 05:08 jianlu8023

I think you should firstly start an oredering node. Orderer is the one of key parts in Hyperledger Fabric, and it should be created earlier, than channel, because it establishes a consensus on the order of transactions across the entire network, while channel is the place where transactions occurs.

https://hyperledger-fabric.readthedocs.io/en/latest/deployorderer/ordererdeploy.html?highlight=orderer#start-the-orderer

werniq avatar Oct 19 '23 06:10 werniq

I think you should firstly start an oredering node. Orderer is the one of key parts in Hyperledger Fabric, and it should be created earlier, than channel, because it establishes a consensus on the order of transactions across the entire network, while channel is the place where transactions occurs.

https://hyperledger-fabric.readthedocs.io/en/latest/deployorderer/ordererdeploy.html?highlight=orderer#start-the-orderer

this is my steps:

  1. use network.sh start test-network environment command: ./network.sh up -ca -s couchdb
  2. use go sdk to create a channel

then i meet this problem

i want to study use go-sdk to create a channel and other operation such as install chaincode

jianlu8023 avatar Oct 20 '23 03:10 jianlu8023

You can use ./network.sh up createChannel and it will create channel with name mychannel, and install chaincode there like: peer chaincode package basic.tar.gz --path path/to/your/chaincode --lang golang --label basic_1.0 && peer chaincode install basic.tar.gz

werniq avatar Oct 20 '23 05:10 werniq

You can use ./network.sh up createChannel and it will create channel with name mychannel, and install chaincode there like:

peer chaincode package basic.tar.gz --path path/to/your/chaincode --lang golang --label basic_1.0

&&

peer chaincode install basic.tar.gz

yes i know but i want to use sdk to operation environment

jianlu8023 avatar Oct 20 '23 05:10 jianlu8023

Then you should firstly initialize fabric sdk:

fsdk, err := fabsdk.New(config.FromFile("config.yaml")) if err != nil { panic(err) } // defer close clientContext := sdk.Context() and then, create a channel

channelClient, err := channel.New(clientContext) if err != nil { panic(err) } err = channelClient.CreateChannel(channel.Request{ Name: "mychannel", Orderer: "orderer.example.com", }) if err != nil { panic(err) }

werniq avatar Oct 20 '23 07:10 werniq