Error: instantiation policy violation: signature set did not satisfy policy - node.js

I am facing this problem, below is the exact error:
Error: instantiation policy violation: signature set did not satisfy policy
at self._endorserClient.processProposal
(/home/ubuntu/node_modules/fabric-client/lib/Peer.js:144:36)
at Object.onReceiveStatus
(/home/ubuntu/node_modules/grpc/src/client_interceptors.js:1212:9)
at InterceptingListener._callNext
(/home/ubuntu/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus
(/home/ubuntu/node_modules/grpc/src/client_interceptors.js:618:8)
at callback
(/home/ubuntu/node_modules/grpc/src/client_interceptors.js:847:24)
Here's my code, helper is the connection profile object of yaml.
var client = await helper.getClientForOrg(orgName, username);
var channel = client.getChannel(channelName);
var txId = client.newTransactionID(true);
var params = {
targets: peerNames,
chaincodePath: chaincodePath,
chaincodeId: chaincodeName,
chaincodeVersion: chaincodeVersion,
chaincodeType: "node",
channelNames: channelName
}
var deployResponse = await client.installChaincode(params);
console.log(deployResponse);
// send proposal to endorsing peers
var request = {
targets: peerNames,
chaincodeType: 'node',
chaincodeId: chaincodeName,
chaincodeVersion: chaincodeVersion,
txId: txId,
fcn: 'instantiate',
args: args
}
let results = await channel.sendUpgradeProposal(request);
console.log(results);
This is the example of classic one member & one peer Fabric BlockChain (AWS managed) where using fabric-client library we are able to invoke chaincode and do the query as well. And it's working with any deployed chaincode. However if we try to instantiate / update a chain code using sendUpgradeProposal() method or sendInstantiateProposal() it's giving permission error, mentioned on the post. However installChaincode() method working fine.

Related

ENDORSEMENT_POLICY_FAILURE while invoking chain code using even if the transaction object contains enough endorsements

I have a network on hyperledger fabric 1.4.4 with 5 organizations A , B, C , D , E. I created a channel with these 5 orgs and installed my chaincode on org A and org B because only they are apart of the endorsement policy.
This is the endorsement policy :
{"identities":[{"role":{"name":"member","mspId":"AMSP"}},{"role":{"name":"member","mspId":"BMSP"}},{"role":{"name":"member","mspId":"CMSP"}},{"role":{"name":"member","mspId":"DMSP"}},{"role":{"name":"member","mspId":"EMSP"}}],"policy":{"2-of":[{"signed-by":0},{"signed-by":1}]}}
I am using a gateway with the below configuration to invoke the chain code
const walletPath = path.join('wallet' );
const wallet = new FileSystemWallet(walletPath);
let connectionOptions = {
identity: userName,
wallet: wallet,
discovery: { enabled:true, asLocalhost: true },
eventHandlerOptions: {
commitTimeout: 100,
strategy: DefaultEventHandlerStrategies.NETWORK_SCOPE_ALLFORTX
}
};
logger.debug('Connecting to Fabric gateway');
await gateway.connect(clientConnectionProfileJson, connectionOptions);
const network = await gateway.getNetwork(channelName);
const contract = await network.getContract(chaincodeName , contractName);
const transaction = contract.createTransaction(functionName);
await transaction.submit(<arguments>);
This is the error which I a getting , at the client level
2021-02-17T05:28:13.063Z - warn: [TransactionEventHandler]: _strategyFail: strategy fail for transaction "9be4da8b1d52ddde804d6c7c08d134ef4b6ac2043cbe0258b5b4c921424c9f04": TransactionError: Peer a-org-peer1.a-org.com:7051 has rejected transaction "9be4da8b1d52ddde804d6c7c08d134ef4b6ac2043cbe0258b5b4c921424c9f04" with code "ENDORSEMENT_POLICY_FAILURE"
This is what I see in all the peer logs
2021-02-17 05:28:12.313 UTC [vscc] Validate -> ERRO 0db VSCC error: stateBasedValidator.Validate failed, err validation of endorsement policy for chaincode {chaincodeName} in tx 26:0 failed: signature set did not satisfy policy
After some research , I found that this is a failure that is occurring when the org peer is trying to commit the transaction to the ledger , and finds that the signature set did not satisfy the policy.
I have gone ahead and looked at the transaction object using the getTransactionByID method. I see that there are two endorsers MSP with the correct sign certificates , these certificates belong to the one of the peers of A and B orgs. So the discovery service correctly identified the peers and even the peers have endorsed the transaction , but not sure why the transaction is not getting committed.
What am I missing here ?
How can I verify if the signatures are correct ?
To explicitly say to the gateway that the request should go to specific endorsing peers , I have used the below code.
const walletPath = path.join('wallet' );
const wallet = new FileSystemWallet(walletPath);
let connectionOptions = {
identity: userName,
wallet: wallet,
discovery: { enabled: true , asLocalhost: true },
eventHandlerOptions: {
commitTimeout: 100,
strategy: DefaultEventHandlerStrategies.NETWORK_SCOPE_ALLFORTX
}
};
logger.debug('Connecting to Fabric gateway');
await gateway.connect(clientConnectionProfileJson, connectionOptions);
const network = await gateway.getNetwork(channelName);
const channel = network.getChannel();
let endorsingPeers = [];
endorsingPeers.push(channel.getChannelPeer('a-org-peer1.a-org.com'));
endorsingPeers.push(channel.getChannelPeer('b-org-peer1.b-org.com'));
// Get addressability to org.cargoesnetwork.ebilloflading contract
// Use chaincodeName that is used for installing
const contract = await network.getContract(chaincodeName , contractName);
const transaction = contract.createTransaction(functionName).setEndorsingPeers(endorsingPeers);
await transaction.submit(<arguments>);
No luck , the transaction still fails with the same endorsement policy failure. I verified the transaction object if the endorser sign certs are correctly present. They are present , but still got the same error.
Out of curiosity , I changed the endorsement policy to only one org from two orgs , every thing worked as expected. The issue exists only when the policy contains more than one endorsing organisations.
Please help in debugging this issue.
An ENDORSEMENT_POLICY_FAILURE can occur for a number of reasons. The first being you don't have enough signatures which is what you have said you have already checked. Another reason is that not all the signatures match to the proposal that was sent.
In the 1.4 gateway apis the proposals are received and not compared to see if they all match before a proposal is sent to the orderer. The SDK will send all the signatures and one of the proposals that was received back. The signatures are created over the each peer's individual proposal response.
If those proposals don't match (which would mean that your chaincode is not deterministic) then one of those signatures will be ok, but the other one won't because it won't match the proposal that was sent to the orderer.
I would check that your chaincode is deterministic because it's possible that each peer is generating different responses. An example of non-deterministic chaincode for example is where it creates a new date and stores that in the world state. Each peer would create a slightly different date value resulting in differing responses.

Added a new Org to an existing Hyperledger Fabric Network. Now having issues with getting a Peer to join an existing channel

This question picks up from my earlier question about adding a new org to an existing channel using fabric node sdk.
Gari helped addressing my issues with using the Node SDK and I was able to successfully add the Org to the channel mychannel, which is part of byfn.sh.
Now, following the original tutorial which I had adapted, I want to add the new Org's peers to join the channel mychannel. I am stuck here at the moment and have not been able to find a solution despite looking on Stackoverflow, HL Lists and HL Jira.
At a high level, the steps I am following are these:
Add the new Org to the channel (uses Client.updateChannel API). I can do this successfully.
I then bring up the peer and the couchdb docker containers for the peers associated with the new Org. The new org is Org3 and here is the connection profile
{
"name": "first-network-org3",
"version": "1.0.0",
"client": {
"organization": "Org3",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
}
}
}
},
"organizations": {
"Org3": {
"mspid": "Org3MSP",
"peers": [
"peer0.org3.example.com"
]
}
},
"peers": {
"peer0.org3.example.com": {
"url": "grpcs://localhost:11051",
"tlsCACerts": {
"path": "/usr/local/fabric/fabric-samples/first-network/crypto-config/peerOrganizations/org3.example.com/tlsca/tlsca.org3.example.com-cert.pem"
},
"grpcOptions": {
"ssl-target-name-override": "peer0.org3.example.com"
}
}
}
}
I use a client pointing to the Org1 connection profile and extract the Network and Channel objects, and subsequently retrieve the channel's genesis block.
I then create a new connection profile to point to Org3 peers and connect to it, and get a new (Org3) client reference.
Using this Org3 client, I create a new Peer object (Client.newPeer)
I then issue a channel.joinChannel(request).
Every single time, I get the following error from the client application
Error: 2 UNKNOWN: access denied: channel [] creator org [Org1MSP]
Docker logs for Peer 3 say this:
2020-01-24 19:46:47.774 UTC [protoutils] ValidateProposalMessage ->
WARN 039 channel []: MSP error: expected MSP ID Org3MSP, received
Org1MSP
2020-01-24 19:46:47.774 UTC [comm.grpc.server] 1 -> INFO 03a
unary call completed grpc.service=protos.Endorser
grpc.method=ProcessProposal grpc.peer_address=192.168.240.1:49860
error="access denied: channel [] creator org [Org1MSP]"
grpc.code=Unknown grpc.call_duration=329.567µs
I know this error is because the MSP ID being submitted with the Channel.joinChannel request is Org1MSP but I am not sure why. I am submitting a peer created using an Org3 client and the transaction ID is also an Org3 Admin transaction ID.
Here is my code:
public async addPeerToChannel(orgJSON) {
try {
let json = JSON.parse(JSON.stringify(orgJSON));
if (json.name === undefined || json.msp === undefined || json.domain === undefined || json.peer === undefined
||
json.peerport === undefined || json.channel === undefined || json.peerurl === undefined) {
throw new Error("Invalid org info provided to addPeerToChannel method");
}
let client = this.loanGateway.getClient(); // get the client reference for Org1 ccp
let cMSP = client.getMspid(); // confirms MSP ID is Org1MSP
let network = await this.loanGateway.getNetwork(json.channel); // mychannel
let channel = network.getChannel();
if (client === undefined || network === undefined || channel === undefined) {
throw new Error(`Invalid network, orderer, channel or client handle in function addPeerToChannel. Error.`);
}
let data = fs.readFileSync(SyndLoanConfig.chainconfig.networkpath + `/crypto-config/peerOrganizations/${json.domain}/peers/${json.peer}/tls/ca.crt`).toString();
// load a new client for Org3
const gateway = new Gateway();
const wallet = this.localWallet;
const ccpFile = fs.readFileSync(path.join(SyndLoanConfig.chainconfig.networkpath,'connection-org3_ac.json'));
const ccp = JSON.parse(ccpFile.toString());
await this.importWalletIdentityFromCryptoConfig('Admin#org3.example.com','Org3MSP');
await gateway.connect(ccp, {
identity: 'Admin#org3.example.com',
wallet: wallet
});
let newClient = gateway.getClient();
let peer = newClient.newPeer(json.peerurl,
{
'pem': Buffer.from(data).toString(),
'ssl-target-name-override': json.peer,
'name': json.peer,
'grpc.keepalive_timeout_ms': 10000
})
if (peer === undefined) {
throw new Error(`Could not create the peer for URL ${json.peerurl}. Error.`)
}
channel.addPeer(peer, json.msp);
let request = {
txId: client.newTransactionID() //the generated transaction id
};
let gBlock = await channel.getGenesisBlock(request);
// for(let p of ccp.peers)
// {
// ccp.peers[p].tlsCACerts.path = path.join(SyndLoanConfig.chainconfig.networkpath,ccp.peers[p].tlsCACerts.path);
// }
// let newNetwork = await gateway.getNetwork("mychannel");
// let newChannel = newNetwork.getChannel();
let channel_request = {
targets: [peer],
block: gBlock,
txId: newClient.newTransactionID(true)
}
let proposal_response = {};
proposal_response = await channel.joinChannel(channel_request);
if (proposal_response[0].code !== 200)
{
throw new Error(`Could not make the peer ${json.peer} join channel ${json.channel}. Error: ${proposal_response[0].message}`);
}
}
catch (err) {
throw new Error(err.message);
}
}
I am sure I am missing something but I am not able to figure out what, and why the joinChannel request is being submitted with MSP set to Org1MSP (by the way, where is this set?)
Appreciate any advice on how to proceed. Thank you.
Was finally able to locate some sample code for Channel.joinChannel.
For those interested, these examples by ksachdeva are extremely helpful.
Essentially, what I was doing wrong was using a channel object associated with an Org1MSP client context, and using that to submit the Channel.joinChannel call.
So, the fix was this (broadly speaking)
Assuming the Org has already been added to the channel,
Create a new client instance using the new Org's common connection profile, or you can create a new client instance from scratch using this sample code by ksachdeva.
Create a new channel instance using Client.newChannel("mychannel") or whatever channel you are joining.
Create a new Orderer instance using Client.newOrderer call, that serves as the Orderer for the channel you are joining. In byfn.sh terminology, this is grpcs://localhost:7050 aka orderer.example.com.
Create a new Peer instance using the peer information for the peer you are adding to the channel.
Add the orderer from Step 3 above to the channel object created in Step 2 using Channel.addOrderer(orderer) API.
Then, the rest of the steps can be followed from the tutorial on Fabric Node SDK site i.e. fetch the genesis block, create a request for joining the peer, and submit the Channel.joinChannel(request).
Please review ksachdeva's example code (link provided earlier in this response) for a complete end-to-end code sample.

