<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ta-seen Junaid on Medium]]></title>
        <description><![CDATA[Stories by Ta-seen Junaid on Medium]]></description>
        <link>https://medium.com/@taseen-junaid?source=rss-909447499163------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yKwdabAA1AnMxZJ-.jpg</url>
            <title>Stories by Ta-seen Junaid on Medium</title>
            <link>https://medium.com/@taseen-junaid?source=rss-909447499163------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:39:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@taseen-junaid/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploying Azure AutoML AI Models on Bare Metal, On-Premises, or Custom Servers: A Tutorial with…]]></title>
            <link>https://taseen-junaid.medium.com/deploying-azure-automl-ai-models-on-bare-metal-on-premises-or-custom-servers-a-tutorial-with-f35ba44f31cc?source=rss-909447499163------2</link>
            <guid isPermaLink="false">https://medium.com/p/f35ba44f31cc</guid>
            <category><![CDATA[automl]]></category>
            <category><![CDATA[azure-machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ta-seen Junaid]]></dc:creator>
            <pubDate>Fri, 03 May 2024 06:22:01 GMT</pubDate>
            <atom:updated>2024-08-15T12:30:51.998Z</atom:updated>
            <content:encoded><![CDATA[<h3>Deploying Azure AutoML AI Models on Bare Metal, On-Premises, or Custom Servers: A Tutorial with Flask, Gunicorn, Conda &amp; Nginx</h3><h4>A Cost-Efficient Hybrid Approach for Custom Environments: Decoding Azure’s Abstract Layer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Z2Cj34mNITwmqZLNi5_IA.jpeg" /></figure><p>Deploying AI models efficiently requires establishing a strategic balance between utilizing current infrastructure, such as on-premises servers or specialized hardware, and exploiting the additional advance capabilities of cloud platforms such as Azure AutoML. A hybrid strategy allows enterprises to reduce costs, seamlessly integrate AI into current applications, and modify their infrastructure to meet specific performance, security, and compliance requirements. This strategy combines the best of both worlds, allowing enterprises to benefit from cloud innovation while maintaining control over vital infrastructure and data assets. <strong>Identifying the many abstract layers inside Azure AI models can be like solving a puzzle, making it a difficult but necessary task for efficient deployment in a hybrid infrastructure configuration.</strong></p><h3>Prerequisite</h3><ol><li>Microsoft Azure Machine Learning</li><li>Artificial Intelligence</li><li>Software deployment</li></ol><p>We suggest <a href="https://learn.microsoft.com/en-us/credentials/certifications/azure-data-scientist/?practice-assessment-type=certification">Microsoft Certified: Azure Data Scientist Associate course</a> and <a href="https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/dp-100">Study guide for Exam DP-100</a> for the people who do not know about Microsoft Azure Machine Learning.</p><h3>Why Azure AutoML</h3><p>Azure AutoML is a sophisticated tool from Microsoft Azure that simplifies the process of creating and deploying machine learning models. It is intended to make machine learning more approachable to developers, data scientists, and business analysts by abstracting away much of the complexity associated with the machine learning process. Below is an overview of Azure AutoML’s core features and capabilities:</p><ol><li><strong>Automated Model Selection</strong>: Azure AutoML chooses the appropriate machine learning model for your dataset based on a number of algorithms and architectures, such as decision trees, random forests, gradient boosting, and neural networks. This saves you time and effort while testing with various methods.</li><li><strong>Hyperparameter Optimization:</strong> It adjusts the hyperparameters of the chosen models to improve their performance. Hyperparameters are model-specific factors that influence the learning process, such as the learning rate, number of layers in a neural network, and tree depth in decision trees. Azure AutoML use techniques such as grid search, random search, and Bayesian optimization to rapidly search the hyperparameter space and identify the best configuration.</li><li><strong>Feature Engineering:</strong> Azure AutoML automates feature engineering, which is the process of choosing, manipulating, and producing features from raw data to improve model performance. It automates operations such as missing value imputation, categorical encoding, feature scaling, and feature selection, allowing you to concentrate on the problem domain rather than the complexities of data preprocessing.</li><li><strong>Model Interpretability:</strong> The service offers insights into how the model creates predictions, allowing you to better understand the factors that drive its judgments. This is critical for regulatory compliance, model debugging, and increasing confidence in the model’s predictions.</li><li><strong>Scalability and Performance: </strong>Azure AutoML is built on Microsoft Azure’s resilient infrastructure, allowing it to scale smoothly to handle huge datasets and compute-intensive workloads. It uses distributed computing resources to efficiently train models and make high-performance predictions.</li><li><strong>Integration with Azure Ecosystem:</strong> Azure AutoML integrates seamlessly with other Azure services, including Azure Machine Learning, Azure Databricks, Azure Synapse Analytics, and Azure DevOps, allowing you to harness the full power of the Azure ecosystem to create end-to-end machine learning solutions.</li><li><strong>Deployment Options:</strong> After training a model using Azure AutoML, you can simply deploy it to a variety of deployment destinations, such as Azure Kubernetes Service (AKS), Azure Container Instances (ACI), Azure IoT Edge, Azure Functions, or a web service endpoint. This allows you to grow your models and link them with your existing apps and workflows.</li></ol><p>Overall, Azure AutoML simplifies the machine learning workflow, from data preparation and model training to deployment and monitoring, allowing enterprises to harness the power of AI in their products and services.</p><h4>Why Hybrid Approach</h4><ol><li><strong>Cost-Efficient:</strong></li></ol><p><strong>Utilizing Existing Infrastructure:</strong> By eliminating the need to invest in additional cloud resources, leveraging existing on-premises or custom servers can drastically lower the expenses involved with deploying AI models. <br><strong>Optimized Resource usage:</strong> By consolidating numerous deployments on a single server instance, enterprises can improve resource usage and reduce idle capacity, resulting in increased cost efficiency.</p><p>2. <strong>Integration of Existing Applications: </strong><br> <br><strong>Seamless Integration: </strong>A hybrid approach enables the seamless integration of AI models into current systems without requiring large architectural modifications or reliance on external cloud services. <br><strong>Minimized Disruption:</strong> Integration with existing apps minimizes disturbance to workflows and processes, allowing for the smooth adoption of AI capabilities within the existing ecosystem.</p><p>3. <strong>Flexibility in Infrastructure:</strong> <br> <br><strong>Custom Infrastructure: </strong>Organizations may have specialized infrastructure needs, such as bare-metal servers or on-premises data centers, that are better suited to certain workloads or compliance requirements. <br><strong>Tailored Solutions: </strong>With a hybrid approach, enterprises may tailor their infrastructure to meet specific performance, security, and regulatory needs while still benefiting from Azure AutoML’s advanced features.</p><p>4. <strong>Best of Two Worlds: </strong><br> <br><strong>Azure AutoML Integration:</strong> Organizations may use Azure AutoML to train and develop models, taking advantage of its advanced capabilities. <br><strong>On-Premises Deployment:</strong> By deploying models on-premises or on custom servers, enterprises can maintain control over their infrastructure while also leveraging Azure AutoML’s model development and optimization capabilities.</p><p>5. <strong>Data sovereignty and compliance: </strong><br> <br><strong>Compliance Requirements: </strong>Certain businesses or locations have strict data sovereignty and compliance rules that require the deployment of AI models within certain geographical boundaries or on-premises infrastructure. <br><strong>Mitigated concerns: </strong>By keeping sensitive data within their own infrastructure while employing Azure AutoML for model building and management, enterprises can reduce data privacy and compliance concerns.</p><p>6.<strong> Performance and latency considerations: </strong><br> <br><strong>Low Latency Requirements:</strong> For applications that require low latency, putting AI models on-premises or closer to the data source can help reduce latency and improve overall performance. <br><strong>High Throughput: </strong>By putting models on custom servers with high-throughput capabilities, companies may efficiently manage massive amounts of data while maintaining optimal performance for real-time inference.</p><p>7. <strong>Hybrid Cloud Strategy: </strong><br> <br><strong>Strategic Flexibility:</strong> A hybrid cloud strategy enables enterprises to balance the benefits of cloud scalability and innovation with the management and security of on-premises infrastructure, resulting in greater flexibility and agility when deploying AI solutions.</p><h3>Architecture</h3><p>Before diving into a hybrid architecture, it’s critical to understand the fundamental structure of Microsoft Azure Machine Learning. The Compute instance is at the heart of Azure Machine Learning, serving as a single center for functions like executing codes, scripts, and instructions to manage data, compute clusters, registries, and deployments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*58xU1sN24NCdfEjkuriu3A.jpeg" /><figcaption>Architecture for Microsoft Azure Machine Learning</figcaption></figure><p>Data is originally saved in a persistent store. We can obtain data from this store using a variety of techniques, including cloud flows, SQL, manual processes, and URLs, resulting in datasets. These datasets give an extra layer of abstraction and metadata to raw data, allowing machines to comprehend connection setups, data types, source formats, headers, and more. Complex processes and heavy lifting operations like data preprocessing and training are carried out within the compute cluster, utilizing its powerful GPU/CPU resources. Given the vast number of techniques, experiments, models, algorithms, artifacts, and versions, it is critical to keep a versioned repository. As a result, a model registry is used to store important models along with their codes, scripts, artifacts, and versions.</p><p>To provide platform independence and unique shipment across several Azure services; the AI model, Azure-managed code, scripts, versions, and runtime environments are all encapsulated in a container registry. This allows for smoother deployment operations. Finally, AI models are deployed to Azure’s managed services, such as Azure Kubernetes Service (AKS), Azure Container Instances (ACI), Azure IoT Edge, Azure Functions, and web service endpoints. Applications use these endpoints to retrieve results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jeaNeZMfcIqD2ImYNeGSjQ.jpeg" /><figcaption>Hybrid architecture</figcaption></figure><p>Alternatively, our hybrid technique replicates the deployment of an AI model using Flask, Gunicorn, and Nginx. <strong>The major distinction is customizing the runtime environment to handle the many abstract layers included in the Azure AutoML model and running our code including those abstract layers.</strong></p><p>To deploy a machine learning model with Flask, Gunicorn, and Nginx, we first create a Flask application to serve our model predictions. Flask is a lightweight Python web framework that is perfect for creating web applications. We will create routes in your Flask application to handle incoming requests and return predictions created by your machine learning model. To serve our Flask application, we’ll use Gunicorn, a Python WSGI HTTP server. Gunicorn efficiently manages several concurrent requests, ensuring that your application’s traffic flows smoothly.</p><p>Finally, Nginx, a high-performance web server and reverse proxy, can be used to direct incoming traffic to Gunicorn. Nginx also includes load balancing, caching, and security upgrades, making it a good option for building production-grade server. We may build a strong and scalable deployment strategy for our machine learning models by combining Flask for application logic, Gunicorn for processing Python web requests, and Nginx for efficient routing and scalability.</p><h4>To keep the main topic simple and easy to understand, we have opted not to incorporate pipelines, automation, or other advanced features in this tutorial. Additionally, we provide minimum runnable code snippets to facilitate quick implementation and understanding. Our server is running with Linux (ubuntu 20.04) and we also prefer that the code is shipped with it”s runtime environment like containerization.</h4><h4>Experimental Lab Setup</h4><p>We assume you already setup your Microsoft Azure Machine Learning Studio. We suggest <a href="https://learn.microsoft.com/en-us/credentials/certifications/azure-data-scientist/?practice-assessment-type=certification">Microsoft Certified: Azure Data Scientist Associate course</a> and <a href="https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/dp-100">Study guide for Exam DP-100</a> for the people who do not setup Microsoft Azure Machine Learning Studio.</p><p>To clone the repository, run this command from your compute instance command line.</p><pre>git clone https://github.com/Ta-SeenJunaid/Azure-AutoML-Custom-Deployment.git </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ng1Z4jaTwfzEqKZc-Aqlg.png" /><figcaption>Cloning the code repository</figcaption></figure><p>Refresh your directory to visualize the change.</p><h4>Data Pre Processing &amp; Training a classification model with Automated Machine Learning</h4><p>Go to Azure-AutoML-Custom-Deployment folder and run ‘Classification with Automated Machine Learning.ipynb’. Code, explanation and instruction for Azure AutoML is in that file. Running the code is the same<br>standard process as running IPython Notebook. The IPython Notebook is now known as the Jupyter Notebook. It is an interactive computational environment, in which you can combine code execution, rich text, mathematics, plots and rich media.</p><h4>Download the Best Model and Related Artifacts</h4><p>Go to Azure-AutoML-Custom-Deployment folder and run ‘Download the Best Model and Related Artifacts.ipynb’. Code, explanation and instruction are given in that file. After running this file, go to the directory Azure-AutoML-Custom-Deployment/artifact_downloads/outputs. Make sure you reload the directory. You’ll find our AI model stored as a pickle file titled model.pkl. You’ll also find the scoring script and the Conda environment file. <strong>The scoring script is important since it offers instructions for using the model within code, whereas the conda environment file is required to set up the runtime environment.</strong></p><h4>Transfer the Code into Your Server</h4><p>Transfer cloud local folder to a remote server through SSH, you can use the scp (secure copy) command. We recommend to transfer the whole Azure-AutoML-Custom-Deployment directory to the remote server.</p><p>Here’s the command using SSH key authentication:</p><pre>scp -i /path/to/your/key.pem -r /path/to/local/folder username@remote_host:/path/to/destination/folder</pre><p>And here’s an alternative command using username and password authentication:</p><pre>scp -r /path/to/local/folder username@remote_host:/path/to/destination/folder</pre><p>Put the value according to your setup.</p><p>For me, the command is:</p><pre>scp -r /home/azureuser/cloudfiles/code/Users/taseen.junaid/Azure-AutoML-Custom-Deployment tj@20.79.154.74:/home/tj</pre><p><strong>From now, we do not have any further interaction with Azure Machine Learning.</strong></p><h4>SSH to your server</h4><p>SSH, also known as Secure Shell or Secure Socket Shell, is a network protocol that gives users, particularly system administrators, a secure way to access a computer over an unsecured network. Here’s the command using SSH key authentication:</p><pre>ssh -i /path/to/private_key.pem username@remote_host</pre><p>Here’s an alternative command using username and password authentication:</p><pre>ssh username@remote_host</pre><p>Put the value according to your setup.</p><p>For us the command is:</p><pre>ssh tj@20.79.154.74</pre><p>After that we will find your project folder into your remote server through ls command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*EifDzWOiKrE6EMouVSlTWw.png" /><figcaption>Remote server through SSH</figcaption></figure><p>When “tj@tj” appears in the terminal, it signifies that the command is being executed on our remote server.</p><h4>Setting up the Runtime Environment</h4><p>We are using the conda environment because the Azure AutoML model is created with conda. To install miniconda into your server we <a href="https://docs.anaconda.com/free/miniconda/">recommended to follow their official installation guide</a>.</p><p>Here are the commands we use:</p><pre>mkdir -p ~/miniconda3<br>wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh<br>bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3<br>rm -rf ~/miniconda3/miniconda.sh</pre><p>After installing, initialize your newly-installed Miniconda. The following commands initialize for bash.</p><pre>~/miniconda3/bin/conda init bash</pre><p>See ‘conda init — help’ for more information and options.</p><p>Reload bashrc with follwoing command “source ~/.bashrc” if necessary.</p><p>Go to project directory.</p><pre>cd Azure-AutoML-Custom-Deployment/</pre><p>After that create conda environment by using conda.yaml file.</p><pre>conda env create -f conda.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*bMZRkkNj47VDelgtIqTI3w.png" /><figcaption>Conda environment creation</figcaption></figure><p>Finally activate the conda environment named as ‘conda-env’ with following command:</p><pre>conda activate conda-env</pre><p>Run app.py code locally to see it is working properly with the environment.</p><pre>python3 app.py  </pre><p>Invoke the local endpoint with curl to see it is working properly.</p><pre>curl -X POST http://localhost:5000/prediction -H &#39;Content-Type: application/json&#39; -d &#39;{&quot;PatientID&quot;: 1020531, &quot;Pregnancies&quot;: 3, &quot;PlasmaGlucose&quot;: 125, &quot;DiastolicBloodPressure&quot;: 82, &quot;TricepsThickness&quot;: 23, &quot;SerumInsulin&quot;: 112, &quot;BMI&quot;: 34.95472243, &quot;DiabetesPedigree&quot;: 0.204847272, &quot;Age&quot;: 46}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SsQaDiIphVySljPbyeeAlg.png" /><figcaption>Activating conda environment, running app.py and tested it with curl</figcaption></figure><p>Now close the local server by pressing ctrl+c into terminal.</p><h4>Gunicorn WSGI (Web Server Gateway Interface) Setup</h4><p>Gunicorn, or “Green Unicorn,” is a popular WSGI HTTP server for Python web applications. Python web applications, such as Flask, Django, and Pyramid, are typically deployed using this method. Gunicorn is a popular reverse proxy that works well with Nginx or other web servers due to its simplicity, reliability, and performance. Its rapid handling of multiple concurrent requests makes it a popular choice for deploying production-grade web applications.</p><p>We now instruct the Gunicorn server on how to connect with the application via wsgi.py code, which imports the Flask instance from our application. Before proceeding, ensure that Gunicorn can serve the application correctly. We can accomplish this by specifying the name of the application’s entry point. This is made up of the module name (without the .py extension) and the name of the application’s callable. In this case, it’s wsgi:app. Specify the interface and port to bind to with the 0.0.0.0:5000 option so that we can test the application.</p><pre>gunicorn --bind 0.0.0.0:5000 wsgi:app</pre><p>Invoke the local endpoint with curl to see it is working properly.</p><pre>curl -X POST http://0.0.0.0:5000/prediction -H &#39;Content-Type: application/json&#39; -d &#39;{&quot;PatientID&quot;: 1020531, &quot;Pregnancies&quot;: 3, &quot;PlasmaGlucose&quot;: 125, &quot;DiastolicBloodPressure&quot;: 82, &quot;TricepsThickness&quot;: 23, &quot;SerumInsulin&quot;: 112, &quot;BMI&quot;: 34.95472243, &quot;DiabetesPedigree&quot;: 0.204847272, &quot;Age&quot;: 46}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qa6MZPSVREuhijTxUBTarw.png" /><figcaption>Gunicorn is working properly and tested it with curl</figcaption></figure><p>Now close the local server by pressing ctrl+c into terminal. Deactivate the conda environment with following command:</p><pre>conda deactivate</pre><p>Next, create a systemd service unit file. Creating a systemd unit file enables Ubuntu’s init system to automatically restart Gunicorn and serve the Flask application upon server boot. <br>Create a unit file ending in .service within the /etc/systemd/system directory:</p><pre>sudo nano /etc/systemd/system/automl_deployment.service</pre><p>Put <strong>similar </strong>content inside this file, change the content according to your setup:</p><pre>[Unit]<br>Description=Gunicorn instance to serve automl_deployment<br>After=network.target<br><br>[Service]<br>User=tj<br>Group=www-data<br>WorkingDirectory=/home/tj/Azure-AutoML-Custom-Deployment<br>Environment=&quot;PATH=/home/tj/miniconda3/envs/conda-env/bin&quot;<br>ExecStart=/home/tj/miniconda3/envs/conda-env/bin/gunicorn --workers 3 --bind unix:app_sock.sock -m 007 wsgi:app<br><br>[Install]<br>WantedBy=multi-user.target</pre><p>Let’s break down each section:</p><p>[Unit]</p><ul><li>Description: Provides a description of the service, in this case, it’s a Gunicorn instance to serve an Azure AutoML deployment.</li><li>After: Specifies that this service should start after the network is up.</li></ul><p>[Service]</p><ul><li>User: Specifies the user under which the service will run, in this case, “tj”.</li><li>Group: Specifies the group under which the service will run, typically used for permission settings, in this case, “www-data”.</li><li>WorkingDirectory: Sets the working directory for the service, where it will execute commands.</li><li>Environment: Defines environment variables for the service, setting the PATH variable to include the location of a specific Conda environment.</li><li>ExecStart: Specifies the command to start the service. Here, it’s starting Gunicorn with specific configurations:</li><li>--workers 3: Specifies the number of worker processes Gunicorn should use.</li><li>--bind unix:app_sock.sock: Binds Gunicorn to a Unix socket file named &quot;app_sock.sock&quot;.</li><li>-m 007: Sets the file permissions for the socket file to 007.</li><li>wsgi:app: Specifies the entry point for the WSGI application, which typically resides in a file named &quot;wsgi.py&quot;.</li></ul><p>[Install]</p><ul><li>WantedBy: Specifies the target multi-user environment where this service should be enabled.</li></ul><p>After that run the following commands and check the status.</p><pre>sudo systemctl daemon-reload<br>sudo systemctl start automl_deployment<br>sudo systemctl enable automl_deployment</pre><pre>sudo systemctl status automl_deployment</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_fuBJosCbxidApgm3G4Qw.png" /><figcaption>Service is running properly</figcaption></figure><p>Give this command according to your setup.</p><pre>sudo chmod 775 /home/tj/Azure-AutoML-Custom-Deployment</pre><p>This command gives the owner and the group associated with the directory /home/tj/Azure-AutoML-Custom-Deployment full permissions (read, write, and execute), while granting read and execute permissions to all other users.</p><p><strong>If you want to access your Gunicorn server directly from outside without using Nginx, you can modify your systemd service file accordingly. You only need to change ExecStart line like following “ExecStart=/home/tj/miniconda3/envs/conda-env/bin/gunicorn — workers 3 — bind 0.0.0.0:5000 -m 007 wsgi:app”. If your Firewall is open for port 5000 you can use the API directly likewise following curl API call “ curl -X POST </strong><a href="http://0.0.0.0:5000/prediction"><strong>http://your_ip:5000/prediction</strong></a><strong> -H ‘Content-Type: application/json’ -d ‘{“PatientID”: 1020531, “Pregnancies”: 3, “PlasmaGlucose”: 125, “DiastolicBloodPressure”: 82, “TricepsThickness”: 23, “SerumInsulin”: 112, “BMI”: 34.95472243, “DiabetesPedigree”: 0.204847272, “Age”: 46}’</strong></p><p><strong>”</strong></p><h4>Nginx Reverse Proxy Server Setup</h4><p>Nginx is a high-performance, open-source web server. It excels at managing concurrent connections and providing fast static content delivery. Nginx is commonly used as a reverse proxy, load balancer, and HTTP cache. This technology is commonly utilized in commercial situations to enhance web application performance, dependability, and security. Nginx’s lightweight design, scalability, and flexibility make it a popular choice for hosting websites and online applications.</p><p>1st we have to install Nginx with following command:</p><pre>sudo apt update<br>sudo apt install nginx</pre><p>After that we have to adjust the Firewall. To see the application that ufw knows run this command and you will see Nginx.</p><pre>sudo ufw app list</pre><p>‘Nginx Full’ will open both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic) for communication. Run the following command to enable this:</p><pre>sudo ufw allow &#39;Nginx FULL&#39;<br>sudo ufw allow ssh</pre><p>If your Firewall is not enabled, you can enable this with:</p><pre>sudo ufw enable</pre><p>Verify the ufw status with following command:</p><pre>sudo ufw status</pre><p>To check that the service related to Nginx is running properly, run the following command:</p><pre>systemctl status nginx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O7Wx9ZKOr6NQkEGWH5rkgg.png" /><figcaption>Firewall setup and Nginx status</figcaption></figure><p>If you visit <a href="http://your_server_ip/">http://your_server_ip</a> (like <a href="http://20.79.154.74/">http://20.79.154.74</a>)you will see Nginx default landing page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fkgw2dcP7t2LzJ2UAWhpjg.png" /><figcaption>Nginx default page</figcaption></figure><p>Now we have to create a server block for our application beside the default landing page. Navigate to the Nginx configuration directory, usually located at /etc/nginx/sites-available/. Create a new configuration file for your API, we named it automl_deployment.</p><pre>sudo nano /etc/nginx/sites-available/automl_deployment</pre><p>Put following content, edit it <strong>according to your configuration:</strong></p><pre>server {<br>    listen 80;<br>    server_name taseenjunaid.com www.taseenjunaid.com;<br><br>    location /prediction{<br>        include proxy_params;<br>        proxy_pass http://unix:/home/tj/Azure-AutoML-Custom-Deployment/app_sock.sock;<br>    }<br>}</pre><p>Explanation of the configuration:</p><ul><li>server: This block defines a virtual server in Nginx.</li><li>listen 80;: Specifies that Nginx should listen for incoming connections on port 80, the default port for HTTP traffic.</li><li>server_name taseenjunaid.com www.taseenjunaid.com;: Specifies the domain names for which this server block will be used. Requests coming to taseenjunaid.com or www.taseenjunaid.com will be handled by this server block.</li><li>location /prediction { ... }: This block defines how Nginx should handle requests that match the specified location pattern, in this case, requests with a URI starting with /prediction which we implemented at app.py code.</li><li>include proxy_params;: Includes additional configuration parameters for the proxy. This is typically used to ensure that certain headers and settings are passed along correctly.</li><li>proxy_pass http://unix:/home/tj/Azure-AutoML-Custom-Deployment/app_sock.sock;: Specifies that incoming requests should be proxied to the Unix socket located at /home/tj/Azure-AutoML-Custom-Deployment/app_sock.sock. This directive tells Nginx to forward requests to the specified upstream server. Here, it’s using a Unix socket (unix:) instead of a traditional IP address and port combination. Unix sockets are a method of inter-process communication (IPC) used for communication between processes on the same host. In this case, it’s pointing to the Unix socket file /home/tj/Azure-AutoML-Custom-Deployment/app_sock.sock, where your Gunicorn server is listening for requests.</li></ul><p>So, when a request comes in for a URI starting with /prediction, Nginx will pass that request to the upstream server defined by proxy_pass, which in turn will forward it to your Gunicorn server via the specified Unix socket file.</p><p>Next we have to enable this server block. We need to create a symbolic link to it in the sites-enabled directory to enable it:</p><pre>sudo ln -s /etc/nginx/sites-available/automl_deployment /etc/nginx/sites-enabled/</pre><p>Before you restart Nginx, it’s a good idea to test your configuration file for syntax errors:</p><pre>sudo nginx -t</pre><p>If the test is successful, restart Nginx to apply the changes:</p><pre>sudo systemctl restart nginx</pre><p>Now your reverse proxy server is up and running and you can test it with following curl command.</p><pre>curl -X POST http://taseenjunaid.com/prediction -H &#39;Content-Type: application/json&#39; -d &#39;{&quot;PatientID&quot;: 1020531, &quot;Pregnancies&quot;: 3, &quot;PlasmaGlucose&quot;: 125, &quot;DiastolicBloodPressure&quot;: 82, &quot;TricepsThickness&quot;: 23, &quot;SerumInsulin&quot;: 112, &quot;BMI&quot;: 34.95472243, &quot;DiabetesPedigree&quot;: 0.204847272, &quot;Age&quot;: 46}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wtInuWUN1cnD8KwDQTEsnw.png" /><figcaption>Invoking reverse proxy server without SSL</figcaption></figure><p>If you face any issue, you can check the error log.</p><pre>sudo tail /var/log/nginx/error.log</pre><p>If you get ‘502 Bad Gateway’ error, it’s a permission denied issue when it try to access the socket file. You can fix it with following command, change it according to your settings:</p><pre>sudo chmod 775 /home/tj/</pre><p>Now If you want you can secure your API through SSL. Because it encrypts data transferred between users’ browsers and web servers, SSL (Secure Sockets Layer) is essential for safeguarding online communication because it prevents illegal access and tampering. It guarantees privacy, authenticity, and data integrity — all of which are essential for safeguarding private data like credit card numbers and login credentials. By confirming the legitimacy of websites, SSL certificates from reliable sources promote user confidence and counter phishing efforts. SSL also improves search engine rankings and aids with an organization’s compliance with PCI DSS and other regulatory standards. All things considered, SSL is essential for preserving compliance, building trust, and protecting data in the digital sphere.</p><p>If you do not have SSL certificate, you can use OpenSSL to generate a self-signed SSL certificate and key:</p><pre>sudo mkdir -p /etc/nginx/ssl/</pre><pre>sudo openssl req -x509 -nodes -newkey rsa:4096 -keyout /etc/nginx/ssl/self.key -out /etc/nginx/ssl/self.crt -days 365</pre><p>Ensure that the SSL certificate and key files are readable by the Nginx user (www-data in this case). Run:</p><pre>sudo chown root:www-data /etc/nginx/ssl/self.crt<br>sudo chown root:www-data /etc/nginx/ssl/self.key<br>sudo chmod 775 /etc/nginx/ssl/self.crt<br>sudo chmod 775 /etc/nginx/ssl/self.key</pre><p>Edit etc/nginx/sites-available/automl_deployment according to your configuration.</p><pre>sudo nano /etc/nginx/sites-available/automl_deployment</pre><p>Put following content according to your configuration.</p><pre>server {<br>    listen 80;<br>    server_name taseenjunaid.com www.taseenjunaid.com;<br>    return 301 https://$server_name$request_uri;<br>}<br><br>server {<br>    listen 443 ssl;<br>    server_name taseenjunaid.com www.taseenjunaid.com;<br><br>    ssl_certificate /etc/nginx/ssl/self.crt;<br>    ssl_certificate_key /etc/nginx/ssl/self.key;<br><br>    location /prediction {<br>        include proxy_params;<br>        proxy_pass http://unix:/home/tj/Azure-AutoML-Custom-Deployment/app_sock.sock;<br>    }<br>}</pre><p>In this configuration:</p><ul><li>The first server block listens on port 80 and handles HTTP requests. It redirects all HTTP traffic to the HTTPS version of your site using a 301 redirect.</li><li>The second server block listens on port 443 and handles HTTPS requests. It serves your site over HTTPS using the SSL certificate and key specified.</li></ul><p>Before you restart Nginx, it’s a good idea to test your configuration file for syntax errors:</p><pre>sudo nginx -t</pre><p>If the test is successful, restart Nginx to apply the changes:</p><pre>sudo systemctl restart nginx</pre><p>Now your reverse proxy server is up and running with SSL and you can test it with following curl command. The -k option is included in the curl command to allow insecure SSL connections, which may be necessary for systems with self-signed certificates, or certificates without root trust or other SSL issues.</p><pre>curl -X POST https://taseenjunaid.com/prediction -H &#39;Content-Type: application/json&#39; -d &#39;{&quot;PatientID&quot;: 1020531, &quot;Pregnancies&quot;: 3, &quot;PlasmaGlucose&quot;: 125, &quot;DiastolicBloodPressure&quot;: 82, &quot;TricepsThickness&quot;: 23, &quot;SerumInsulin&quot;: 112, &quot;BMI&quot;: 34.95472243, &quot;DiabetesPedigree&quot;: 0.204847272, &quot;Age&quot;: 46}&#39; -k</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hSEgAONBO8_Z9QVBtWJbSg.png" /><figcaption>Invoking reverse proxy server with SSL</figcaption></figure><p>Now It’s time for you to add authentication, incorporate pipelines, automation, containerization or other advanced features related to your setup.</p><p>We hope this tutorial is helpful for you, we are looking for your valuable feedback. We appreciate you taking the time to read our writing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f35ba44f31cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperledger Iroha (Blockchain Framework) Tutorial with Multi Signature & Decentralized Exchange in…]]></title>
            <link>https://taseen-junaid.medium.com/hyperledger-iroha-blockchain-framework-tutorial-with-multi-signature-decentralized-exchange-in-5e8786572381?source=rss-909447499163------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e8786572381</guid>
            <category><![CDATA[cross-border-currency]]></category>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[hyperledger-iroha]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Ta-seen Junaid]]></dc:creator>
            <pubDate>Sun, 26 Dec 2021 11:24:43 GMT</pubDate>
            <atom:updated>2021-12-26T11:24:43.125Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hyperledger Iroha (Blockchain Framework) Tutorial with Multi Signature &amp; Decentralized Exchange in Multi Peers Set-up (Part 2)</h3><h4>Cross Border Asset/Currency Transfer with Enterprise Blockchain.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IydedV58xQ1XtffHj-4rpg.jpeg" /></figure><p>In this blog we try to explain Hyperledger Iroha’s two great features which are multi signature and decentralized exchange which will help us to develop a trustworthy decentralized finance system. This blog is the second part of our series named as “Hyperledger Iroha (Blockchain Framework) Tutorial with Multi Signature &amp; Decentralized Exchange in Multi Peers Set-up”. To understand all the concept properly and to deploy the demo code, you have to follow the <a href="https://taseen-junaid.medium.com/hyperledger-iroha-blockchain-framework-tutorial-with-multi-signature-decentralized-exchanged-in-a24a6f13e5bb">part 1</a> of this series. The link of part 1 is given below:</p><p><a href="https://taseen-junaid.medium.com/hyperledger-iroha-blockchain-framework-tutorial-with-multi-signature-decentralized-exchanged-in-a24a6f13e5bb">Hyperledger Iroha (Blockchain Framework) Tutorial with Multi Signature &amp; Decentralized Exchange in…</a></p><h3>Decentralized Exchange</h3><p>Decentralized exchange is one of the most promising features of Hyperledger Iroha which will solve many of today’s real world problems. Decentralized exchange provides an ability to transfer assets between accounts in exchange for other assets. An example will be buyer &amp; asset seller will agree into a shared agreement where asset ownership will transfer from seller to buyer accounts where token ownership will transfer from buyer to seller accounts automatically.</p><p>In a traditional system there will always be trust issues with this kind of business exchange like the seller may take the money and don’t provide the asset or the buyer may take the asset but not pay the bill. Iroha brings trust into this type of scenario where transactions will be successfully committed from both sides simultaneously.</p><p>In practice, this decentralized exchange may play a bigger role in opening a market of true decentralization by giving an asset its true value. We can take an example of cross border currency exchange. The way we choose the exchange rate between two currencies is not a totally decentralized system, moreover some big players always win in this exchange system instead of a currency’s true value. In the Iroha system, it will give the user a true power to fix the exchange rate according to that currency’s true value. We will see a real example of this in the hands-on demo section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-msVXbMnnsJZD6OUqfajA.jpeg" /><figcaption>Decentralized Exchange Example</figcaption></figure><p>Now less discuss about Iroha’s <a href="https://iroha.readthedocs.io/en/main/develop/cases.html#cross-border-asset-transfers">decentralized exchange</a> and how we can implement the system.</p><h4>Hands-on Demo</h4><p>From projects root directory, run the following command to clear the previous setup:</p><pre>bash network.sh down</pre><p>From projects root directory, run the following command to start the network:</p><pre>bash network.sh up</pre><p>You can also change the start up timing according to your machine by modifying the ‘network.sh’ file.</p><p>From projects root directory, run the following command for decentralized-exchanged example:</p><pre>python3 python_sdk/decentralized-exchanged.py</pre><h4>Explanation</h4><p>At first we have to initialize our peers/nodes with respective IP addresses and corresponding ports and after that we have to feed those values into ‘IrohaGrpc’.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c9344eec9171a3fd574947cee536f44/href">https://medium.com/media/3c9344eec9171a3fd574947cee536f44/href</a></iframe><p>Here we have one admin and two users where each account holder will recreate/create their cryptographic keys. In the real scenario, each account holder will use their own wallet to sign transactions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/767d97431e6d98fd93910c2c985af396/href">https://medium.com/media/767d97431e6d98fd93910c2c985af396/href</a></iframe><p>Now it is time for the admin to initialize some transactions so that other users can perform their operations. Here admin performs 8 initialization operations and those are:</p><ol><li>Admin creates ‘scoin’ asset at ‘test’ domain with precision=2</li><li>Admin creates ‘ncoin’ asset at ‘test’ domain with precision=2</li><li>Admin adds ‘10000’ ammount of scoin asset where asset id is ‘scoin#test’</li><li>Admin adds ‘20000’ ammount of ncoin asset where asset id is ‘ncoin#test’</li><li>Admin creates new account where account_name= ‘satoshi’, domain_id= ‘test’ with account holder public key</li><li>Admin creates new account where account_name= ‘nakamoto’, domain_id= ‘test’ with account holder public key</li><li>Admin transfers ‘10000’ amount of ‘scoin’ from admin’s account to ‘satoshi’ account</li><li>Admin transfers ‘20000’ amount of ‘ncoin’ from admin’s account to ‘nakamoto’ account</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3932f13731500163276d20c4a27f01dd/href">https://medium.com/media/3932f13731500163276d20c4a27f01dd/href</a></iframe><p>In Iroha, we can send several transactions at once as a batch which is known as <a href="https://iroha.readthedocs.io/en/main/concepts_architecture/glossary.html#batch-of-transactions">Batch of transactions</a>. There are 2 types of batch named as <a href="https://iroha.readthedocs.io/en/main/concepts_architecture/glossary.html#atomic-batch">Atomic batch</a> and <a href="https://iroha.readthedocs.io/en/main/concepts_architecture/glossary.html#ordered-batch">Ordered batch</a>. An atomic batch will only work if all the transactions within the batch are signed by its authority and all the transactions will pass the verification process. In Iroha system, one party needs to create an atomic exchange branch by fixing the exchange rate and transferable amount where to complete the transactions, the atomic exchange branch needs the consensus from both parties.</p><p>In our case, Satoshi creates a decentralized atomic exchange branch by initializing two transactions. In one transaction, ‘100’ amount of ‘scoin’ will be transferred from ‘satoshi’ account to ‘nakamoto’ account where in other transaction ‘200’ amount of ‘ncoin’ will be transferred from ‘nakamoto’ account to ‘satoshi’ account. Here Satoshi indirectly initializes an exchange rate which means 1 ‘scoin’ is equivalent to 2 ‘ncoin’. After the creation of the exchange batch, Satoshi gives his consent by signing his part of the transaction where ‘100’ amount of ‘scoin’ will be transferred from ‘satoshi’ account to ‘nakamoto’ account. Finally Satoshi sends the atomic batch of transactions to Iroha Peer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c3ce88aa65232d79286c37919ef212b/href">https://medium.com/media/2c3ce88aa65232d79286c37919ef212b/href</a></iframe><p>Now it is time for Nakomoto to accept the atomic batch of transactions. Nakamoto can find pending transactions from peer or Satoshi may pass that via a messaging channel (Like the example of multi signature). Transactions that do not receive the required number of signatures will be considered as <a href="https://iroha.readthedocs.io/en/main/concepts_architecture/glossary.html#pending-transactions">pending transactions</a> where the Iroha system will trigger a transaction automatically when the transaction will collect the required number of signatures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_kFIxXcdX-LIzzTMgsXjLA.jpeg" /><figcaption>Iroha Decentralized Exchange</figcaption></figure><p>Here Nakamoto is querying pending transactions from peer with his valid credentials. The atomic batch of transactions, which was previously created by Satoshi are now in pending state as those got Satoshi’s signature for transferring of ‘100’ amount of ‘scoin’ from ‘satoshi’ account to ‘nakamoto’ account but do not get Nakamoto’s signature for transferring of ‘200’ amount of ‘ncoin’ from ‘nakamoto’ account to ‘satoshi’ account. This atomic batch of pending transactions that Nakamoto fetched from peer, already got Satoshi’s signature and only needed Nakamoto’s signature and so Nakamoto will delete Satoshi’s signature and will sign only his transaction with his private key. Finally Nakamoto sends the atomic batch of transactions to Iroha Peer. Now this atomic exchange batch of transactions receives all the required consensus and this batch will commit transactional changes into leger by Iroha automatic triggering system if it passes other verification processes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc0154625fff41c37b223b657af157c4/href">https://medium.com/media/bc0154625fff41c37b223b657af157c4/href</a></iframe><h3>Multi Signature Transactions</h3><p>Multi Signature Transactions is one of the best key features of Hyperledger Iroha Blockchain framework. With this feature we can manage our funds, deeds, agreement, assets etc by a decentralized authorization system. Decentralized authorization system lets several people from the same business complete a third-party asset transfer by taking the consensus from required number authorities.</p><p>A <a href="https://iroha.readthedocs.io/en/develop/develop/cases.html#fund-management">use case scenario</a> will be a fund assets that is held at one account which is managed by multiple managers who are dealing with investments and portfolio distributions. Every manager will act as a role of a <a href="https://iroha.readthedocs.io/en/main/concepts_architecture/glossary.html#signatory">signatory</a> who can sign the transactions to give his/her consensus. Here Iroha uses a term named ‘<a href="https://iroha.readthedocs.io/en/main/concepts_architecture/glossary.html#quorum">Quorum</a>’ which means a minimum number of signatures required to consider a transaction signed. Here one manager may confirm a deal by sending the original transaction and others managers’ then sign that transaction where Iroha will maintain the transaction sending so that the deal will not be completed until it receives the required number of confirmation, which is parametrized with the transaction quorum parameter. Transactions that do not receive the required number of signatures will be considered as <a href="https://iroha.readthedocs.io/en/main/concepts_architecture/glossary.html#pending-transactions">pending transactions</a> where the Iroha system will trigger a transaction automatically when the transaction will collect the required number of signatures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A-aJjjFOdL8Fa3lXahCigw.jpeg" /><figcaption>Multi Signature Transactions</figcaption></figure><h4>Hands-on Demo</h4><p>From projects root directory, run the following command to clear the previous setup:</p><pre>bash network.sh down</pre><p>From projects root directory, run the following command to start the network:</p><pre>bash network.sh up</pre><p>You can also change the start up timing according to your machine by modifying the ‘network.sh’ file.</p><p>From projects root directory, run the following command for multi-signature example:</p><pre>python3 python_sdk/multi-signature.py</pre><h4>Explanation</h4><p>At first we have to initialize our peers/nodes with respective IP addresses and corresponding ports and after that we have to feed those values into ‘IrohaGrpc’.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da5b9f559f9cc9d946deefd30ef96ac4/href">https://medium.com/media/da5b9f559f9cc9d946deefd30ef96ac4/href</a></iframe><p>Here we have one admin and three users where each account holder will recreate/create their cryptographic keys. In the real scenario, each account holder will use their own wallet to sign transactions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/686a4f9df6649a3639720c8cd1a68b45/href">https://medium.com/media/686a4f9df6649a3639720c8cd1a68b45/href</a></iframe><p>Now it is time for the admin to initialize some transactions so that other users can perform their operations. Here admin performs 5 initialization operations and those are:</p><p>1. Admin creates ‘scoin’ asset at ‘test’ domain with precision=2</p><p>2. Admin adds ‘10000’ amount of scoin asset where asset id is ‘scoin#test’</p><p>3. Admin creates new account where account_name= ‘satoshi’, domain_id= ‘test’ with account holder public key</p><p>4. Admin creates new account where account_name= ‘nakamoto’, domain_id= ‘test’ with account holder public key</p><p>5. Admin transfers ‘10000’ amount of ‘scoin’ from admin’s account to ‘satoshi’ account</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53a21e888f6e39283f95c311f972921d/href">https://medium.com/media/53a21e888f6e39283f95c311f972921d/href</a></iframe><p>For multi signature transactions we have to add keys for signatory and set quorum. Signatory represents an entity that can confirm multi signature transactions (MST) for an account. Quorum number is a minimum amount of signatures required to consider a transaction signed. So our Satoshi_1 adds a new signatory with Satoshi_2’s public key and sets quorum number 2.<br>As our quorum number is 2, so from now any transaction from account_id=’satoshi@test’ needs at least 2 signatorys’ signatures (Signature with Satoshi_1’s private key &amp; Signature with Satoshi_2’s private key) to consider as a valid transaction in Hyperledger Iroha.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b18096ecdea4fc018b689cbf60bdabb/href">https://medium.com/media/0b18096ecdea4fc018b689cbf60bdabb/href</a></iframe><p>To perform a multi signature transaction, a signatory has to initiate the transaction. Here Satoshi_1 initiates that ‘10’ amount of ‘scoin’ will be transferred from ‘satoshi’ account to ‘nakamoto’ account. After that Satoshi_1 signs the transaction with it’s private key and then Satoshi_1 can send the signed transaction into Iroha peer or can give it to other signatories and in this scenario, Satoshi_1 gives it to another signatory named as Satoshi_2. So Satoshi_2 can find pending transactions from peer if Satoshi_1 sent that on peer (Like the example of decentralized exchanged) or Satoshi_1 may pass that via a messaging channel to Satoshi_2. Finally Satoshi_2 signs the transaction with it’s private key and sends the transaction to Iroha Peer. The transaction will be completed and committed into ledgers on successful verification performed by Iroha system.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b321e4108a9832fcaa4150348bbd50b5/href">https://medium.com/media/b321e4108a9832fcaa4150348bbd50b5/href</a></iframe><h3>Summary</h3><p>In this blog we try to explain Hyperledger Iroha’s two great features which are multi signature and decentralized exchange. This blog is written only for learning purposes and we hope that this blog will be helpful for you and also expect your valuable reviews so that we all can have a chance to learn from you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e8786572381" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperledger Iroha (Blockchain Framework) Tutorial with Multi Signature & Decentralized Exchange in…]]></title>
            <link>https://taseen-junaid.medium.com/hyperledger-iroha-blockchain-framework-tutorial-with-multi-signature-decentralized-exchanged-in-a24a6f13e5bb?source=rss-909447499163------2</link>
            <guid isPermaLink="false">https://medium.com/p/a24a6f13e5bb</guid>
            <category><![CDATA[banking]]></category>
            <category><![CDATA[hyperledger-iroha]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[hyperledger]]></category>
            <dc:creator><![CDATA[Ta-seen Junaid]]></dc:creator>
            <pubDate>Sat, 15 May 2021 02:53:26 GMT</pubDate>
            <atom:updated>2021-12-26T11:27:22.787Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hyperledger Iroha (Blockchain Framework) Tutorial with Multi Signature &amp; Decentralized Exchange in Multi Peers Set-up (Part 1)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BqMBzj2dZ28OLEoRR18HQQ.jpeg" /></figure><h3>Key Features of Iroha Blockchain System</h3><p>In <a href="https://iroha.readthedocs.io/en/main/">Hyperledger Iroha’s official documentation</a>, they mentioned some key features.</p><ul><li>Assets and identity management</li><li>Decentralized finance and decentralized exchange</li><li>Role-based access control, Multi signature transactions</li><li>Available SDK in Python, Java, Javascript, iOS</li><li>Built-in commands for asset management</li><li>No costly mining and low transactions latency</li><li>Clients need interaction with any one of the peers and that peer will proceed other operations</li><li>Private and permissioned network</li></ul><h3>Possible Use Cases</h3><p>Banking, cross border asset management, decentralized finance and decentralized exchange, financial applications, identity management, supply chain, fund management, certificate management, payment systems, central bank digital currencies, inter bank settlement and many more, token management.</p><p><a href="https://iroha.readthedocs.io/en/main/develop/cases.html#use-case-scenarios">Details with examples are also available at documentation</a>.</p><h3>Hyperledger Iroha Network</h3><p>Hyperledger Iroha network consists of distributed <strong>peers</strong>/nodes server where each peer/node has the same identical blockchain which is stored in the database of that peer/node for storing the information and every peer/node maintains the same identical protocol to keep the blockchain running into a secured, distributed and decentralized way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BqMBzj2dZ28OLEoRR18HQQ.jpeg" /><figcaption>Hyperledger Iroha Network</figcaption></figure><p>To achieve reliability into the network involving multiple unreliable nodes, a consensus algorithm is used to achieve agreement on a single data value among distributed processes or systems. To preserve a consistent state among the peers within a distributed, decentralized, private and permissioned network, Iroha uses its own consensus algorithm called <strong>Yet Another Consensus</strong> (aka <strong>YAC</strong>). You can check out a <a href="https://www.youtube.com/watch?v=mzuAbalxOKo">video</a> with a thorough explanation of the principles of consensus and YAC implemented in Iroha.</p><p>Unlike other Hyperledger frameworks, in Hyperledger Iroha clients need interaction with any one of the peers and that peer will proceed other operations with other peers. An Iroha peer has a <strong>Torii</strong> gateway for client to peer communication with the help of gRPC system and has a separate internal port for peer to peer communication.</p><h3>Demo Code Repository Setup</h3><p>We run this demo with Docker and Docker Compose on an Ubuntu machine. To run the python SDK, you also need python3, pip3 and iroha python library. Those are the prerequisite of this demo. Please install the iroha python library with following command:</p><pre>pip3 install iroha==0.0.5.5</pre><p>We assume that you have git install on your machine. Please clone the <a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up">project</a> by using the following command:</p><pre>git clone <a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up.git">https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up.git</a></pre><p>Please go to project’s root directory:</p><pre>cd Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up/</pre><p>For this tutorial, we will use version v1.0.0 and so we have to checkout that version with the following command:</p><pre>git checkout tags/v1.0.0 -b v1.0.0-branch</pre><h3>Short Review on Public Key Cryptography and Digital Signature</h3><p>In the public key cryptographic (asymmetric key cryptographic) system, an entity owns a pair of keys known as a private key and its corresponding public key. The private key is kept private/secret which may never be known by any except the owner where the owner shares the corresponding public key publicly with other participants for encryption-decryption or digital signature verification purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*Ks51WJppHrVigYVLYqL6Lw.jpeg" /><figcaption>Public Key Cryptography</figcaption></figure><p>An entity can cryptographically sign a document with the private key which is known as digital signature. A signature verification function takes this digital signature and the corresponding document as input and with the help of public key, it can cryptographically prove that the document is came from that entity who owns this public key’s corresponding private key and the document is not tampered during transmission time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*1tPuIVvdID-498vs-EP8tQ.jpeg" /><figcaption>Digital Signature</figcaption></figure><p>In this demo, we use Iroha’s special <a href="https://iroha.readthedocs.io/en/main/develop/keys.html#key-pair-format"><strong>Ed25519 with SHA-3</strong></a><strong> </strong>algorithm as our public key cryptography where Hyperledger Ursa provides Iroha with support of standard Ed25519 with SHA-2 algorithm which is also <a href="https://iroha.readthedocs.io/en/main/integrations/index.html#hyperledger-ursa">implementable</a>.</p><p>To generate private-public key-pair, use following command from your projects root folder:</p><pre>python3 python_sdk/key-pair.py</pre><p>This will print our private-public key-pair where we have to save the private key in private and publish the public key with other entities.</p><p>By using the private key we can also regenerate private-public key-pair. An example command is given below where we have to give a private key as argument to regenerate private-public key-pair..</p><pre>python3 python_sdk/key-pair.py --private_key 038783f1bfb934bea80a892d789a53d7d7126c9c60c375ff2259f6fc809b7828</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Vu5dLkDkOfW2QwjopYqrw.png" /><figcaption>Private-public key-pair generation</figcaption></figure><h3>Data Structure with Prebuilt Commands, Queries &amp; Permission in Hyperledger Iroha</h3><p>A <strong>domain</strong> is a named abstraction for grouping accounts and assets where every user (or entity) has its own <strong>account</strong>: <strong>{account_name}@{domain}</strong> like ‘satoshi@test’, ‘nakamoto@test’ and every account can have several types of <strong>assets</strong> on board: <strong>{asset_name}#{domain} </strong>like the account ‘satoshi@test’ may have several asset like ‘bitcoin#test’, ‘dogecoin#test’ with some owned quantity where the account ‘nakamoto@test’ may have no ownership on ‘bitcoin#test’. Every account may have a list of <strong>roles</strong> with corresponding permission. Like a role named as ‘admin’ may have permission to create a new asset where a role named as ‘user’ may not have any permission to create a new asset. So the account ‘nakamoto@test’ with role only ‘user’ may not be able to create a new asset where the account ‘satoshi@test’ with both ‘user’ and ‘admin’ roles may be able to create a new asset. Actually all of those are maintaining an entity-relationship model which can be found in <a href="https://iroha.readthedocs.io/en/main/concepts_architecture/er_model.html#entity-relationship-model">official documentation</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xi2jzNjgQVs0Ic0o8VLj4g.jpeg" /><figcaption>Data structure</figcaption></figure><p>As Hyperledger Iroha is a special purpose framework for asset, identity &amp; supply chain management, it allows users to perform common functions with some prebuilt <a href="https://iroha.readthedocs.io/en/main/develop/api.html#iroha-api-reference"><strong>commands</strong> and <strong>queries</strong></a> which negates the need to write cumbersome and hard to test smart contracts, enabling developers to complete simple tasks faster and reliably with less risk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZydORVBYInNkmAjGP2oG8w.jpeg" /><figcaption>Prebuilt commands</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FUgRwt2Qps9RCKf0X5RUNw.jpeg" /><figcaption>Prebuilt queries</figcaption></figure><h3>Block and Genesis Block with Genesis Transactions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1eqHIdnZ9cvJWGIPz9AWaQ.jpeg" /><figcaption>Block and Genesis Block</figcaption></figure><p>Transaction data is permanently recorded into the data store of every peer, known as <strong>blocks</strong>. Blocks are organized into a linear sequence over time like a chain of blocks as each block is attaching the hash of it’s previous block. A block has several fields and those are:</p><ul><li>Height, a number of blocks in the chain up to the block</li><li>Timestamp, Unix time (in milliseconds) of block forming by a peer</li><li>Array of transactions, which successfully passed validation and consensus step</li><li>Signatures, signatures of peers, which voted for the block during consensus round</li><li>Hash of a previous block in the chain</li><li>Rejected transactions’ hashes</li></ul><p>A <strong>genesis block</strong> is the name given to the first block a chain, which has ‘height = 1’, ‘previous block hash = 0000000000000000000000000000000000000000000000000000000000000000’ and some initialization transactions known as genesis transactions. You can create the genesis block with any of available SDK of you can easily <a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up/blob/v1.0.0/network/node1/genesis.block">write the genesis block</a> as this is human readable file. To initialize genesis transactions into our example “<a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up/blob/v1.0.0/network/node1/genesis.block"><strong>genesis.block</strong></a>” file, we first add each initial peer/node with <strong>address</strong> (network address and internal port) and attach every peer’s public key with it so that our network can automatically verify digital signature for synchronization, consensus, and communication purposes. Then we create different roles like ‘admin’, ‘user’ with their allowed permission (prebuilt commands and queries) list. We also initialize some domains, assets and accounts where we also append different roles on those accounts. We also attach a public key on each account creation time so that we can automatically verify that a transaction is signed by that entity and the transaction is not tampered. Each and every peer must need an identical genesis block to start up it’s operation on same network.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d14e87b6adc21a4f0131a70903b4ead/href">https://medium.com/media/5d14e87b6adc21a4f0131a70903b4ead/href</a></iframe><h3>Setting-up &amp; Deploying Multi Peers Network</h3><p>To deploy the Iroha network, we need to configure <a href="https://iroha.readthedocs.io/en/main/configure/index.html#deployment-specific-parameters"><strong>deployment specific parameters</strong></a> like block store path, torii port, internal port, database etc and <a href="https://iroha.readthedocs.io/en/main/configure/index.html#environment-specific-parameters"><strong>environment specific parameters</strong></a> like maximum proposal size, proposal delay, vote delay etc. The Detailed configuration process for different setup is described in <a href="https://iroha.readthedocs.io/en/main/configure/index.html#configure">official documentation</a> with examples.</p><p>In our multi peers/nodes setup, we have different data volume for different peers like for peer/node 1 we have volume ‘<a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up/tree/v1.0.0/network/node1">node1</a>’, for peer/node 2 we have volume ‘<a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up/tree/v1.0.0/network/node2">node2</a>’, for peer/node 3 we have volume ‘<a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up/tree/v1.0.0/network/node3">node3</a>’ where we store genesis.block file, public and private key of that peer/node for singing purpose, config.docker file for configuration set up for that node/peer.</p><p>Now it’s time to deploy our network where we run this demo with Docker and Docker Compose into an Ubuntu machine and so we have to prepare a <a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up/blob/v1.0.0/network/docker-compose.yaml">docker-compose.yaml</a> file. To create multi peers/nodes into localhost, we have to provide all the peers/nodes IP addresses into the genesis file and to give each node a specific IP address into our localhost, we have to create a docker network with a specific subnet. Details explanation for a network with single peer/node set up will also be available at Iroha’s <a href="https://iroha.readthedocs.io/en/main/getting_started/index.html#quick-start-guide">quick start guide</a>.</p><p>From projects root directory, run the following command to clear the previous setup:</p><pre>bash network.sh down</pre><p>From projects root directory, run the following command to start the network:</p><pre>bash network.sh up</pre><p>You can also change the start up timing according to your machine by modifying the ‘network.sh’ file.</p><h3>Testing Client Libraries AKA SDK</h3><p>Hyperledger Iroha has<a href="https://iroha.readthedocs.io/en/main/develop/libraries.html#client-libraries"> client libraries aka SDK</a> available in Python, Java, Javascript, iOS etc where in this demo we use python SDK. When we create the genesis block, we initialize the ‘admin@test’ and the ‘test@test’ account. Here we will use that ‘admin@test’ account’s credential(public-private key pair) for transactions and for querying the result from different peers/nodes.</p><p>From projects root directory, run the following command for transaction example with python SDK:</p><pre>python3 python_sdk/tx-example.py</pre><h3>Summary of Part 1:</h3><p>In this tutorial we deploy a multi peers/nodes Iroha network and we also discuss some core concepts of Hyperledger Iroha and try to provide some valuable links of different concepts related to Hyperledger Iroha.</p><p>In the next part of this tutorial we will describe some of Hyperledger Iroha’s <strong>awesome features like ‘Multi Signature’, ‘Decentralized Exchange’</strong> <strong>etc where the code for that tutorial is already available at </strong><a href="https://github.com/Ta-SeenJunaid/Hyperledger-Iroha-Tutorial-with-Multi-Signature-and-Decentralized-Exchanged-in-Multi-Node-Set-up/tree/v1.0.0"><strong>github</strong></a>.</p><p>This blog is written only for learning purposes and we hope that this blog will be helpful for you and also expect your valuable reviews so that we all can have a chance to learn from you.</p><p>The link of <a href="https://taseen-junaid.medium.com/hyperledger-iroha-blockchain-framework-tutorial-with-multi-signature-decentralized-exchange-in-5e8786572381">part 2</a> is given below:</p><p><a href="https://taseen-junaid.medium.com/hyperledger-iroha-blockchain-framework-tutorial-with-multi-signature-decentralized-exchange-in-5e8786572381">Hyperledger Iroha (Blockchain Framework) Tutorial with Multi Signature &amp; Decentralized Exchange in…</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a24a6f13e5bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperledger Indy Custom Network with Indy Node & Plenum(Protocol & Ledger)]]></title>
            <link>https://medium.com/coinmonks/hyperledger-indy-custom-network-with-indy-node-plenum-protocol-ledger-85fd10eb5bf5?source=rss-909447499163------2</link>
            <guid isPermaLink="false">https://medium.com/p/85fd10eb5bf5</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[digital-identity]]></category>
            <category><![CDATA[hyperledger-indy]]></category>
            <dc:creator><![CDATA[Ta-seen Junaid]]></dc:creator>
            <pubDate>Sun, 01 Nov 2020 06:54:28 GMT</pubDate>
            <atom:updated>2020-12-28T14:54:11.851Z</atom:updated>
            <content:encoded><![CDATA[<h4>Self Sovereign Identity (SSI) with Blockchain</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OLN6HWQ_qUIskDI8isQsNQ.jpeg" /></figure><p>The popularity of Self Sovereign Identity (SSI) with Blockchain technology is gaining very rapidly where Self Sovereign Identity (SSI) is considered as the future of internet identity and Blockchain technology will be used to build the underlying structures of a proper Self Sovereign Identity (SSI) system. On the other hand Hyperledger Indy provides tools, libraries, and reusable components for providing digital self sovereign identities rooted on blockchains or other distributed ledgers so that they are interoperable across administrative domains, applications, and any other silo. <strong><em>Hyperledger Indy is a developing platform and so far there has no proper tutorial or document for development of a custom Indy network as all other tutorials are based on Indy Test Network. Moreover Indy Sdk is not ready to develop a custom Indy network. So by following this tutorial, anyone can easily build a custom made Hyperledger Indy network as per anyone’s requirements.</em></strong></p><p>To know the necessity of Self Sovereign Identity (SSI), please follow below link:<br><a href="https://medium.com/@taseen.junaid/self-sovereign-identity-ssi-in-blockchain-the-future-of-internet-identity-6deb75607aa">https://medium.com/@taseen.junaid/self-sovereign-identity-ssi-in-blockchain-the-future-of-internet-identity-6deb75607aa</a></p><p><a href="https://medium.com/@taseen.junaid/self-sovereign-identity-ssi-in-blockchain-the-future-of-internet-identity-6deb75607aa">Self Sovereign Identity (SSI) in  Blockchain &amp; The Future of  Internet Identity</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OLN6HWQ_qUIskDI8isQsNQ.jpeg" /><figcaption>Hyperledger Indy Network</figcaption></figure><h3>Indy Node:</h3><p>Each Indy Node works as a distributed server and each node houses ledger to store records.</p><h3>Indy Plenum(Protocol &amp; Ledger):</h3><h4><strong>Ledger</strong></h4><p>Ledger is used to store transactions and each node into a blockchain based distributed system holds the same identical ledger. Currently, Indy Plenum has four types of ledger but plugins can add new ledger too.</p><p><strong>Domain Ledger</strong> is used to store identity and application specific transactions. For example if you need to store stewards,trustees,actors identity or you need to store credential definition, schema definition or even revocation information of a particular credential, you have to use domain ledger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XS_vJEI8EkjnwHwpDRK05A.jpeg" /><figcaption>Different types of Indy Ledger</figcaption></figure><p><strong>Pool ledger</strong> is used to store all node specific transactions so that we can create and manage network pools. It is used to add, edit or remove nodes into a distributed system.</p><p><strong>Config ledger</strong> is used to store configuration related transactions, pool config parameters, transactions validation etc purpose. For example if an authority wants to add a credential definition and needs permission from the majority of stewards, we can store this type of access control options into config ledger.</p><p><strong>Audit ledger</strong> actually works as a blockchain as it holds a global sequence number of all other ledger transactions(Domain, Pool, Config) in a sequential way.</p><h4><strong>Protocol</strong></h4><p>Protocol is the established set of rules that is used to govern our distributed system. Currently Indy uses Redundant Byzantine Fault Tolerance (RBFT) protocol for consensus with a potential plan to move to Aardvark.</p><h3>Public Permissioned Blockchain</h3><p>Hyperledger Indy is called a public permissioned blockchain due to its nature. Everyone can read data from ledger without any permission which is the reason to call it public blockchain. On the other hand, to write data into ledger, you need validation according to a consensus mechanism and so it is also called permissioned blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-9IuGrqNtevMmLerbrmgw.png" /></figure><p>To write something into a ledger, someone not only needs permission, but also needs consensus from a certain percentage of nodes. For example, a network pool is created with 10 nodes, so to write something into a ledger, someone needs consensus from at least 7 (10–3) nodes. The fault tolerance formula is ‘N = (3F + 1 )’ where ’N’ is the total number of nodes and F is the maximum number of malicious nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sen5x0jbW_BDe2LNkOwsmg.jpeg" /><figcaption>Write request</figcaption></figure><p>On the other hand, reading data does not need any permission or consensus and anyone can read data from any random node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_TQx41eVDCYS4sX6SGNzQ.jpeg" /><figcaption>Read request</figcaption></figure><h3>Hands on Tutorial</h3><h4><strong>Prerequisites</strong></h4><p>Hyperledger Indy network can be created by running nodes on different Ubuntu 16.04 machines. As till October, 2020 there is full support for only Ubuntu 16.04 which is also known as Ubuntu <strong>Xenial</strong>. So we have to use Ubuntu Xenial where Docker or Virtual Machine can also be used to make the network.<br>Download the latest version of <a href="https://git-scm.com/downloads"><strong>git</strong></a> if it is not already installed.</p><h4>Presetup</h4><p>Please clone the <a href="https://github.com/Ta-SeenJunaid/Hyperledger-Indy-Tutorial.git">project </a>by using the following command.</p><pre>git clone <a href="https://github.com/Ta-SeenJunaid/Hyperledger-Indy-Tutorial.git">https://github.com/Ta-SeenJunaid/Hyperledger-Indy-Tutorial.git</a></pre><p>For this tutorial, we will use version v1.0.0 and so we have to checkout that version with the following command.</p><pre>git checkout tags/v1.0.0 -b v1.0.0-branch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4AoQfoEJwOMOaog1" /><figcaption>Using tag V1.0.0</figcaption></figure><p>To set up the environment, you have to use the “prerequisites.sh” file. Instead of downloading different Indy components, we can also build those from respective sources.</p><pre>sudo bash prerequisites.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/0*OfWpP-9luWs6X6mx" /><figcaption>Prerequisites</figcaption></figure><h4>Generating public info using private/secret seed value</h4><p>Seed is a 32 character long value which acts as an actor’s/component’s private information which is not shareable with others for security reasons. By using seed value, we can generate public information and can share those public information via agents or other mediums.<br>By calling “get_did_and_verkey.py” with 32 character long seed value, different actors can see their did(Decentralized Identity) and verification keys.</p><pre>python3 get_did_and_verkey.py --seed 100A000000300000c0000000Steward1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/0*rnKQbezBGHh0S0tW" /><figcaption>Generating public info using private/secret seed value</figcaption></figure><h4>Initial Actors and Components</h4><p>In an Indy based network there are some initials actors called endorsers, these include stewards and trustees.</p><p><strong>Trustee<br></strong>First and foremost actors of our network are trustees. Domain ledger transactions start with trustee. In domain ledger, a trustee can add new stewards too. Both trustee and stewards have power to write on domain ledger.<br>In this tutorial, we have one trustee with seed value “T0003000u0I000D000F000g0Trustee1”</p><p><strong>Stewards</strong><br>Stewards have power to write on both domain ledger and pool ledger. A steward can add a new node by using pool ledger transactions. A steward can add only one node and so each steward can add its only node into networks.<br>In this tutorial, as we have three nodes, we use three stewards with seed values <br>“100A000000300000c0000000Steward1”, <br>“300600b0D030000000z00000Steward2”, “v000K00l0000S000000e0000Steward3”</p><p>You can find different actors role into the following links<br><a href="https://hyperledger-indy.readthedocs.io/projects/node/en/latest/auth_rules.html#default-auth-map-rules">https://hyperledger-indy.readthedocs.io/projects/node/en/latest/auth_rules.html#default-auth-map-rules</a></p><p><strong>Nodes:</strong><br>Every node is a network component which holds ledgers. Users need to initialize each node by calling “init_indy_node.py” with the node name and node’s seed value. This code also prints that node’s public information like verification keys, BLS Public key, Proof of possession for BLS key which we share with others via agents or other mediums.</p><pre>sudo python3 init_indy_node.py --name Node1 --seed 4000F000u00000D0000000g0000Node1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/0*QkB2Lp8YbqYMyHaw" /><figcaption>Initialization of node</figcaption></figure><p>In this tutorial, as we have three nodes, we use seed with values <br>“4000F000u00000D0000000g0000Node1”, “T00000000u0000I0000v0003000Node2”, “300000A00u000z0000600003000Node3”</p><h4>Single Host Network Development</h4><p>If we have an existing previous setup, we have to clear that at the very beginning by calling “clear_setup.py”.</p><pre>sudo python3 clear_setup.py --full True --network sandbox</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/0*IJoxLSWh-8R2I0aM" /><figcaption>Clear previous setup</figcaption></figure><p>To initialize nodes and to generate domain ledger and pool ledger genesis transactions, we have to call “single_host_generation.sh” file.</p><pre>sudo bash single_host_generation.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/0*z2J55sRyWUDLblZs" /><figcaption>Setup</figcaption></figure><p>To start Node, we have to use the “start_indy_node.py” file for each node.For Node1:</p><pre>sudo python3 start_indy_node.py Node1 0.0.0.0 9701 0.0.0.0 9702</pre><p>For Node2:</p><pre>sudo python3 start_indy_node.py Node2 0.0.0.0 9703 0.0.0.0 9704</pre><p>For Node3:</p><pre>sudo python3 start_indy_node.py Node3 0.0.0.0 9705 0.0.0.0 9706</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/0*io7so-RCq8zmS1Ur" /><figcaption>Node start</figcaption></figure><p>To check the node information:</p><pre>sudo python3 validator_info.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/0*ouVEnpIbvTJ7kKSD" /><figcaption>Node information</figcaption></figure><p>To restart the stopped node:</p><pre>sudo bash restart_indy_node.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/0*26V1C0ZVSYEaF8zJ" /><figcaption>Node restart</figcaption></figure><p>If your validity information shows that your node is stopped, you have to restart it again.</p><h4>Multi Hosts Network Development</h4><p><strong>If you want to run the network on a single host, then please skip the “Multi Hosts Network Development” section.</strong></p><p>Suppose Host IP of 3 Nodes are ‘191.177.76.26’, ‘22.185.194.102’, ‘247.81.153.79’ respectively. If you want to use your own IP, then you have to edit the “- -ips” flag of multi_host_host1_generation.sh, multi_host_host2_generation.sh, multi_host_host3_generation.sh files. Actually for each node, you have to write that node’s generation file so that no one will be able to know that node’s seed value.</p><p><strong>Host 1:</strong><br>Host IP: 191.177.76.26</p><pre>sudo python3 clear_setup.py --full True --network sandbox<br>sudo bash multi_host_host1_generation.sh<br>sudo python3 start_indy_node.py Node1 0.0.0.0 9701 0.0.0.0 9702</pre><p>To check node information and to restart stopped node</p><pre>sudo python3 validator_info.py<br>sudo bash restart_indy_node.sh</pre><p><strong>Host 2:</strong><br>Host IP: 22.185.194.102</p><pre>sudo python3 clear_setup.py --full True --network sandbox<br>sudo bash multi_host_host1_generation.sh<br>sudo python3 start_indy_node.py Node2 0.0.0.0 9703 0.0.0.0 9704</pre><p>To check node information and to restart stopped node</p><pre>sudo python3 validator_info.py<br>sudo bash restart_indy_node.sh</pre><p><strong>Host 3:</strong><br>Host IP: 247.81.153.79</p><pre>sudo python3 clear_setup.py --full True --network sandbox<br>sudo bash multi_host_host1_generation.sh<br>sudo python3 start_indy_node.py Node3 0.0.0.0 9705 0.0.0.0 9706</pre><p>To check node information and to restart stopped node</p><pre>sudo python3 validator_info.py<br>sudo bash restart_indy_node.sh</pre><h4>Behind the Scene</h4><p>At the very beginning, every host has to initialize it’s node with seed value and has to share it’s public information with others.</p><p>After that we have to create a domain ledger genesis file with stewards and trustees public information.</p><p>Next we have to create a pool ledger genesis file with nodes and stewards public information. Besides that, we have to provide node names, node to node communication ports, node to clients communication ports, node numbers, node IPs, network name etc.</p><p>After finishing the domain ledger genesis file and pool ledger genesis file, every host is ready to start it’s node.</p><p>Every actor/component has to generate it’s public information with secret seed value and every actor/component has to keep the seed value secret for security purposes. For that reason, we have to use get_did_and_verkey.py and init_indy_node.py file and have to share public information via agents or other mediums.</p><p>For single host pluggable setup, we have to modify single_host_generation.sh file and for multi hosts pluggable setups, each host has to write it’s own generation file.</p><h4>Testing with SDK Applications</h4><p>Here we’ll be using an <strong>Indy SDK API </strong>(as provided by libindy) instead of an app, so we can see what happens behind the scenes.</p><p>We can follow the following links to know more about “Indy Story Walkthrough”</p><p>Link: <a href="https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/getting-started/indy-walkthrough.html#indy-walkthrough">https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/getting-started/indy-walkthrough.html#indy-walkthrough</a></p><p><a href="https://hyperledger-indy.readthedocs.io/projects/sdk/en/latest/docs/getting-started/indy-walkthrough.html#indy-walkthrough">Indy Walkthrough - Hyperledger Indy SDK documentation</a></p><p>Link: <a href="https://medium.com/@kctheservant/exploring-hyperledger-indy-through-indy-dev-example-10075d2547ae">https://medium.com/@kctheservant/exploring-hyperledger-indy-through-indy-dev-example-10075d2547ae</a></p><p><a href="https://medium.com/@kctheservant/exploring-hyperledger-indy-through-indy-dev-example-10075d2547ae">Exploring Hyperledger Indy through indy-dev Example</a></p><p>Go to any of host machine and you will find pool_transactions_genesis file into following directory:</p><p>“/var/lib/indy/sandbox/pool_transactions_genesis”</p><p>You can also get pool transactions by going to “indy_network” directory and by executing read_ledger.py file.</p><p>Now we have to share the pool_transactions_genesis file with others via agents or other mediums.</p><p>Please go to “indy_sdk/src/utils.py” file and fix the “pool_genesis_txn_data()” functions return value according to the pool_transactions_genesis file.</p><p>Now from “indy_sdk” directory call “sdk_sample.py” to witness the end to end application demo with Indy SDK. Be careful about putting the steward seed value at “sdk_sample.py” file because we have to use one of our stewards credentials that we use during the network development process.</p><pre>python3 -m src.sdk_sample</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*32cRhPqbECeJAUqW" /><figcaption>Indy SDK demo</figcaption></figure><p>If you face any problem like “Wallet already exists”, “Pool already exists” etc to witness the end to end application demo with Indy SDK then please clear the “.indy_client” folder from your Home directory.</p><h3>Summary:</h3><p>This blog is written only for learning purposes and we try to develop Hyperledger Indy customized blockchain network without sharing any private information. We hope this blog will be helpful for you and also expect your valuable reviews so that we all can have a chance to learn from you.</p><h4>Also, Read</h4><ul><li>The Best <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">Crypto Trading Bot</a></li><li><a href="https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c">Crypto Copy Trading Platforms</a></li><li>The Best <a href="https://medium.com/coinmonks/best-crypto-tax-tool-for-my-money-72d4b430816b">Crypto Tax Software</a></li><li><a href="https://medium.com/coinmonks/the-best-crypto-trading-platforms-in-2020-the-definitive-guide-updated-c72f8b874555">Best Crypto Trading Platforms</a></li><li>Best <a href="https://medium.com/coinmonks/top-5-crypto-lending-platforms-in-2020-that-you-need-to-know-a1b675cec3fa">Crypto Lending Platforms</a></li><li><a href="https://bitquery.io/blog/best-blockchain-analysis-tools-and-software">Best Blockchain Analysis Tools</a></li><li><a href="https://medium.com/coinmonks/crypto-arbitrage-guide-how-to-make-money-as-a-beginner-62bfe5c868f6">Crypto arbitrage</a> guide: How to make money as a beginner</li><li>Best <a href="https://medium.com/coinmonks/what-are-the-best-charting-platforms-for-cryptocurrency-trading-85aade584d80">Crypto Charting Tool</a></li><li><a href="https://medium.com/coinmonks/ledger-vs-trezor-best-hardware-wallet-to-secure-cryptocurrency-22c7a3fd391e">Ledger vs Trezor</a></li><li>What are the <a href="https://medium.com/coinmonks/what-are-the-best-books-to-learn-bitcoin-409aeb9aff4b">best books to learn about Bitcoin</a>?</li><li><a href="https://medium.com/coinmonks/3commas-review-an-excellent-crypto-trading-bot-2020-1313a58bec92">3Commas Review</a></li><li><a href="https://medium.com/coinmonks/aax-exchange-review-2021-67c5ea09330c">AAX Exchange Review</a> | Referral Code, Trading Fee, Pros and Cons</li><li><a href="https://medium.com/coinmonks/deribit-review-options-fees-apis-and-testnet-2ca16c4bbdb2">Deribit Review</a> | Options, Fees, APIs and Testnet</li><li><a href="https://medium.com/coinmonks/ftx-crypto-exchange-review-53664ac1198f">FTX Crypto Exchange Review</a></li><li><a href="https://medium.com/coinmonks/ngrave-zero-review-c465cf8307fc">NGRAVE ZERO review</a></li><li><a href="https://medium.com/coinmonks/bybit-exchange-review-dbd570019b71">Bybit Exchange Review</a></li><li><a href="https://medium.com/coinmonks/cryptohopper-vs-3commas-vs-shrimpy-a2c16095b8fe">3Commas vs Cryptohopper</a></li><li>The Best Bitcoin <a href="https://medium.com/coinmonks/the-best-cryptocurrency-hardware-wallets-of-2020-e28b1c124069?source=friends_link&amp;sk=324dd9ff8556ab578d71e7ad7658ad7c">Hardware wallet</a></li><li>Best <a href="https://blog.coincodecap.com/best-monero-wallets">monero wallet</a></li><li><a href="https://blog.coincodecap.com/ledger-nano-s-vs-x">ledger nano s vs x</a></li><li><a href="https://blog.coincodecap.com/bitsgap-3commas-quadency">Bitsgap vs 3Commas vs Quadency</a></li><li><a href="https://blog.coincodecap.com/ledger-nano-s-vs-trezor-one-ledger-nano-x-trezor-t">Ledger Nano S vs Trezor one vs Trezor T vs Ledger Nano X</a></li><li><a href="https://medium.com/coinmonks/blockfi-vs-celsius-vs-hodlnaut-8a1cc8c26630">BlockFi vs Celsius</a> vs Hodlnaut</li><li><a href="https://medium.com/coinmonks/bitsgap-review-a-crypto-trading-bot-that-makes-easy-money-a5d88a336df2">Bitsgap review</a> — A Crypto Trading Bot That Makes Easy Money</li><li><a href="https://medium.com/coinmonks/quadency-review-a-crypto-trading-automation-platform-3068eaa374e1">Quadency Review</a>- A Crypto Trading Bot Made For Professionals</li><li><a href="https://medium.com/coinmonks/primexbt-review-88e0815be858">PrimeXBT Review</a> | Leverage Trading, Fee and Covesting</li><li><a href="https://medium.com/coinmonks/ellipal-titan-review-85e9071dd029">Ellipal Titan Review</a></li><li><a href="https://blog.coincodecap.com/secux-stone-hardware-wallet-review">SecuX Stone Review</a></li><li><a href="https://medium.com/coinmonks/blockfi-review-53096053c097">BlockFi Review</a> | Earn up to 8.6% interests on your Crypto</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85fd10eb5bf5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/hyperledger-indy-custom-network-with-indy-node-plenum-protocol-ledger-85fd10eb5bf5">Hyperledger Indy Custom Network with Indy Node &amp; Plenum(Protocol &amp; Ledger)</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Self Sovereign Identity (SSI) in  Blockchain & The Future of  Internet Identity]]></title>
            <link>https://medium.com/swlh/self-sovereign-identity-ssi-in-blockchain-the-future-of-internet-identity-6deb75607aa?source=rss-909447499163------2</link>
            <guid isPermaLink="false">https://medium.com/p/6deb75607aa</guid>
            <category><![CDATA[self-sovereign-identity]]></category>
            <category><![CDATA[internet]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Ta-seen Junaid]]></dc:creator>
            <pubDate>Sun, 21 Jun 2020 11:21:42 GMT</pubDate>
            <atom:updated>2020-06-21T11:21:42.500Z</atom:updated>
            <content:encoded><![CDATA[<h3>Self Sovereign Identity (SSI) in Blockchain &amp; The Future of Internet Identity</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E21VGS-xgIoD77HOk4ao1A.jpeg" /></figure><p>Self Sovereign Identity (SSI) is considered as the future of internet identity where Blockchain technology will be used to build the underlying structures of a proper Self Sovereign Identity (SSI) system. So what exactly Self Sovereign Identity (SSI) is? What are the principles of Self Sovereign Identity (SSI)? Why do we need Self Sovereign Identity (SSI)? Why do we have to implement (SSI) with blockchain? The answer of those questions are given below with the characteristics of Self Sovereign Identity (SSI).</p><h3><strong>Independent Existence with Total Control:</strong></h3><p>Users must have an independent existence with total control of their identities. With current systems, a user identity depends on identity providers and identity providers have immense control on their user identities. With control on identity providers, they can choose to take away an identifier or they can use identifiers’ information illegally or they can also change a user identity information too.</p><p>With Self Sovereign Identity (SSI), a user must have an independent existence with total control on that user hand. Other authorities do not have any power to take away an identifier or to use identifiers’ information illegally.</p><p>A user may gain credentials from an issuer and the issuer can only control the credentials that are issued by that issuer where the issuer has no power on a user identity or others credentials that the user has from other issuers. For example an user may have a credential of driving license issued by a proper authority. With Self Sovereign Identity (SSI), the authority can only take away that user’s driving license credential for reckless driving where that authority does not have any other controls on that user’s identity.</p><h3><strong>Verifiable Credentials:</strong></h3><p>Suppose I apply for a job by claiming that I hold a credential of a Bachelor of Science degree from Chittagong University of Engineering &amp; Technology(CUET). There must be proper verification systems in Self Sovereign Identity (SSI) so that I can prove my claim to the hiring company that the credential of a Bachelor of Science degree I give them is issued by Chittagong University of Engineering &amp; Technology(CUET) &amp; the claim was not tampered with any fraudulent activities.</p><h3><strong>Selective Disclosure of Attributes:</strong></h3><p>Suppose your overall grade of graduation is not very good because you gave more effort on pure computer science related subjects where in computer science related subjects you have very good grades. A research based company needs employees who have very good knowledge on computer science. So if your university issues you digital transcripts you need a Self Sovereign Identity (SSI) system where you can selectively choose your representation so that you can show them only your computer science related subjects by hiding other details with the help of proper zero knowledge proof technique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*cavZjitWg5ETyNCO9_vgRg.png" /><figcaption><strong>Selective disclosure of attributes</strong></figcaption></figure><p>Another use case will be blockchain based online voting system where you can give your vote anonymously by showing the rightful eligible credentials but also by hiding your personal details(like name, SSN number etc).</p><h3><strong>Unlinkability:</strong></h3><p>You need to transact from an online site regularly but you do not want the site to know your personal choices and financial conditions or exactly you want such a system so that the online site will never realize that all those transactions are coming from you. So you need Self Sovereign Identity (SSI) system with advanced privacy features where others are not able to tell that all those transactions come from the same person (unlinkability) without violating the proper authentication systems by taking the advantages of zero knowledge proof technique.</p><h3><strong>Distributed, Decentralization and Peer to Peer communications :</strong></h3><p>Most of the systems are centralized in power and so the central authorities can take actions in their favor which is always a security threat for everyone. Moreover the central authority can choose to take away an identifier at any time or can sell our valuable secured information to other organizations without our permissions. That is why we need decentralized systems. Centralized systems are prone to attack and it is very easy to destroy a central system and so we need both distributed and decentralized systems. With peer to peer communication we can easily eliminate untrusted third parties and our communication will be direct with our partner’s peer without any middleman. With peer to peer communication, we can give everyone everyone’s rightful value as the communication is direct with the one who created that value or products or services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_PT97pOhi2YhpzMR4w7ZQ.jpeg" /><figcaption><strong>Distributed, decentralization and peer to peer communications</strong></figcaption></figure><h3><strong>Immutability:</strong></h3><blockquote><strong>“The Rohingya people have faced decades of systematic discrimination, statelessness and targeted violence in Rakhine State, Myanmar. Such persecution has forced Rohingya women, girls, boys and men into Bangladesh for many years, with significant spikes following violent attacks in 1978, 1991–1992, and again in 2016. Yet it was August 2017 that triggered by far the largest and fastest refugee influx into Bangladesh. Since then, an estimated 745,000 Rohingya — including more than 400,000 children — have fled into Cox’s Bazar.</strong></blockquote><blockquote><strong>In Myanmar, entire villages were burned to the ground, families were separated and killed, and women and girls were gang raped. Most of the people who escaped were severely traumatized after witnessing unspeakable atrocities. These people found temporary shelter in refugee camps around Cox’s Bazar, Bangladesh, which is now home to the world’s largest refugee camp.”</strong></blockquote><p>The article is taken from <a href="https://www.unocha.org/rohingya-refugee-crisis">United Nations Office for the Coordination of Humanitarian Affairs(UNOCHA)</a>.</p><p>This situation shows the importance of immutability on digital identities and credentials. For example if our world has immutable records for everyone’s properties and the credibility everyone achieved then those situations will not arise anymore.</p><p>The records we keep on the database must need to be immutable with proper cryptography and algorithms like once recorded and it will never be possible to temper those records. We can easily implement immutability by introducing proper blockchain based systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tHCcqdLn3iNw9Vb2x5wN3w.jpeg" /><figcaption>Blockchain Characteristics</figcaption></figure><h3><strong>Open, Transparent &amp; Cryptographically secured:</strong></h3><p>Most of the traditional systems are not open sourced and so we do not have any power to examine the underlying technologies. There might be security breaches and the system might be fraudulent and that is why the whole system needs to be open-sourced, well-known, cryptographically secured, and free so that anyone should be able to examine how the system works. In Self Sovereign Identity (SSI), the systems used to administer and operate a network of identities must be open and transparent, both in how they function and in how they are managed and updated.</p><h3><strong>Portability &amp; Interoperability:</strong></h3><p>An user needs portability on identities and credentials so that the user can transfer user’s information and services as the user wishes(Portability). With Self Sovereign Identity (SSI), Identities and credentials should be as widely usable as possible(Interoperability) which will help users for cross platforms communication . Nowadays, we can use the same identity in multiple platforms by using identity providers(like same e-mail &amp; password for multiple platforms) but those identity providers have massive control over our identities and information. We need an identity management system so that we can communicate within multiple platforms and individuals have the powers to transfer individuals identity information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*2lqQSRzZdiRs9pNxd0Zz-w.png" /><figcaption>Identity providers have massive control over our identity and information</figcaption></figure><h3>Conclusion</h3><p>The future of internet identity will be truth, trusted and transparent with the proper implementation of Self Sovereign Identity (SSI) where Blockchain technology will be used to build the underlying structures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6deb75607aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/self-sovereign-identity-ssi-in-blockchain-the-future-of-internet-identity-6deb75607aa">Self Sovereign Identity (SSI) in  Blockchain &amp; The Future of  Internet Identity</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Private & Public Data at Hyperledger Fabric v1.4]]></title>
            <link>https://medium.com/coinmonks/private-public-data-at-hyperledger-fabric-v1-4-ff9f303f4bc1?source=rss-909447499163------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff9f303f4bc1</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[hyperledger-fabric]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[hyperledger]]></category>
            <dc:creator><![CDATA[Ta-seen Junaid]]></dc:creator>
            <pubDate>Sat, 05 Oct 2019 02:38:17 GMT</pubDate>
            <atom:updated>2021-02-13T08:07:18.105Z</atom:updated>
            <content:encoded><![CDATA[<h3>Private &amp; Public Data at Hyperledger Fabric</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V1AdIOimOJcJ72HLnSZPuQ.jpeg" /></figure><h3>Overview</h3><p>This article represents both conceptual theories and implementation processes of public and private data at Hyperledger Fabric v1.4 blockchain platform and <strong>it is the first article that covers implementation processes of public and private data into a same channel.</strong></p><p>We assume that you know all the <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/key_concepts.html">key concepts</a> of Hyperledger Fabric v1.4 and have sound knowledge on <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html">Building Your First Network</a>.</p><h3>Why we need private data?</h3><p>Private data is used for data confidentiality and to hide sensitive information from other parties. Like two parties do not want to share their pricing policies among other members of Blockchain network or customers do not want to share all their information among others.</p><p>Though Hyperledger Fabric is a private permissioned Blockchain network, creating more channels for private data will cause maintenance nightmare and performance degradation. Encrypting the key-value pairs will create overheads and everyone with the shared key can access the encrypted data. So the best solution is to use private data to keep your necessary information confidential from others.</p><h3>An Example</h3><p>Suppose Org A, Org B, Org C and Org D are four business organizations in our blockchain network and those organizations are in Channel x for their business purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KxvEdiZc9m825zwdpNkuRw.jpeg" /><figcaption>Channel x with both public data and private data</figcaption></figure><p>Each of them has a same Ledger that holds facts about the current and historical state of a set of business objects whereas Chaincode defines the executable logic that generates new facts to add to each Ledger. So data in the Ledger is <strong>public</strong> among all organizations of that channel. But Org C and Org D do not want to share their confidential data with other organizations. So they store those private data in a <strong>SideDB</strong> which is <strong>private</strong> between Org C &amp; Org D where Org A &amp; Org B will never know the private data but a transaction hash will be added at each Ledger.</p><h3>Flow of Transactions for a Channel’s Public Data</h3><p><strong>.</strong> Signing transaction proposal and sending that to endorsers</p><p><strong>. </strong>Gathering signed responses from endorsers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5COJlX6D6nvsfdXoCDSZsQ.jpeg" /><figcaption>Flow of transactions for a channel’s public data</figcaption></figure><p><strong>. </strong>Broadcasting request to orders</p><p><strong>.</strong> Creation of blocks by orders</p><p><strong>.</strong> Delivering blocks to peers by orders</p><p><strong>.</strong> Validating by peers</p><p><strong>. </strong>Updating Ledgers</p><h3>Flow of Transactions for a Channel’s Private Data</h3><p><strong>.</strong> Signing transaction proposal and sending that to endorsers</p><p><strong>.</strong> Keeping private data in transient field to hide it from endorsers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_dxnVi8NWdcYtV2uer-NPg.jpeg" /><figcaption>Flow of transactions for a channel’s private Data</figcaption></figure><p><strong>.</strong> Checking of private data collection definition by endorsers</p><p><strong>.</strong> Sending of private data to some of authorized organizations peers</p><p><strong>.</strong> Use of <strong>gossip protocol </strong>among authorized organizations peers to receive private data</p><p><strong>.</strong> responding with the hash of private data by endorsers</p><p><strong>.</strong> Broadcasting request to orders</p><p><strong>.</strong> Creation of blocks by orders</p><p><strong>.</strong> Delivering blocks to peers by orders</p><p><strong>.</strong> Validating by peers</p><p><strong>.</strong> Updating Ledgers with transaction hash (both authorized and unauthorized peers)</p><p><strong>.</strong> Checking by authorized peers</p><p><strong>. </strong>Moving of private data into <strong>SideDB </strong>by authorized peers</p><p><strong>.</strong> Deletion of private data from transient DB by authorized peers</p><h3>Hands-on tutorial</h3><p>Private data collection definition needs to write in a JSON format and needs to introduce it’s path during Chaincode instantiate process(like $GOPATH/src/github.com/chaincode/collections_config.json). We name the JSON file as collections_config.json and you can read <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/private_data_tutorial.html">official documents</a> about how to write this file.</p><pre>//collections_config.json<br>[<br>  {<br>    &quot;name&quot;: &quot;collectionMaterialOrderPrivateDetails&quot;,<br>    &quot;policy&quot;: &quot;OR(&#39;CMSP.member&#39;,&#39;DMSP.member&#39;)&quot;,<br>    &quot;requiredPeerCount&quot;: 0,<br>    &quot;maxPeerCount&quot;: 3,<br>    &quot;blockToLive&quot;: 0,<br>    &quot;memberOnlyRead&quot;: true<br>  }<br>]</pre><p>We name this as “collectionMaterialOrderPrivateDetails” and according to the policy only C and D organizations can have access into the private data.</p><p>In our Chaincode, we keep the pricing policy private so only authorized organizations can view it. The Chaincode is written by using GO language.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2853d3a01cc28145480ab9eab4b71845/href">https://medium.com/media/2853d3a01cc28145480ab9eab4b71845/href</a></iframe><pre>//Chaincode<br>package main<br><br>import (<br>	&quot;bytes&quot;<br>	&quot;encoding/json&quot;<br>	&quot;fmt&quot;<br>	&quot;strconv&quot;<br>	&quot;time&quot;<br><br>	&quot;github.com/hyperledger/fabric/core/chaincode/shim&quot;<br>	pb &quot;github.com/hyperledger/fabric/protos/peer&quot;<br>)<br><br>type SimpleChaincode struct {<br>}<br><br>type order struct {<br>	ObjectType            string `json:&quot;docType&quot;`<br>	Order_raw_material_id string `json:&quot;order_raw_material_id&quot;`<br>	Manufacturer_id       string `json:&quot;manufacturer_id&quot;`<br>	Provider_id           string `json:&quot;provider_id&quot;`<br>	Material_name         string `json:&quot;material_name&quot;`<br>	Order_medicine_id     string `json:&quot;order_medicine_id&quot;`<br>	Quantity              string `json:&quot;quantity&quot;`<br>	Status                string `json:&quot;status&quot;`<br>}<br><br>type orderPrivateDetails struct {<br>	Price string `json:&quot;price&quot;`<br>}<br><br>func main() {<br>	err := shim.Start(new(SimpleChaincode))<br>	if err != nil {<br>		fmt.Printf(&quot;Error starting Simple chaincode: %s&quot;, err)<br>	}<br>}<br><br>func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {<br>	return shim.Success(nil)<br>}<br><br>func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {<br>	function, args := stub.GetFunctionAndParameters()<br>	fmt.Println(&quot;invoke is running &quot; + function)<br><br>	if function == &quot;initOrder&quot; {<br>		return t.initOrder(stub, args)<br>	} else if function == &quot;changeStatus&quot; {<br>		return t.changeStatus(stub, args)<br>	} else if function == &quot;changeProvider_id&quot; {<br>		return t.changeProvider_id(stub, args)<br>	} else if function == &quot;changeQuantity&quot; {<br>		return t.changeQuantity(stub, args)<br>	} else if function == &quot;readOrder&quot; {<br>		return t.readOrder(stub, args)<br>	} else if function == &quot;getHistoryForOrder&quot; {<br>		return t.getHistoryForOrder(stub, args)<br>	} else if function == &quot;getOrdersByRange&quot; {<br>		return t.getOrdersByRange(stub, args)<br>	} else if function == &quot;queryOrderByOrder_medicine_id&quot; {<br>		return t.queryOrderByOrder_medicine_id(stub, args)<br>	} else if function == &quot;readOrderPrivateDetails&quot; {<br>		return t.readOrderPrivateDetails(stub, args)<br>	} else if function == &quot;changeOrderPrivateDetails&quot; {<br>		return t.changeOrderPrivateDetails(stub, args)<br>	}<br><br>	fmt.Println(&quot;invoke did not find func: &quot; + function)<br>	return shim.Error(&quot;Received unknown function invocation&quot;)<br>}<br><br>func (t *SimpleChaincode) initOrder(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br>	var err error<br><br>	if len(args) != 7 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting 7&quot;)<br>	}<br><br>	fmt.Println(&quot;- start init order&quot;)<br>	if len(args[0]) &lt;= 0 {<br>		return shim.Error(&quot;1st argument must be a non-empty string&quot;)<br>	}<br>	if len(args[1]) &lt;= 0 {<br>		return shim.Error(&quot;2nd argument must be a non-empty string&quot;)<br>	}<br>	if len(args[2]) &lt;= 0 {<br>		return shim.Error(&quot;3rd argument must be a non-empty string&quot;)<br>	}<br>	if len(args[3]) &lt;= 0 {<br>		return shim.Error(&quot;4th argument must be a non-empty string&quot;)<br>	}<br>	if len(args[4]) &lt;= 0 {<br>		return shim.Error(&quot;5th argument must be a non-empty string&quot;)<br>	}<br>	if len(args[5]) &lt;= 0 {<br>		return shim.Error(&quot;6th argument must be a non-empty string&quot;)<br>	}<br>	if len(args[6]) &lt;= 0 {<br>		return shim.Error(&quot;7th argument must be a non-empty string&quot;)<br>	}<br><br>	orderName := args[0]<br>	manufacturer_id := args[1]<br>	provider_id := args[2]<br>	material_name := args[3]<br>	order_medicine_id := args[4]<br>	quantity := args[5]<br>	status := args[6]<br><br>	orderAsBytes, err := stub.GetState(orderName)<br>	if err != nil {<br>		return shim.Error(&quot;Failed to get order: &quot; + err.Error())<br>	} else if orderAsBytes != nil {<br>		fmt.Println(&quot;This orderName already exists: &quot; + orderName)<br>		return shim.Error(&quot;This orderName already exists: &quot; + orderName)<br>	}<br><br>	objectType := &quot;order&quot;<br>	order := &amp;order{objectType, orderName, manufacturer_id, provider_id, material_name, order_medicine_id, quantity, status}<br>	orderJSONasBytes, err := json.Marshal(order)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	err = stub.PutState(orderName, orderJSONasBytes)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	// ==== Create order private details object with price, marshal to JSON, and save to state ====<br>	transMap, err := stub.GetTransient()<br>	if err != nil {<br>		return shim.Error(&quot;Error getting transient: &quot; + err.Error())<br>	}<br><br>	if _, ok := transMap[&quot;order&quot;]; !ok {<br>		return shim.Error(&quot;order must be a key in the transient map&quot;)<br>	}<br><br>	if len(transMap[&quot;order&quot;]) == 0 {<br>		return shim.Error(&quot;order value in the transient map must be a non-empty JSON string&quot;)<br>	}<br><br>	type orderTransientInput struct {<br>		Price string `json:&quot;price&quot;`<br>	}<br><br>	var orderInput orderTransientInput<br>	err = json.Unmarshal(transMap[&quot;order&quot;], &amp;orderInput)<br>	if err != nil {<br>		return shim.Error(&quot;Failed to decode JSON of: &quot; + string(transMap[&quot;order&quot;]))<br>	}<br><br>	orderPrivateDetails := &amp;orderPrivateDetails{<br>		Price: orderInput.Price,<br>	}<br>	orderPrivateDetailsBytes, err := json.Marshal(orderPrivateDetails)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br>	err = stub.PutPrivateData(&quot;collectionMaterialOrderPrivateDetails&quot;, orderName, orderPrivateDetailsBytes)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	indexName := &quot;order_medicine_id&quot;<br>	order_medicine_idIndexKey, err := stub.CreateCompositeKey(indexName, []string{order.Order_medicine_id, order.Order_raw_material_id})<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	value := []byte{0x00}<br>	stub.PutState(order_medicine_idIndexKey, value)<br><br>	fmt.Println(&quot;- end init order&quot;)<br>	return shim.Success(nil)<br>}<br><br>func (t *SimpleChaincode) readOrder(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br>	var name, jsonResp string<br>	var err error<br><br>	if len(args) != 1 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting name of the order to query&quot;)<br>	}<br><br>	name = args[0]<br>	valAsbytes, err := stub.GetState(name)<br>	if err != nil {<br>		jsonResp = &quot;{\&quot;Error\&quot;:\&quot;Failed to get state for &quot; + name + &quot;\&quot;}&quot;<br>		return shim.Error(jsonResp)<br>	} else if valAsbytes == nil {<br>		jsonResp = &quot;{\&quot;Error\&quot;:\&quot;Order does not exist: &quot; + name + &quot;\&quot;}&quot;<br>		return shim.Error(jsonResp)<br>	}<br><br>	return shim.Success(valAsbytes)<br>}<br><br>func (t *SimpleChaincode) changeStatus(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br><br>	if len(args) &lt; 2 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting 2&quot;)<br>	}<br><br>	orderName := args[0]<br>	newStatus := args[1]<br>	fmt.Println(&quot;- start changeStatus &quot;, orderName, newStatus)<br><br>	orderAsBytes, err := stub.GetState(orderName)<br>	if err != nil {<br>		return shim.Error(&quot;Failed to get order:&quot; + err.Error())<br>	} else if orderAsBytes == nil {<br>		return shim.Error(&quot;Order does not exist&quot;)<br>	}<br><br>	statusToChange := order{}<br>	err = json.Unmarshal(orderAsBytes, &amp;statusToChange)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br>	statusToChange.Status = newStatus<br><br>	orderJSONasBytes, _ := json.Marshal(statusToChange)<br>	err = stub.PutState(orderName, orderJSONasBytes)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	fmt.Println(&quot;- end changeStatus (success)&quot;)<br>	return shim.Success(nil)<br>}<br><br>func (t *SimpleChaincode) changeProvider_id(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br><br>	if len(args) &lt; 2 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting 2&quot;)<br>	}<br><br>	orderName := args[0]<br>	newProvider_id := args[1]<br>	fmt.Println(&quot;- start changeStatus &quot;, orderName, newProvider_id)<br><br>	orderAsBytes, err := stub.GetState(orderName)<br>	if err != nil {<br>		return shim.Error(&quot;Failed to get order:&quot; + err.Error())<br>	} else if orderAsBytes == nil {<br>		return shim.Error(&quot;Order does not exist&quot;)<br>	}<br><br>	provider_idToChange := order{}<br>	err = json.Unmarshal(orderAsBytes, &amp;provider_idToChange)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	orderJSONasBytes, _ := json.Marshal(provider_idToChange)<br>	err = stub.PutState(orderName, orderJSONasBytes)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	fmt.Println(&quot;- end changeStatus (success)&quot;)<br>	return shim.Success(nil)<br>}<br><br>func (t *SimpleChaincode) changeQuantity(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br><br>	if len(args) &lt; 2 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting 2&quot;)<br>	}<br><br>	orderName := args[0]<br>	newQuantity := args[1]<br>	fmt.Println(&quot;- start changeStatus &quot;, orderName, newQuantity)<br><br>	orderAsBytes, err := stub.GetState(orderName)<br>	if err != nil {<br>		return shim.Error(&quot;Failed to get order:&quot; + err.Error())<br>	} else if orderAsBytes == nil {<br>		return shim.Error(&quot;Order does not exist&quot;)<br>	}<br><br>	quantityToChange := order{}<br>	err = json.Unmarshal(orderAsBytes, &amp;quantityToChange)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br>	quantityToChange.Quantity = newQuantity<br><br>	orderJSONasBytes, _ := json.Marshal(quantityToChange)<br>	err = stub.PutState(orderName, orderJSONasBytes)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	fmt.Println(&quot;- end changeStatus (success)&quot;)<br>	return shim.Success(nil)<br>}<br><br>func (t *SimpleChaincode) queryOrderByOrder_medicine_id(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br><br>	if len(args) &lt; 1 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting 1&quot;)<br>	}<br><br>	order_medicine_id := args[0]<br><br>	queryString := fmt.Sprintf(&quot;{\&quot;selector\&quot;:{\&quot;docType\&quot;:\&quot;order\&quot;,\&quot;order_medicine_id\&quot;:\&quot;%s\&quot;}}&quot;, order_medicine_id)<br><br>	queryResults, err := getQueryResultForQueryString(stub, queryString)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br>	return shim.Success(queryResults)<br>}<br><br>func getQueryResultForQueryString(stub shim.ChaincodeStubInterface, queryString string) ([]byte, error) {<br><br>	fmt.Printf(&quot;- getQueryResultForQueryString queryString:\n%s\n&quot;, queryString)<br><br>	resultsIterator, err := stub.GetQueryResult(queryString)<br>	if err != nil {<br>		return nil, err<br>	}<br>	defer resultsIterator.Close()<br><br>	buffer, err := constructQueryResponseFromIterator(resultsIterator)<br>	if err != nil {<br>		return nil, err<br>	}<br><br>	fmt.Printf(&quot;- getQueryResultForQueryString queryResult:\n%s\n&quot;, buffer.String())<br><br>	return buffer.Bytes(), nil<br>}<br><br>func constructQueryResponseFromIterator(resultsIterator shim.StateQueryIteratorInterface) (*bytes.Buffer, error) {<br><br>	var buffer bytes.Buffer<br>	buffer.WriteString(&quot;[&quot;)<br><br>	bArrayMemberAlreadyWritten := false<br>	for resultsIterator.HasNext() {<br>		queryResponse, err := resultsIterator.Next()<br>		if err != nil {<br>			return nil, err<br>		}<br><br>		if bArrayMemberAlreadyWritten == true {<br>			buffer.WriteString(&quot;,&quot;)<br>		}<br>		buffer.WriteString(&quot;{\&quot;Key\&quot;:&quot;)<br>		buffer.WriteString(&quot;\&quot;&quot;)<br>		buffer.WriteString(queryResponse.Key)<br>		buffer.WriteString(&quot;\&quot;&quot;)<br><br>		buffer.WriteString(&quot;, \&quot;Record\&quot;:&quot;)<br>		buffer.WriteString(string(queryResponse.Value))<br>		buffer.WriteString(&quot;}&quot;)<br>		bArrayMemberAlreadyWritten = true<br>	}<br>	buffer.WriteString(&quot;]&quot;)<br><br>	return &amp;buffer, nil<br>}<br><br>func (t *SimpleChaincode) getHistoryForOrder(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br><br>	if len(args) &lt; 1 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting 1&quot;)<br>	}<br><br>	orderName := args[0]<br><br>	fmt.Printf(&quot;- start getHistoryForOrder: %s\n&quot;, orderName)<br><br>	resultsIterator, err := stub.GetHistoryForKey(orderName)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br>	defer resultsIterator.Close()<br><br>	var buffer bytes.Buffer<br>	buffer.WriteString(&quot;[&quot;)<br><br>	bArrayMemberAlreadyWritten := false<br>	for resultsIterator.HasNext() {<br>		response, err := resultsIterator.Next()<br>		if err != nil {<br>			return shim.Error(err.Error())<br>		}<br><br>		if bArrayMemberAlreadyWritten == true {<br>			buffer.WriteString(&quot;,&quot;)<br>		}<br>		buffer.WriteString(&quot;{\&quot;TxId\&quot;:&quot;)<br>		buffer.WriteString(&quot;\&quot;&quot;)<br>		buffer.WriteString(response.TxId)<br>		buffer.WriteString(&quot;\&quot;&quot;)<br><br>		buffer.WriteString(&quot;, \&quot;Value\&quot;:&quot;)<br><br>		if response.IsDelete {<br>			buffer.WriteString(&quot;null&quot;)<br>		} else {<br>			buffer.WriteString(string(response.Value))<br>		}<br><br>		buffer.WriteString(&quot;, \&quot;Timestamp\&quot;:&quot;)<br>		buffer.WriteString(&quot;\&quot;&quot;)<br>		buffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())<br>		buffer.WriteString(&quot;\&quot;&quot;)<br><br>		buffer.WriteString(&quot;, \&quot;IsDelete\&quot;:&quot;)<br>		buffer.WriteString(&quot;\&quot;&quot;)<br>		buffer.WriteString(strconv.FormatBool(response.IsDelete))<br>		buffer.WriteString(&quot;\&quot;&quot;)<br><br>		buffer.WriteString(&quot;}&quot;)<br>		bArrayMemberAlreadyWritten = true<br>	}<br>	buffer.WriteString(&quot;]&quot;)<br><br>	fmt.Printf(&quot;- getHistoryForOrder returning:\n%s\n&quot;, buffer.String())<br><br>	return shim.Success(buffer.Bytes())<br>}<br><br>func (t *SimpleChaincode) getOrdersByRange(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br><br>	if len(args) &lt; 2 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting 2&quot;)<br>	}<br><br>	startKey := args[0]<br>	endKey := args[1]<br><br>	resultsIterator, err := stub.GetStateByRange(startKey, endKey)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br>	defer resultsIterator.Close()<br><br>	buffer, err := constructQueryResponseFromIterator(resultsIterator)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	fmt.Printf(&quot;- getOrdersByRange queryResult:\n%s\n&quot;, buffer.String())<br><br>	return shim.Success(buffer.Bytes())<br>}<br><br>func (t *SimpleChaincode) readOrderPrivateDetails(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br>	var name, jsonResp string<br>	var err error<br><br>	if len(args) != 1 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting name of the order to query&quot;)<br>	}<br><br>	name = args[0]<br>	valAsbytes, err := stub.GetPrivateData(&quot;collectionMaterialOrderPrivateDetails&quot;, name) //get the order private details from chaincode state<br>	if err != nil {<br>		jsonResp = &quot;{\&quot;Error\&quot;:\&quot;Failed to get private details for &quot; + name + &quot;: &quot; + err.Error() + &quot;\&quot;}&quot;<br>		return shim.Error(jsonResp)<br>	} else if valAsbytes == nil {<br>		jsonResp = &quot;{\&quot;Error\&quot;:\&quot;order private details does not exist: &quot; + name + &quot;\&quot;}&quot;<br>		return shim.Error(jsonResp)<br>	}<br><br>	return shim.Success(valAsbytes)<br>}<br><br>func (t *SimpleChaincode) changeOrderPrivateDetails(stub shim.ChaincodeStubInterface, args []string) pb.Response {<br><br>	if len(args) &lt; 2 {<br>		return shim.Error(&quot;Incorrect number of arguments. Expecting 2&quot;)<br>	}<br><br>	orderName := args[0]<br>	newPrice := args[1]<br>	fmt.Println(&quot;- start changeStatus &quot;, orderName, newPrice)<br><br>	orderAsBytes, err := stub.GetPrivateData(&quot;collectionMaterialOrderPrivateDetails&quot;, orderName)<br>	if err != nil {<br>		return shim.Error(&quot;Failed to get order:&quot; + err.Error())<br>	} else if orderAsBytes == nil {<br>		return shim.Error(&quot;Order does not exist&quot;)<br>	}<br><br>	priceToChange := orderPrivateDetails{}<br>	err = json.Unmarshal(orderAsBytes, &amp;priceToChange)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br>	priceToChange.Price = newPrice<br><br>	orderJSONasBytes, _ := json.Marshal(priceToChange)<br>	err = stub.PutPrivateData(&quot;collectionMaterialOrderPrivateDetails&quot;, orderName, orderJSONasBytes)<br>	if err != nil {<br>		return shim.Error(err.Error())<br>	}<br><br>	fmt.Println(&quot;- end changeStatus (success)&quot;)<br>	return shim.Success(nil)<br>}</pre><p>To install Chanincode:</p><pre>peer chaincode install -n ${CHAINCODE_NAME} -v 1.0 -p github.com/chaincode/ordermaterial/<br></pre><p>To instantiate Chaincode:</p><pre>peer chaincode instantiate -o orderer.example.com:7050 — tls — cafile $ORDERER_CA_FILE -C $CHANNEL_NAME -n $CHAINCODE_NAME -v 1.0 -c ‘{“Args”:[]}’ -P “OR (‘AMSP.peer’,’BMSP.peer’,’CMSP.peer’,’DMSP.peer’)” — collections-config $GOPATH/src/github.com/chaincode/collections_config.json</pre><p>To invoke Chaincode with both public and private data:</p><pre>export ORDER=$(echo -n “{\”price\”:\”100\”}” | base64 | tr -d \\n)<br>peer chaincode invoke -o orderer.example.com:7050 — tls — cafile $ORDERER_CA_FILE -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“function”:”initOrder”,”Args”:[“12”, “manu”, “pro”, “material”, “1a1”, “10”, “accept”]}’ — transient “{\”order\”:\”$ORDER\”}”</pre><p>Some invoking commands for both private and public data:</p><pre>export ORDER=$(echo -n “{\”price\”:\”200\”}” | base64 | tr -d \\n)<br>peer chaincode invoke -o orderer.example.com:7050 — tls — cafile $ORDERER_CA_FILE -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“function”:”initOrder”,”Args”:[“1”, “manu”, “pro12”, “material123”, “1a1”, “102”, “accept”]}’ — transient “{\”order\”:\”$ORDER\”}”</pre><pre>peer chaincode invoke -o orderer.example.com:7050 — tls — cafile $ORDERER_CA_FILE -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“function”:”changeStatus”,”Args”:[“12” , “Good”]}’</pre><pre>peer chaincode invoke -o orderer.example.com:7050 — tls — cafile $ORDERER_CA_FILE -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“function”:”changeQuantity”,”Args”:[“12” , “100”]}’</pre><pre>peer chaincode invoke -o orderer.example.com:7050 — tls — cafile $ORDERER_CA_FILE -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“function”:”changeProvider_id”,”Args”:[“12” , “pro10”]}’</pre><pre>peer chaincode invoke -o orderer.example.com:7050 — tls — cafile $ORDERER_CA_FILE -C $CHANNEL_NAME -n $CHAINCODE_NAME -c’{“function”:”changeOrderPrivateDetails”,”Args”:[“12” , “300”]}’</pre><p>Some query commands for both private and public data:</p><pre>peer chaincode query -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“function”:”readOrder”,”Args”:[“12”]}’</pre><pre>peer chaincode query -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“function”:”getOrdersByRange”,”Args”:[“1” , “15”]}’</pre><pre>peer chaincode query -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“Args”:[“queryOrderByOrder_medicine_id”,”1a1&quot;]}’</pre><pre>peer chaincode query -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“Args”:[“readOrderPrivateDetails”,”12&quot;]}’</pre><pre>peer chaincode query -C $CHANNEL_NAME -n $CHAINCODE_NAME -c ‘{“Args”:[“getHistoryForOrder”,”12&quot;]}’</pre><h3>Summary:</h3><p>In this article we try to explain public and private data of Hyperledger Fabric v1.4 blockchain platform with a hands-on tutorial about how to implement both private and public data on same channel. We hardly find any tutorial about implementation processes<strong> </strong>of<strong> </strong>both private and public data on same channel and so we hope it will help you to develop your blockchain network.</p><figure><a href="https://coincodecap.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bcTJUjFtXf1QtlWzlS04XQ.jpeg" /></a></figure><blockquote><a href="https://coincodecap.com/?utm_source=coinmonks">Get Best Software Deals Directly In Your Inbox</a></blockquote><figure><a href="https://coincodecap.com/?utm_source=coinmonks"><img alt="" src="https://cdn-images-1.medium.com/max/584/0*OJ-qb5G6i863msBB.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff9f303f4bc1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/private-public-data-at-hyperledger-fabric-v1-4-ff9f303f4bc1">Private &amp; Public Data at Hyperledger Fabric v1.4</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taste all the features of Hyperledger Fabric v1.4]]></title>
            <link>https://medium.com/hackernoon/taste-all-the-features-of-hyperledger-fabric-v1-4-4275fd9b9d8e?source=rss-909447499163------2</link>
            <guid isPermaLink="false">https://medium.com/p/4275fd9b9d8e</guid>
            <category><![CDATA[hyperledger-fabric]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[couchdb]]></category>
            <category><![CDATA[raft]]></category>
            <dc:creator><![CDATA[Ta-seen Junaid]]></dc:creator>
            <pubDate>Thu, 09 May 2019 03:10:49 GMT</pubDate>
            <atom:updated>2021-02-13T08:05:21.474Z</atom:updated>
            <content:encoded><![CDATA[<h3>Taste all the Features of the Hyperledger Fabric v1.4 Network</h3><h4>At Minimum Configuration of Multi-Channels with Different Participating Organizations Using CouchDB &amp; Raft Ordering Service.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*NesMie_FXd0gEl9a6jPB5w.jpeg" /><figcaption>System Architecture</figcaption></figure><h3>Overview</h3><p>This article covers all the features of <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/">Hyperledger Fabric v1.4</a> network at minimum configuration which is the “next step” of <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html">Building Your First Network</a>. In this article we are showing a network with three organizations where two organizations have multi-peer and a setup of a two different channels each of which has different participating organizations established with Raft ordering service by using CouchDB as ledger database.</p><p>We assume you know all the <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/key_concepts.html">key concepts</a> of Hyperledger Fabric v1.4 and have sound knowledge on <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html">Building Your First Network</a>.</p><p>This is the fast article covering all the features of <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/">Hyperledger Fabric v1.4</a> network with minimum configuration.</p><h3>System Architecture</h3><p>Here we have three organizations as Org1, Org2 &amp; Org3 where Org1 &amp; Org2 have 2 peers. There are two channels as channel1 &amp; channel2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*NesMie_FXd0gEl9a6jPB5w.jpeg" /><figcaption>System Architecture</figcaption></figure><p>Here channel1 consists with all the peers and all the organizations where channel2 consists with peer0.Org2 &amp; peer0.Org3. By using raft ordering service we can use multiple Orderer and so we will use five Orderer. L1 is the ledger for Channel1 which is invoked by smart contact S1 and L2 is the ledger for Channel2 which is invoked by smart contact S2.</p><h3>Step 1</h3><p>First of all, prepare the <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/prereqs.html">prerequisites</a> and after that you also need to Install Samples, Binaries and Docker Images. I assume you are now in home directory and run the following command:</p><pre>curl -sSL http://bit.ly/2ysbOFE | bash -s</pre><p>After completion you will see the directory ‘fabric-samples’, and the required docker images are already downloaded as well.</p><p><strong>Caution: </strong>Samples, Binaries may change and so you need to edit some of your files according to that changes.</p><h3>Step 2</h3><p>First you need to create a new directory under <strong>home/fabric-samples</strong> named as <strong>mynetwork </strong>and then need to enter into that directory. From now we will run all our commands from <strong>home/fabric-samples/mynetwork </strong>directory.</p><pre>cd fabric-samples<br>mkdir mynetwork<br>cd mynetwork</pre><p>To stop and delete all the previous docker containers, docker volumes, docker networks, script created files we need to run those commands:</p><pre>#STOP AND DELETE THE DOCKER CONTAINERS<br>docker ps -aq | xargs -n 1 docker stop<br>docker ps -aq | xargs -n 1 docker rm -v</pre><pre>#DELETE THE OLD DOCKER VOLUMES<br>docker volume prune -f</pre><pre>#DELETE OLD DOCKER NETWORKS<br>docker network prune -f</pre><pre>#Remove all stopped containers<br>docker container prune -f</pre><pre>#Remove All Unused Objects<br>docker system prune -f<br>docker system prune --volumes -f</pre><pre>#DELETE SCRIPT-CREATED FILES<br>rm -rf channel-artifacts/*.block channel-artifacts/*.tx crypto-config</pre><pre>#DELETE un-tagged images<br>docker rmi -f $(docker images | awk &#39;($1 ~ /dev-peer.*/) {print $3}&#39;)</pre><pre>#if you get error in future you may also need to remove docker images using the commands given below:<br>#docker rm -f $(docker ps -aq)<br>#docker rmi -f $(docker images -q)</pre><p>All our binaries are housed inside bin directory. First we need to create <strong>crypto-config.yaml</strong> file as given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e46074222697d654a974c10984c3963e/href">https://medium.com/media/e46074222697d654a974c10984c3963e/href</a></iframe><p>We have to run the cryptogen tool which will create all the necessary certificates and keys inside <strong>crypto-config </strong>folder.</p><pre>../bin/cryptogen generate --config=./crypto-config.yaml</pre><h3>Step 3</h3><p>First we need to create a directory named <strong>channel-artifacts </strong>where we store scripts created files like ‘_.block’ or ‘_.tx’ .</p><p>Then we need to create <strong>configtx.yaml</strong> file at <strong>home/fabric-samples/mynetwork </strong>directory which hosts all the business network.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3c2c17abadc42c16d22a22fc3885146/href">https://medium.com/media/f3c2c17abadc42c16d22a22fc3885146/href</a></iframe><p>We need to create a new directory named <strong>channel-artifacts </strong>inside <strong>home/fabric-samples/mynetwork </strong>directory after that we need to tell the configtxgentool to look for the <strong>configtx.yaml</strong> file at our present working directory:</p><pre>export FABRIC_CFG_PATH=$PWD</pre><p>Finally we need to invoke the configtxgen tool to create the orderer genesis block for Raft ordering service. It will create genesis.block inside <strong>channel-artifacts </strong>directory.</p><pre>../bin/configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block</pre><h3>Step 4</h3><p>In this step we will create all the channel transactions artifacts. So we need to define some environment variables.</p><pre>export CHANNEL_ONE_NAME=channel1</pre><pre>export CHANNEL_ONE_PROFILE=Channel1</pre><pre>export CHANNEL_TWO_NAME=channel2</pre><pre>export CHANNEL_TWO_PROFILE=Channel2</pre><p>Now we need to create channel transaction artifacts which will create ‘<strong>_.tx</strong>’ files inside <strong>channel-artifacts directory</strong> and those contains the definitions of channels. The command for channel1 and channel2 are given respectively:</p><pre>../bin/configtxgen -profile ${CHANNEL_ONE_PROFILE} -outputCreateChannelTx ./channel-artifacts/${CHANNEL_ONE_NAME}.tx -channelID $CHANNEL_ONE_NAME</pre><pre>../bin/configtxgen -profile ${CHANNEL_TWO_PROFILE} -outputCreateChannelTx ./channel-artifacts/${CHANNEL_TWO_NAME}.tx -channelID $CHANNEL_TWO_NAME</pre><p>It is time to define anchor peers for channel1 which consists with three organizations.</p><pre>../bin/configtxgen -profile ${CHANNEL_ONE_PROFILE} -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors_${CHANNEL_ONE_NAME}.tx -channelID $CHANNEL_ONE_NAME -asOrg Org1MSP</pre><pre>../bin/configtxgen -profile ${CHANNEL_ONE_PROFILE} -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors_${CHANNEL_ONE_NAME}.tx -channelID $CHANNEL_ONE_NAME -asOrg Org2MSP</pre><pre>../bin/configtxgen -profile ${CHANNEL_ONE_PROFILE} -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors_${CHANNEL_ONE_NAME}.tx -channelID $CHANNEL_ONE_NAME -asOrg Org3MSP</pre><p>After that we need to define the anchor peers for Channel2 consists with two organizations .</p><pre>../bin/configtxgen -profile ${CHANNEL_TWO_PROFILE} -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors_${CHANNEL_TWO_NAME}.tx -channelID $CHANNEL_TWO_NAME -asOrg Org2MSP</pre><pre>../bin/configtxgen -profile ${CHANNEL_TWO_PROFILE} -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors_${CHANNEL_TWO_NAME}.tx -channelID $CHANNEL_TWO_NAME -asOrg Org3MSP</pre><h3>Step 5</h3><p>We need to create a directory named <strong>base </strong>inside <strong>home/fabric-samples/mynetwork </strong>directory. Inside <strong>base</strong> we need to create two files named as <strong>docker-compose-base.yaml</strong> &amp; <strong>peer-base.yaml.</strong></p><p><strong>docker-compose-base.yaml </strong>file is given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fb2b0cde0ab16247617f53db93058c7/href">https://medium.com/media/8fb2b0cde0ab16247617f53db93058c7/href</a></iframe><p><strong>peer-base.yaml </strong>file is given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/159fc0d743a60a469df8a6aaa648252c/href">https://medium.com/media/159fc0d743a60a469df8a6aaa648252c/href</a></iframe><p>Now we need to create a file named <strong>docker-compose-cli.yaml </strong>inside <strong>home/fabric-samples/mynetwork </strong>directory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a46b38cd268939e78884a381e7fd0ae/href">https://medium.com/media/4a46b38cd268939e78884a381e7fd0ae/href</a></iframe><p>Hyperledger Fabric network is deployed in Docker containers and so we need to write those files.</p><p>We will store our ledger using CouchDB so we need to create <strong>docker-compose-couch.yaml</strong> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69effffdc78868c673f0acc5e0ddadda/href">https://medium.com/media/69effffdc78868c673f0acc5e0ddadda/href</a></iframe><p>As we are using Raft ordering services we need to create <strong>docker-compose-etcdraft2.yaml</strong> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69967444028419f36e032beb2af31a84/href">https://medium.com/media/69967444028419f36e032beb2af31a84/href</a></iframe><p>We also need to create .env file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d1e0890465e3223496e859fcca39cff/href">https://medium.com/media/9d1e0890465e3223496e859fcca39cff/href</a></iframe><p>Finally we complete to write all our files and it is time to start the network with the following command:</p><pre>docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml -f docker-compose-etcdraft2.yaml up -d</pre><h3>Step 6</h3><p>Now we can create our channels and can add peers to the channels. To do that we need to enter into the CLI container.</p><pre>docker exec -it cli bash</pre><p>After entering into the CLI container we need to add<strong> channel1</strong>.</p><pre>#environment variable for peer0.org1<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org1.example.com:7051<br>CORE_PEER_LOCALMSPID=&quot;Org1MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt</pre><pre>#export channel name<br>export CHANNEL_NAME=channel1</pre><pre>#creation of channel1<br>peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel1.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</pre><p>Now we need to join all peers of <strong>channel1</strong>.</p><pre>#Now let’s join peer0.org1.example.com to the channel.</pre><pre>peer channel join -b channel1.block</pre><pre>#Rather than join every peer, we will simply join peer1.org1.example.com in our channel.<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com</a>/msp CORE_PEER_ADDRESS=peer1.org1.example.com:8051 CORE_PEER_LOCALMSPID=&quot;Org1MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt peer channel join -b channel1.block</pre><pre>#Rather than join every peer, we will simply join peer0.org2.example.com so that we can properly update the anchor peer definitions in our channel.</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp CORE_PEER_ADDRESS=peer0.org2.example.com:9051 CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer channel join -b channel1.block</pre><pre>#Rather than join every peer, we will simply join peer1.org2.example.com in our channel.<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp CORE_PEER_ADDRESS=peer1.org2.example.com:10051 CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt peer channel join -b channel1.block</pre><pre>#Rather than join every peer, we will simply join peer0.org3.example.com so that we can properly update the anchor peer definitions in our channel.</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com</a>/msp CORE_PEER_ADDRESS=peer0.org3.example.com:11051 CORE_PEER_LOCALMSPID=&quot;Org3MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt peer channel join -b channel1.block</pre><p>Now we need to update the channel definition to define the anchor peers for <strong>channel1</strong>.</p><pre>#Update the channel definition to define the anchor peer for Org1 as peer0.org1.example.com:</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com</a>/msp CORE_PEER_ADDRESS=peer0.org1.example.com:7051 CORE_PEER_LOCALMSPID=&quot;Org1MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org1MSPanchors_channel1.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</pre><pre>#Now update the channel definition to define the anchor peer for Org2 as peer0.org2.example.com.</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp CORE_PEER_ADDRESS=peer0.org2.example.com:9051 CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org2MSPanchors_channel1.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</pre><pre>#Now update the channel definition to define the anchor peer for Org3 as peer0.org3.example.com.</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com</a>/msp CORE_PEER_ADDRESS=peer0.org3.example.com:11051 CORE_PEER_LOCALMSPID=&quot;Org3MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org3MSPanchors_channel1.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</pre><p>We need to follow the same procedures for <strong>channel2 </strong>and<strong> </strong>all commands are given below:</p><pre>#environment variable for peer0.org2<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org2.example.com:9051<br>CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt</pre><pre>#export channel name<br>export CHANNEL_NAME=channel2</pre><pre>#creation of channel2<br>peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel2.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</pre><pre>#Now let’s join peer0.org1.example.com to the channel.</pre><pre>peer channel join -b channel2.block</pre><pre>#Rather than join every peer, we will simply join peer0.org3.example.com so that we can properly update the anchor peer definitions in our channel.</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com</a>/msp CORE_PEER_ADDRESS=peer0.org3.example.com:11051 CORE_PEER_LOCALMSPID=&quot;Org3MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt peer channel join -b channel2.block</pre><pre>#Now update the channel definition to define the anchor peer for Org2 as peer0.org2.example.com.</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org2MSPanchors_channel2.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</pre><pre>#Now update the channel definition to define the anchor peer for Org3 as peer0.org3.example.com.</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com</a>/msp CORE_PEER_ADDRESS=peer0.org3.example.com:7051 CORE_PEER_LOCALMSPID=&quot;Org3MSP&quot; CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org3MSPanchors_channel2.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem</pre><h3>Step 6</h3><p>We will install two different smart contracts into two channels.</p><p>We will install smart contract ‘<strong>mycc</strong>’ (S1) in <strong>channel1 </strong>and will issue the install<strong> </strong>command against every peer. By using go language the smart contract is written under <strong>home/fabric-samples/chaincode/chaincode_example02 </strong>directory.</p><pre>#Applications interact with the blockchain ledger through chaincode. As such we need to install the chaincode on every peer that will execute and endorse our transactions, and then instantiate the chaincode on the channel.<br>#Modify the following four environment variables to issue the install command against peer0 in Org1:<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org1.example.com:7051<br>CORE_PEER_LOCALMSPID=&quot;Org1MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt</pre><pre># this installs the Go chaincode. For go chaincode -p takes the relative path from $GOPATH/src<br>peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/</pre><pre>#Modify the following four environment variables to issue the install command against peer1 in Org1:<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer1.org1.example.com:8051<br>CORE_PEER_LOCALMSPID=&quot;Org1MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt</pre><pre>#Now install the sample Go chaincode onto a peer1 in Org1<br>peer chaincode install -n mycc -v 1.0 -p  github.com/chaincode/chaincode_example02/go/</pre><pre>#Modify the following four environment variables to issue the install command against peer0 in Org2:</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org2.example.com:9051<br>CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt</pre><pre>#Now install the sample Go chaincode onto a peer0 in Org2<br>peer chaincode install -n mycc -v 1.0 -p  github.com/chaincode/chaincode_example02/go/</pre><pre>#Modify the following four environment variables to issue the install command against peer1 in Org2:</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer1.org2.example.com:10051<br>CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt</pre><pre>#17. Now install the sample Go chaincode onto a peer1 in Org2.</pre><pre>peer chaincode install -n mycc -v 1.0 -p  github.com/chaincode/chaincode_example02/go/</pre><pre>#Modify the following four environment variables to issue the install command against peer0 in Org3:</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org3.example.com:11051<br>CORE_PEER_LOCALMSPID=&quot;Org3MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt</pre><pre>#17.1 Now install the Go chaincode onto a peer0 in Org3.</pre><pre>peer chaincode install -n mycc -v 1.0 -p  github.com/chaincode/chaincode_example02/go/</pre><p>We will install smart contract ‘<strong>marbles</strong>’ (S2) in <strong>channel2 </strong>and will issue the install<strong> </strong>command against every peer. By using go language the smart contract is written under <strong>home/fabric-samples/chaincode/marbles02 </strong>directory.</p><pre>#Modify the following four environment variables to issue the install command against peer0 in Org2:</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org2.example.com:9051<br>CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt</pre><pre>#Now install the sample Go chaincode onto a peer0 in Org2<br>peer chaincode install -n marbles -v 1.0 -p github.com/chaincode/marbles02/go</pre><pre>#Modify the following four environment variables to issue the install command against peer0 in Org3:</pre><pre><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org3.example.com:11051<br>CORE_PEER_LOCALMSPID=&quot;Org3MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt</pre><pre>#Now install the Go chaincode onto a peer0 in Org3.</pre><pre>peer chaincode install -n marbles -v 1.0 -p github.com/chaincode/marbles02/go</pre><p>After installing , we need to instantiate our chaincode.</p><p>To instantiate chaincode <strong>‘mycc’ </strong>(S1) in <strong>channel1 </strong>we need to use follwing commands:</p><pre>#environment variable for peer0.org1<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org1.example.com:7051<br>CORE_PEER_LOCALMSPID=&quot;Org1MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt</pre><pre>#export channel name<br>export CHANNEL_NAME=channel1</pre><pre>#instantiate<br>peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c &#39;{&quot;Args&quot;:[&quot;init&quot;,&quot;a&quot;, &quot;100&quot;, &quot;b&quot;,&quot;200&quot;]}&#39; -P &quot;OR (&#39;Org1MSP.peer&#39;, &#39;Org2MSP.peer&#39;, &#39;Org3MSP.peer&#39;)&quot;</pre><p>To instantiate chaincode <strong>‘marbles’ </strong>(S2) in <strong>channel2 </strong>we need to use follwing commands:</p><pre>#environment variable for peer0.org2<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org2.example.com:9051<br>CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt</pre><pre>#export channel name<br>export CHANNEL_NAME=channel2</pre><pre>#instantiate<br>peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -v 1.0 -c &#39;{&quot;Args&quot;:[&quot;init&quot;]}&#39; -P &quot;OR (&#39;Org2MSP.peer&#39;,&#39;Org3MSP.peer&#39;)&quot;</pre><h3>Step 7</h3><p>We completed all the configarational setup now we are ready to us our network.</p><p>First we try to use <strong>channel1 </strong>by using following commands:</p><pre>#environmental variable for peer0.org1<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org1.example.com:7051<br>CORE_PEER_LOCALMSPID=&quot;Org1MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt</pre><pre>#export channel name<br>export CHANNEL_NAME=channel1</pre><pre>#query<br>peer chaincode query -C $CHANNEL_NAME -n mycc -c &#39;{&quot;Args&quot;:[&quot;query&quot;,&quot;a&quot;]}&#39;<br>peer chaincode query -C $CHANNEL_NAME -n mycc -c &#39;{&quot;Args&quot;:[&quot;query&quot;,&quot;b&quot;]}&#39;</pre><pre>#invoking<br>peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt  -c &#39;{&quot;Args&quot;:[&quot;invoke&quot;,&quot;a&quot;,&quot;b&quot;,&quot;10&quot;]}&#39;</pre><pre>#environmental variable for peer0.org2<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org2.example.com:9051<br>CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt</pre><pre>#export channel name<br>export CHANNEL_NAME=channel1</pre><pre>#query<br>peer chaincode query -C $CHANNEL_NAME -n mycc -c &#39;{&quot;Args&quot;:[&quot;query&quot;,&quot;a&quot;]}&#39;<br>peer chaincode query -C $CHANNEL_NAME -n mycc -c &#39;{&quot;Args&quot;:[&quot;query&quot;,&quot;b&quot;]}&#39;</pre><p>Now we try to use <strong>channel2 </strong>by using following commands:</p><pre>#environmental variable for peer0.org2<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org2.example.com:9051<br>CORE_PEER_LOCALMSPID=&quot;Org2MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt</pre><pre>#export channel name<br>export CHANNEL_NAME=channel2</pre><pre>#invoking<br>peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;initMarble&quot;,&quot;marble2&quot;,&quot;red&quot;,&quot;50&quot;,&quot;tom&quot;]}&#39;</pre><pre>peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;initMarble&quot;,&quot;marble1&quot;,&quot;blue&quot;,&quot;35&quot;,&quot;tom&quot;]}&#39;</pre><pre>peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;initMarble&quot;,&quot;marble3&quot;,&quot;blue&quot;,&quot;70&quot;,&quot;tom&quot;]}&#39;</pre><pre>peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;transferMarble&quot;,&quot;marble2&quot;,&quot;jerry&quot;]}&#39;</pre><pre>peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;transferMarblesBasedOnColor&quot;,&quot;blue&quot;,&quot;jerry&quot;]}&#39;</pre><pre>#environmental variable for peer0.org3<br><a href="/service/mailto:CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com">CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com</a>/msp<br>CORE_PEER_ADDRESS=peer0.org3.example.com:11051<br>CORE_PEER_LOCALMSPID=&quot;Org3MSP&quot;<br>CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt</pre><pre>#export channel name<br>export CHANNEL_NAME=channel2</pre><pre>#invoking &amp; query<br>peer chaincode query -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;readMarble&quot;,&quot;marble2&quot;]}&#39;</pre><pre>peer chaincode query -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;getHistoryForMarble&quot;,&quot;marble1&quot;]}&#39;</pre><pre>peer chaincode query -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;queryMarblesByOwner&quot;,&quot;jerry&quot;]}&#39;</pre><pre>peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c &#39;{&quot;Args&quot;:[&quot;delete&quot;,&quot;marble1&quot;]}&#39;<br></pre><h3>Step 8</h3><p>After finishing it is a good practice to clear all setup by using following commands:</p><pre>#STOP AND DELETE THE DOCKER CONTAINERS<br>docker ps -aq | xargs -n 1 docker stop<br>docker ps -aq | xargs -n 1 docker rm -v</pre><pre>#DELETE THE OLD DOCKER VOLUMES<br>docker volume prune -f<br>#DELETE OLD DOCKER NETWORKS<br>docker network prune -f</pre><pre>#Remove all stopped containers<br>docker container prune -f<br>#Remove All Unused Objects<br>docker system prune -f<br>docker system prune --volumes -f</pre><pre>#DELETE SCRIPT-CREATED FILES<br>rm -rf channel-artifacts/*.block channel-artifacts/*.tx crypto-config</pre><pre>#if you get error in future you may also need to remove docker images using the commands given below:<br>#docker rm -f $(docker ps -aq)<br>#docker rmi -f $(docker images -q)</pre><h3>Summary:</h3><p>In this article we focus to taste all the features of <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/">Hyperledger Fabric v1.4</a> network at minimum configuration. We hope it will be very helpfull for you and if you will face some problems please <a href="https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html#troubleshooting">troubleshooting</a> those.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4275fd9b9d8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/taste-all-the-features-of-hyperledger-fabric-v1-4-4275fd9b9d8e">Taste all the features of Hyperledger Fabric v1.4</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>