How to generate Hyperlegder Fabric genesis block with/ without configtxgen tool - hyperledger-fabric

I'll go straight to my problems.
All we know that to start a fabric network, we need a genesis block. I just know the only way to generate genesis block using configtxgen from HF and it requires a config file.
Here is my situation:
User can choose organizations to create consortium.
I thought about the way to generate the config file but it doesn't work. I can't define any structs like the config file ( cause they contain & << * character - go-yaml module didn't help).
I got two questions:
If we can continue with using the config file solution, how we can generate a file with special characters?
Is there any way to generate genesis block without configtxgen
Additional information. I'm using Fabric 2.2
Any help is appreciated :)

Finally, I found the solution. Because Hyperledger Fabric already exported module named fabric-config#v0.0.9, we can use this module to create and generate config block. It was pretty upset that they don't tell us in document. Lucky for me when I saw the module and tried.

Related

how to start hyper ledger fabric without fabric-samples?

I am going to build my own hyperledger fabric network , but I cannot see how to start my project without the fabric-sample, because all the tutorials I found did not tell me how. How can I get those folders and stuffs for my own project? .
You could go through the scripts of Fabric-samples to see what it does as a reference but in general the algorithm is the following:
define the participants in your network in crypto-config.yaml and generate their crypto materials with either cryptogen (but not for production network!) or manually.
define the network parameters like different policies, ordered type, consortium etc in configtx.yaml and generate a genesis block from it using configtxgen tool
having that you may run required nodes like peers belonging to different organizations, orderers and certificate authorities servers and actually start the network, the channels, install chaincodes as it all referenced in Fabric docs: https://hyperledger-fabric.readthedocs.io/en/release-2.2/

How create or generate the channelTx and Genesisblock

I am using the configTx to create the channelTx and genesis block,
using the config-file.yaml.
Is there is any other way to create the channelTx and genesisTx using fabric-sdk-node ?
when the fabric network setup and running are it possible to update the channelTx ?
Thanks for asking this question, as many wants to know the answer to this question
Let me first talk about hyperledger fabric tools
cryptogen
configtxgen
configtxlator
protolator
idemixgen
Link here: https://github.com/hyperledger/fabric/tree/release-1.4/common/tools
These tools are opensource and built by IBM, fabric team, aims to fulfill configuration tasks. As of now 1.4 SDK's doesn't support for configuration tasks
Each & every tool is built by golang and make use of grpc
Coming to your second question:
Once the channel is created then no use of channel.tx file if you want to update you will have to send update transaction

How to execute the given "js files" on the Fabric network?

I'm studying Hyperledger Fabric with the documentation(https://hyperledger-fabric.readthedocs.io/en/release-1.0/write_first_app.html)
I'm done with two samples, which is "Building Your First network" & "Writing Your First Application"
I'm also done adding 1 extra peer to each organization, by modifying certain files, as well as done trying all commands on "Writing Your Fist Application" session.
Now, I'd like to execute the same commands(e.g. Querying all cars, Adding new cars or whatever) on the first network where I have built up, not on the test Fabcar network.
The thing is that I really have no idea what to do and how to do, even though I know how to handle NodeJS program(by Writing Application webpage)
So I'd like to ask you some questions.
Should I modify some files in order to "move" all necessary things to my network? if so, which file should I modify?
By any chance, Could you please tell me the correct steps to make it? I feel like I need to install and instantiate the required smart contract on my peers. Am I right?
I really appreciate your help in advance.
To answer your question, you would need to read some documentation online that will help you understand the architecture and how you can build up the packages as hyperledger fabric provided freedom to users to create use case specific configurations.
To start with.
Make sure you have have understood the concept of peer, orderer, couchdb, ca authority. Those 4 things you need to play with most of the times.
Assuming you have installed nodejs and able to run node through terminal, Read through the following example
Tuna Fish example, it help you to understand the concept of injecting, updating, querying blockchin ledger. Also, It will help understand the usage of Nodejs backend and angularjs basic UI. or use the other examples as you have seen on the fabric-samples github repository. Fabric Samples. Balance Transfer will help you understand the channel and chaincode operations using Node JS. Build your first network will help you understand the configuration files(concentrate on docker-compose.yaml, scipt.js and byfn.js)
Then to answer your questions.
you just have to modify the mount drive config variables in docker-componse-cli.yaml. Then you can edit your startup script based on how you want to move chaincode to your peer.
you need to install chaincode on all the peers that are part of that channel. And you only need to instantiate chaincode once per channel.
Installation and instantiation combination is a powerful feature because it allows for a peer to interact with the same chaincode container across multiple channels. The only prerequisite is for the actual chaincode source files to be installed on the peer's file system. As such, if a piece of common chaincode is being used across dozens of channels, a peer would need only a single chaincode container to perform read/writes on all the channel ledgers.
To run the node js files on the fabric network.
welcome to blockchain world :)

Hyperledger Fabric: What's the relationship between MSP and Fabric CA

For BYFN, If the network is started with ./byfn.sh -m up. How is MSP work without CA containers?
Please consider to take a look on my previous answer for "What is the difference between MSP and Fabric CA?" first.
Now to expand a bit on this:
For BYFN, If the network is started with ./byfn.sh -m up. How is MSP work without CA containers?
In build your first network example, used cryptogen tool which primarily used in testing and demo scenarios to quickly setup crypto materials required to initialize the MSP, basically it generates certificates needed to operate network entities. Therefore there is no actually need to use Fabric-CA, however there is a different example which I advise you to explore which make use of Fabric-CA as well instead of relying on cryptogen.

what crypto-config.yaml and configtx.yaml generate msp and orderer.blcok about Fabric sample chaincode-docker-devmode

I know cryptogen could generate msp ,and configtxgen tools could generate genesis.block and myc.tx, I want to know what crypto-config.yaml and configtx.yaml could generate them, and where to explain notion about them detail??
cryptogen is just a convenience tool to make it easier to get up and running with a sample network quickly without having to go through the process of setting up certificate authorities and gathering the cryptographic material required for X509-based MSPs. Not sure exactly what answer you are looking for, but it basically generates MSPs per the specification outlined here. The format for crypto-config.yaml itself is described in the yaml file itself. You can generate a template file without generating the actual crypto material using cryptogen showtemplate. The generated yaml should provide the details / options which are available. It is also possible to generate MSPs using the fabric-ca and fabric-ca-client as well.
For configtxgen and configtx.yaml, have you looked at http://hyperledger-fabric.readthedocs.io/en/latest/configtx.html and http://hyperledger-fabric.readthedocs.io/en/latest/configtxgen.html ?

Resources