Querying chaincode is only successful in ~3/5 cases with nodejs

I successfully installed and instantiated chaincode on my chain. I'm able to enroll the admin and register a user trough nodejs. If I query the chaincode it only returns a correct response around 3 out of 5 times. The rest throws errors that the chaincode can't be found.
The chaincode installed is the basic example from the fabric samples.
My js file to query the chaincode (based on the fabcar example):
/*
* SPDX-License-Identifier: Apache-2.0
*/
'use strict';
const { FileSystemWallet, Gateway } = require('fabric-network');
const path = require('path');
const ccpPath = path.resolve(__dirname, 'connection-org1.json');
async function main() {
try {
// Create a new file system based wallet for managing identities.
const walletPath = path.join(process.cwd(), 'wallet');
const wallet = new FileSystemWallet(walletPath);
console.log(`Wallet path: ${walletPath}`);
// Check to see if we've already enrolled the user.
const userExists = await wallet.exists('user1');
if (!userExists) {
console.log('An identity for the user "user1" does not exist in the wallet');
console.log('Run the registerUser.js application before retrying');
return;
}
// Create a new gateway for connecting to our peer node.
const gateway = new Gateway();
await gateway.connect(ccpPath, { wallet, identity: 'user1', discovery: { enabled: true, asLocalhost: true } });
// Get the network (channel) our contract is deployed to.
const network = await gateway.getNetwork('mychannel');
// Get the contract from the network.
const contract = network.getContract('mycc');
const result = await contract.evaluateTransaction('query', 'a');
console.log(`Transaction has been evaluated, result is: ${result}`);
} catch (error) {
console.error(`Failed to evaluate transaction: ${error}`);
process.exit(1);
}
}
main();
The successful queries with the errors, nothing has been changed between those executions and they have been called with around 5 seconds beetween them.
root#devserver ~/fabric-samples/bla/first-network # node index.js
Transaction has been evaluated, resultb is: 210
root#devserver ~/fabric-samples/bla/first-network # node index.js
Transaction has been evaluated, resultb is: 210
root#devserver ~/fabric-samples/bla/first-network # node index.js
Transaction has been evaluated, resultb is: 210
root#devserver ~/fabric-samples/bla/first-network # node index.js
Transaction has been evaluated, resultb is: 210
root#devserver ~/fabric-samples/bla/first-network # node index.js
2019-09-09T18:53:24.646Z - warn: [Query]: evaluate: Query ID "[object Object]" of peer "peer1.PharmaProducer.bigpharma.com:8051" failed: message=cannot retrieve package for chaincode mycc/1.0, error open /var/hyperledger/production/chaincodes/mycc.1.0: no such file or directory, stack=Error: cannot retrieve package for chaincode mycc/1.0, error open /var/hyperledger/production/chaincodes/mycc.1.0: no such file or directory
at self._endorserClient.processProposal (/root/fabric-samples/bla/first-network/node_modules/fabric-network/node_modules/fabric-client/lib/Peer.js:140:36)
at Object.onReceiveStatus (/root/fabric-samples/bla/first-network/node_modules/grpc/src/client_interceptors.js:1207:9)
at InterceptingListener._callNext (/root/fabric-samples/bla/first-network/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/root/fabric-samples/bla/first-network/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/root/fabric-samples/bla/first-network/node_modules/grpc/src/client_interceptors.js:845:24), status=500, , url=grpcs://localhost:8051, name=peer1.PharmaProducer.bigpharma.com:8051, grpc.max_receive_message_length=-1, grpc.max_send_message_length=-1, grpc.keepalive_time_ms=120000, grpc.http2.min_time_between_pings_ms=120000, grpc.keepalive_timeout_ms=20000, grpc.http2.max_pings_without_data=0, grpc.keepalive_permit_without_calls=1, name=peer1.PharmaProducer.bigpharma.com:8051, grpc.ssl_target_name_override=peer1.PharmaProducer.bigpharma.com, grpc.default_authority=peer1.PharmaProducer.bigpharma.com, isProposalResponse=true
Failed to evaluate transaction: Error: cannot retrieve package for chaincode mycc/1.0, error open /var/hyperledger/production/chaincodes/mycc.1.0: no such file or directory
I expect the code to successfuly return a correct result every time and not randomly show an error that the code doesn't exist.
Any insight on how this can happen is appreciated.
Looking at the logs I can see why sometimes you get peer0 and occasionally you get peer1, and that is because the discovery results and processing result in it not being possible to get the list of peers in any particular order so with 2 peers in your org and the fact that this is not a long running app but a short running invocation sometimes peer0 will be first in the list of peers and sometimes peer1. Because you have only installed the chaincode on peer0, peer1 can't honour the evaluate request and return an error.
The node-sdk should detect this and then try peer0 but either you are using an older version of the node-sdk which definitely had an issue where it did not try a different peer or the node-sdk is thinking this is (incorrectly, but may not be able to distinguish) a chaincode response and passes that back to the caller.
The solution to avoid the error is to install the chaincode on all the peers.

