vania-janet/multiturn-rag-retrieval-data huggingface dataset:
Deploy a smart contract using Fabric v1.4 (Deprecated) 

![version 1.4](https://cloud.ibm.com/docs-content/v1/content/c5288bed34c3820e3a5251d820ee91adcd2591a3/blockchain/images/1-4_Pill.png) (Deprecated) Learn how to create and package a smart contract, how to install the smart contract on a peer running a Fabric 1.4 image, and how to instantiate the smart contract on a channel using application capability 1.x.

Target audience: This topic is designed for network operators who are responsible for creating, monitoring, and managing the blockchain network. Additionally, application developers might be interested in the sections that reference how to create a smart contract.

While the terms "smart contract" and "chaincode" are often used interchangeably, "smart contracts" refers to the business logic that governs transactions and access to its data, while "chaincode" refers to the larger infrastructure of packages and other code that encompasses a smart contract.

Smart contracts are installed on peers and then instantiated on channels. All members that want to submit transactions or read data by using a smart contract need to install the contract on their peer. A smart contract is defined by its name and version. Therefore, both the name and version of the installed contract need to be consistent across all peers on the channel that plan to run the smart contract.

After a smart contract is installed on the peers, a single network member instantiates the contract on the channel. The network member needs to have joined the channel in order to perform this action. Instantiation updates the ledger with the initial data that is used by the smart contract, and then starts smart contract pods. The peers can then use the smart contract.



* Only one network member needs to instantiate a smart contract.
* If a peer with a smart contract installed joins a channel where the same smart contract version has already been instantiated, the smart contract container starts automatically.



In this tutorial, we go through the steps to use the IBM Blockchain Platform console to manage the deployment of smart contracts on your network:
Installing from the Cloud Functions CLI 

Install the Natural Language Classifier package from the CLI. Be sure to [install the Cloud Functions plug-in for the IBM Cloud CLI](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-cli_install) first.

To install the Natural Language Classifier package, run the following command.



1. Clone the Natural Language Classifier package repo.

git clone https://github.com/watson-developer-cloud/openwhisk-sdk
2. Deploy the package.

ibmcloud fn deploy -m openwhisk-sdk/packages/natural-language-classifier-v1/manifest.yaml
3. Verify that the package is added to your package list.

ibmcloud fn package list

Example output

packages
/myOrg_mySpace/natural-language-classifier-v1 private
4. Bind the credentials from the Natural Language Classifier instance you created to the package.

ibmcloud fn service bind natural_language_classifier natural-language-classifier-v1

Depending on the region where you created the service instance, the service instance might be named differently because it is an IAM service. If the command fails, use the following service name for the bind command.

ibmcloud fn service bind natural-language-classifier natural-language-classifier-v1

Example output

Credentials 'Credentials-1' from 'natural_language_classifier' service instance 'Watson Natural Language Classifier' bound to 'natural-language-classifier-v1'.
5. Verify that the package is configured with your Natural Language Classifier service instance credentials.

ibmcloud fn package get natural-language-classifier-v1 parameters

Example output

ok: got package natural-language-classifier-v1, displaying field parameters
[
{
"key": "__bx_creds",
"value": {
"natural_language_classifier": {
"credentials": "Credentials-1",
[Opens in a new tab](https://cloud.ibm.com/docs-content/v1/content/images/icons/launch-glyph.svg)](https://www-01.ibm.com/software/passportadvantage/) website. You must run the script on a Linux operating system.
2. Install and authenticate kubectl. For more information, see [Installing the Kubernetes CLI (kubectl)](https://www.ibm.com/support/knowledgecenter/SSFC4F_2.1.0/kubectl/install_kubectl.html).
3. Download and configure the JQ tool by using the following commands:

wget -O jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64

chmod +x ./jq

mv jq /usr/bin

For more information, see [Download jq](https://stedolan.github.io/jq/download/).
4. Copy the automation-navigation-updates.sh script to a directory location. Set the file permissions on the script and run the script to enable navigation to your Infrastructure management instance:

chmod 755 ./automation-navigation-updates.sh

./automation-navigation-updates.sh -i <Infrastructure management URL>



* -i Is a required parameter that refers to the URL for the Infrastructure management console. For example, ./automation-navigation-updates.sh -i https://vm17-im-test.ibm.com/



5. Verify that the Infrastructure management instance is in the IBM Cloud Pak console navigation menu. From the IBM Cloud Pak navigation menu, click Automate infrastructure > Infrastructure management.



Infrastructure management is integrated with the IBM Cloud Pak console.





 Step 8. Create the VM connection for the VM operator 

To use the functional operator ibm-management-infra-vm with Infrastructure management, you must create a Connection CR.
For more information, check out [Step three: Update SDKs and smart contracts](https://cloud.ibm.com/docs/blockchain?topic=blockchain-ibp-console-govern-componentsibp-console-govern-components-upgrade-step-three).



 Upgrading nodes from Fabric v1.4 to v2.2 

Use the following recommended procedure to upgrade your Fabric v1.4 peer and orderer nodes to v2.2, regardless of whether you are also migrating your v1.4 chaincode to run on Fabric v2.2. Once on v2.2, you can migrate your nodes to v2.5.

Attention: To update to Fabric v2.2, the recommended process (below) adds a new peer, rather than updating an existing peer in place. Adding a new peer avoids the extended time to rebuild CouchDB (if applicable) and downtime when an existing peer is updating. The final step then deletes the replaced peer.





 Update your CAs 

Update your Certificate Authority (CA) nodes before you upgrade your peer and orderer nodes, as follows:

Attention: Most application solutions do not interact with CAs continually, in which case CAs can be upgraded with no impact to application usage. However, any application flows that use fabric-ca functionality may be unavailable for 1-2 minutes during the update.



1. Using your console, navigate to your Certificate Authority and select the first CA node. Click on upgrade available and select 1.5.5-2 or later.
2. The CA node will restart with the upgrade installed.
3. Repeat the steps for each CA node.







 Update your orderers 

After updating your Certificate Authority (CA) nodes, update your orderer nodes, as follows:



1. Using your console, navigate to the ordering service and select the first ordering node. Click on upgrade available and select 2.2.10-2 or later. Click through the confirmations dialogs.
2. The node will restart using the 2.2.10-2 (or selected) image. Transaction processing will continue during the node restart, because the remaining four orderer nodes make a quorum.
Onboarding software to your private catalog 

Onboarding your software includes importing a version to your private catalog, configuring the deployment details, setting any license requirements, and validating that the version can be successfully installed on the target infrastructure that you require.



 Before you begin 



1. Upload your source code to a release in your GitHub or GitLab repository. See [Setting up your source code repository](https://cloud.ibm.com/docs/sell?topic=sell-source-repo-setup).
2. Verify that you're using a Pay-As-You-Go or Subscription account. See [Viewing your account type](https://cloud.ibm.com/docs/account?topic=account-account_settingsview-acct-type) for more information.
3. Make sure you're assigned the editor role on the catalog management service. See [Assigning access to account management services](https://cloud.ibm.com/docs/account?topic=account-account-services).
4. Set up the test environment that was previously created for you:





* Install the IBM Cloud CLI and the IBM Cloud Schematics plug-in. See [Setting up the CLI](https://cloud.ibm.com/docs/schematics?topic=schematics-setup-cli).
* Upload a readme file that contains your product installation instructions to your GitHub repository. See [Setting up your source code repository](https://cloud.ibm.com/docs/sell?topic=sell-source-repo-setup).
* For containerized apps:



* Create your [Kubernetes cluster](https://cloud.ibm.com/docs/containers?topic=containers-getting-started) or [Red Hat OpenShift cluster](https://cloud.ibm.com/docs/openshift?topic=openshift-getting-started).
* [Download, modify, and redeploy your Cloud Foundry app with the command-line interface](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-cf-deploy-cli)
* [Creating apps with the Node-RED Starter](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-gettingstarted-nodered)
* [Start coding with Node-RED](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-startNodeRed)



* Developing with buildpacks



* [IBM Cloud Foundry buildpacks](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-available_buildpacks)
* [Using community buildpacks](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-using_buildpacks)
* Liberty for Java



* [Getting started with Liberty for Java](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-getting-started-liberty)
* [Liberty for Java](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-liberty_runtime)
* [Write secure Java web apps](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-secure_java_web_app)
* [Adding certificates to the Liberty keystore](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-cert_liberty_keystore)
* [Configure logging and tracing](https://cloud.ibm.com/docs/cloud-foundry-public?topic=cloud-foundry-public-logging_tracing)
Set the app directory
as the working directory
WORKDIR /cf-py/
COPY . .

Install any requirements that are defined
RUN pip install --no-cache-dir -r requirements.txt

Update the openssl package
RUN apt-get update && apt-get install -y 
openssl

Start the app.
CMD ["python", "welcome.py"]
Show more
3. Save your changes in the nano editor by pressing ctrl + o. Confirm your changes by pressing enter. Exit the nano editor by pressing ctrl + x.
4. Build a Docker image that includes your app code and push it to your private registry.

docker build -t <region>.icr.io/namespace/cf-py .



Table 1. Understanding this command's components

 Option Description 

 build The build command. 
 -t registry.<region>.icr.io/namespace/cf-py Your private registry path, which includes your unique namespace and the name of the image. For this example, the same name is used for the image as the app directory, but you can choose any name for the image in your private registry. If you are unsure what your namespace is, run the ibmcloud cr namespaces command to find it. 
 . The location of the Dockerfile. If you are running the build command from the directory that includes the Dockerfile, enter a period (.). Otherwise, use the relative path to the Dockerfile. 



The image is created in your private registry. You can run the ibmcloud cr images command to verify that the image was created.

REPOSITORY NAMESPACE TAG DIGEST CREATED SIZE VULNERABILITY STATUS
us.icr.io/namespace/cf-py namespace latest cb03170b2cb2 3 minutes ago 271 MB OK







 Step 3: Deploy a container from your image 

Deploy your app as a container in a Kubernetes cluster.



1.
For example, copy the following code example into a file called main.js.

function main(args) {
const oneLinerJoke = require('one-liner-joke');
let getRandomJoke = oneLinerJoke.getRandomJoke();

return {
headers: { 'Content-Type': 'text/plain;charset=utf-8' },
body: getRandomJoke
}
}

module.exports.main = main;
2. Create a package.json file that contains the required dependencies for your Function. For the previous code example, use the following contents for your package.json file.

{
"main": "main.js",
"dependencies" : {
"one-liner-joke" : "1.2.2"
}
}
3. Create your files as a Function in Code Engine. In this case, you are in the directory where the local files exist so you can use . as the build source.

ibmcloud ce fn create -n nodejokes -runtime nodejs-18 --build-source .
4. Invoke your Function by pasting the provided URL into a web browser. Your browser displays a random joke!



For more information about the fn create command and its options, see [Create a Function](https://cloud.ibm.com/docs/codeengine?topic=codeengine-clicli-function-create).





 Including modules for a Python Function 

Create a function that includes a dependency for a specific Python module by creating a requirements.txt file. In this case, both the source code and requirements file are located in the same folder.



1. Create your Function by saving your code into a __main__.py file

import pyjokes
def main(params):
return {
"headers": { 'Content-Type': 'text/plain;charset=utf-8' },
Your app is deployed to IBM Cloud automatically when you commit changes in the code. You do not need to push the app manually. 
 IBM Cloud DevOps Delivery Pipeline Manage your code on DevOps GitHub repository and deploy your app to IBM Cloud by using the DevOps Delivery Pipeline. 



If the Cloud Foundry platform does not support your app requirements, you can use a container or VM where the runtime is set up, configured, and maintained with more customized options.





 Developing and deploying your apps using toolchains in Continuous Delivery 

Add a [toolchain to your app](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-toolchains_getting_startedcreating_a_toolchain_from_an_app) and then use the [Continuous Delivery toolchain UI](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-toolchains-using) to develop and deploy your app.





 Uploading your apps by using ibmcloud cf cli 

You can manage your code on local client and use Cloud Foundry command line interface to upload your app to IBM Cloud manually. If you change the code, you must push your app to IBM Cloud again to run the updated code.

Take the following steps to migrate your app:

Install the Cloud Foundry command line interface. Ensure that you use the latest version of the ibmcloud cf command line interface.



1. Download the installation program for your operating system.
2. Follow the tool wizard to install the command line.
3. Use the following command to verify the version of the ibmcloud cf command line interface: ibmcloud cf -v



Optional: If you want to specify and save the deployment details before you push an app to IBM Cloud, you can add the app manifest by taking the following steps:



1. Go to the working directory of your app and create a file entitled manifest.yml, which is the default name.
2. Specify deployment details in the manifest file. The following example shows a manifest file for a Java™ app.

applications:
- disk_quota: 1024M
host: myjavatest
To install the latest CLI for your OS from the shell manually, use the following command for your OS:

If you don't want to install from the shell because it might use root permissions, you can [download and run the installer](https://cloud.ibm.com/docs/cli?topic=cli-cli-private-endpointscli-private-endpoints-download).



* For Mac, copy and paste the following command to a command line and run it:

curl -fsSL https://ibm-cloud-cli-installer-scripts.s3.private.us.cloud-object-storage.appdomain.cloud/osx_private | sh
* For Linux™, copy and paste the following command to a command line and run it:

curl -fsSL https://ibm-cloud-cli-installer-scripts.s3.private.us.cloud-object-storage.appdomain.cloud/linux_private | sh
* For Windows™, copy and paste the following command to a [Windows™ PowerShell](https://msdn.microsoft.com/en-us/powershell/scripting/getting-started/getting-started-with-windows-powershell) command prompt and run it:

iex (New-Object Net.WebClient).DownloadString('https://ibm-cloud-cli-installer-scripts.s3.private.us.cloud-object-storage.appdomain.cloud/powershell_private')

If you encounter errors like The underlying connection was closed: An unexpected error occurred on a send, make sure you have .Net Framework 4.5 or later installed. Also, try to enable TLS 1.2 protocol by running the following command:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12







 Downloading installation packages with private endpoints 

Use the following steps to install the latest stand-alone IBM Cloud CLI:



1. Select the installer of your OS to begin the download.
* [Including modules for a Node.js Function](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-repofunction-nodejs-dep-repo)
* [Including modules for a Python Function](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-repofunction-python-dep-repo)



* [Next steps](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-reponextsteps-funsource)



[Creating Function workloads from local source code](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-localfun-create-local)



* [Creating a function from local source code with the CLI](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-localfun-create-local-cli)
* [Including dependencies for your Function](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-localfun-package-local)



* [Including modules for a Node.js Function](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-localfunction-nodejs-dep-local)
* [Including modules for a Python Function](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-localfunction-python-dep-local)



* [Next steps](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-create-localnextsteps-funruncr)



[Runtimes](https://cloud.ibm.com/docs/codeengine?topic=codeengine-fun-runtimefun-runtime)
[Image showing applicationApiKey.json download](https://cloud.ibm.com/docs-content/v1/content/3a120b16db5fdc3e70d071af8a63ce5515c1b096/mqcloud/images/mqoc_app_ams_app_apikey.png)
6. Now click on Add and fill in the form as shown in the image below for user bob:
6.1 In the Display name: field of the form, enter the value as bob. 6.2 In the Application username: field of the form, bob will be automatically populated. 6.2 Click on Add and generate API key.
![Image showing application permissions currently set](https://cloud.ibm.com/docs-content/v1/content/3a120b16db5fdc3e70d071af8a63ce5515c1b096/mqcloud/images/mqoc_app_ams_bob.png)
7. Once the user is added, a new apiKey will be generated and shown in the pop-up window. Click on Download to download the applicationApiKey.json, save the file as "applicationApiKey<username>.json (for ex:"applicationApiKeybob.json) to a convenient location.
![Image showing "applicationApiKey.json download](https://cloud.ibm.com/docs-content/v1/content/3a120b16db5fdc3e70d071af8a63ce5515c1b096/mqcloud/images/mqoc_app_ams_app_apikey.png)





 Send and Receive Message before configuring AMS 

As a first step of the AMS configuration, we can check if alice and bob are able to send and receive messages. This would help us to make sure that the client and the queue manager are able to communicate and exchange messages.
[Learn more](https://cloud.ibm.com/docs/openshift?topic=openshift-openshift_apps) or [create an OpenShift cluster](https://cloud.ibm.com/kubernetes/overview). 
 IBM Cloud® Code Engine Ensure that you have either a Pay-As-You-Go account or a Subscription account to use Code Engine as your deployment target. If you are using a free Lite account, upgrade it before you use Code Engine. [Learn more about accounts.](https://cloud.ibm.com/docs/account) 







 View previously created apps 

You can view previously created apps from the [IBM Cloud Resource List](https://cloud.ibm.com/resources). From the IBM Cloud console, select the ![Navigation Menu icon](https://cloud.ibm.com/docs-content/v1/content/efbf7b33e3aca029f69f9244bced9dd4d8acb848/icons/icon_hamburger.svg) > Resource list. Then, expand the Developer tools category.





 Select an option for creating and deploying apps 

Several options are available for you to create and deploy apps on IBM Cloud. You can use any of the following entry points to learn more.



* IBM Cloud® Continuous Delivery uses DevOps toolchain templates to help you create and deploy apps. For more information, see [Toolchain availability, templates, and tutorials](https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-cd_about). You can find several DevOps-based tutorials in the “Tutorials” section of the [Continuous Delivery docs](https://cloud.ibm.com/docs/ContinuousDelivery).
* [Set up continuous deployment with Schematics and DevOps toolchain](https://cloud.ibm.com/schematics?topic=schematics-workspace-continuous-deployment).
If your source repository is not public, you must add [access to Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-code-repositories).

Local workstation
: Store your code on your local workstation. When you submit a build that pulls code from a local directory, your source code is packed into an archive file and uploaded to your IBM Cloud Container Registry instance. The source image is created in the same namespace as your build image. Note that you can target only IBM Cloud Container Registry for your local builds. You can choose to ignore certain file patterns from within your source code by using the .ceignore file, which behaves similarly to a .gitignore file. For example, entries for a .ceignore file for a node.js application might include node_modules and .npm. For more sample file patterns to ignore, see the [GitHub .gitignore repository](https://github.com/github/gitignore).





 Choose a build strategy 

Code Engine can build your container image by using one of following strategies.



 Dockerfile 

[Dockerfile](https://docs.docker.com/engine/reference/builder/) build that uses the [BuildKit](https://github.com/moby/buildkit) tool. To use this strategy, add a Dockerfile to your source repository. This Dockerfile describes the steps that are needed to build a container image from your source repository. The Dockerfile might contain steps that copy static files from your sources into the container to be hosted by a web service, for example. It might compile source code that is written in the language of your choice and add the resulting binary to your container image. For more information about Dockerfile builds, see [Writing a Dockerfile for Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-dockerfile).