hyperledger / fabric-sdk-go

https://wiki.hyperledger.org/display/fabric
Apache License 2.0
911 stars 511 forks source link

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

Open jianlu8023 opened 10 months ago

jianlu8023 commented 10 months ago

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

werniq commented 8 months ago

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

jianlu8023 commented 8 months ago

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

werniq commented 8 months ago

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

jianlu8023 commented 8 months ago

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

werniq commented 8 months ago

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) }