hyperledger fabric chain code installation

i am getting an error while i am trying to install my chain code on my peers
i am using Hyperledger Fabric
var request = {
targets: ["peer1.org2.example.com","peer0.org2.example.com"],
chaincodePath: 'github.com/fabcar/node',
// chaincodePath:'/opt/gopath/src/github.com/fabcar/node',
chaincodeId: 'org2cc',
chaincodeVersion: 'v1',
chaincodeType: 'test'
};
let results = await client.installChaincode(request);
This is my function to install chain code
I am using NodeSDK
chaincodeType => Type of chaincode. One of 'golang', 'car', 'node' or 'java'. Default is 'golang'.
Better remove this optional field (chaincodeType) from your request and try again!!

Error when Creating Channel Using Hyperledger Fabric Node JS

I'm trying to create a channel with the Fabric SDK node.js. When I create the channel through the bash commands, I have no problems (you can see the code below), but when I use the node.js SDK I got some errors.
I am using TLS and client authentication. I can't realize what the error means and how to solve it. Any help will be greatly appreciated.
Node JS code to create Channel, it was executed in host machine:
var Fabric_Client = require('fabric-client');
var fs=require('fs');
var fabric_client = new Fabric_Client();
// Obtain tls cert and key from client.
let clientcert = fs.readFileSync('/home/rosalva40/Documentos/Own2/Own/data/tls/peer1-org1-cli-client.crt');
let clientkey = fs.readFileSync('/home/rosalva40/Documentos/Own2/Own/data/tls/peer1-org1-cli-client.key');
fabric_client.setTlsClientCertAndKey(clientcert.toString(),clientkey.toString())
//Orderer configuration
let pem1 = fs.readFileSync('/home/rosalva40/Documentos/Own2/Own/data/org0-ca-chain.pem');
const connectionopts = {
pem: pem1.toString()
};
var order = fabric_client.newOrderer('grpcs://localhost:9101', connectionopts)
//setup identity admin
let cert = fs.readFileSync('/home/rosalva40/Documentos/Own2/Own/data/orgs/org1/admin/msp/signcerts/cert.pem');
let pk = fs.readFileSync('/home/rosalva40/Documentos/Own2/Own/data/orgs/org1/admin/msp/keystore/b17b8a06b4928a037e621cc784cac4f8a4913087c95c68162ecae6189993a1fa_sk');
const mspid = 'org1MSP';
fabric_client.setAdminSigningIdentity(pk, cert, mspid);
// Setup create channel
var chanelName = 'mychannel';
const envelope = fs.readFileSync('/home/rosalva40/Documentos/Own2/Own/data/channel.tx');
channelConfig = fabric_client.extractChannelConfig(envelope);
signature = fabric_client.signChannelConfig(channelConfig);
const request = {
name: chanelName,
orderer: order,
config: channelConfig,
signatures : [signature],
txId : fabric_client.newTransactionID(true)
};
//Create chanel
fabric_client.createChannel(request);
When I run createChannel.js, I get the following error in the console:
2019-01-17T14:30:42.278Z - error: [Remote.js]: Error: Failed to
connect before the deadline URL:grpcs://localhost:9101
2019-01-17T14:30:42.283Z - error: [Orderer.js]: Orderer
grpcs://localhost:9101 has an error Error: Failed to connect before
the deadline URL:grpcs://localhost:9101 (node:31051)
UnhandledPromiseRejectionWarning: Error: Failed to connect before the
deadline URL:grpcs://localhost:9101
at checkState (/home/rosalva40/fabric-samples/vote/node_modules/fabric-client/node_modules/grpc/src/client.js:720:16)
(node:31051) UnhandledPromiseRejectionWarning: Unhandled promise
rejection. This error originated either by throwing inside of an async
function without a catch block, or by rejecting a promise which was
not handled with .catch(). (rejection id: 2) (node:31051) [DEP0018]
DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.
And this is the orderer node log:
2019-01-17 16:08:40.977 UTC [grpc] Println -> DEBU 13a grpc:
Server.Serve failed to create ServerTransport: connection error: desc
= "transport: http2Server.HandleStreams failed to receive the preface from client: EOF" 2019-01-17 16:08:41.987 UTC [grpc] Println -> DEBU
13b grpc: Server.Serve failed to create ServerTransport: connection
error: desc = "transport: http2Server.HandleStreams failed to receive
the preface from client: EOF" 2019-01-17 16:08:43.572 UTC [grpc]
Println -> DEBU 13c grpc: Server.Serve failed to create
ServerTransport: connection error: desc = "transport:
http2Server.HandleStreams failed to receive the preface from client:
EOF"
This is the bash code executed in a container:
DATA=data
CHANNEL_TX_FILE=/$DATA/channel.tx
CHANNEL_NAME=mychannel
# ORDERER CONNECTION ARGUMENTS
ORDERER_HOST=orderer1-org0
ORDERER_PORT_INT=7050
INT_CA_CHAINFILE=/${DATA}/org0-ca-chain.pem
ORDERER_PORT_ARGS="-o $ORDERER_HOST:$ORDERER_PORT_INT --tls --cafile $INT_CA_CHAINFILE --clientauth"
export CORE_PEER_TLS_CLIENTCERT_FILE=/$DATA/tls/peer1-org1-cli-client.crt
export CORE_PEER_TLS_CLIENTKEY_FILE=/$DATA/tls/peer1-org1-cli-client.key
ORDERER_CONN_ARGS="$ORDERER_PORT_ARGS --keyfile $CORE_PEER_TLS_CLIENTKEY_FILE --certfile $CORE_PEER_TLS_CLIENTCERT_FILE"
#ORGANIZATION ADMIN ENVIROMENT ARGUMENTS
ORG_ADMIN_HOME=/${DATA}/orgs/org1/admin
export CORE_PEER_MSPCONFIGPATH=$ORG_ADMIN_HOME/msp
export CORE_PEER_LOCALMSPID=org1MSP
#CHANNEL CREATE COMMAND
peer channel create --logging-level=DEBUG -c $CHANNEL_NAME -f $CHANNEL_TX_FILE $ORDERER_CONN_ARGS
Its seems like the app has problems to connect to the orderer. Try using this method:
var Client = require('fabric-client');
var Channel = require('fabric-client').Channel;
const fs = require('fs');
var client = Client.loadFromConfig("config/configfile.yaml");
/**
* #param {String} channelName Channel name used in configtxgen to create the channel transaction (mychannel)
* #param {String} channelConfigPath Path of the channel transaction (/home/root/channel-artifacts/channel.tx)
* #param {String} orderer Orderer name (orderer.example.com)
* #description Create channel
*/
async createChannel(channelName,orderer, channelConfigPath) {
var envelope = fs.readFileSync(channelConfigPath);
var channelConfig = client.extractChannelConfig(envelope);
let signature = client.signChannelConfig(channelConfig);
let request = {
config: channelConfig,
orderer: client.getOrderer(orderer),
signatures: [signature],
name: channelName,
txId: client.newTransactionID(true)
};
const result = await client.createChannel(request)
return result;
}
You can check the structure of the configfile.yaml in this link.
Dont forget to set the client header in your configfile.yaml

Resources