Hyperledger Fabric Example Created for JAVA.
On Windows 10 you should use the native Docker distribution and you may use the Windows PowerShell. However, for the binaries command to succeed you will still need to have the uname command available. You can get it as part of Git but beware that only the 64bit version is supported.
Before running any git clone commands, run the following commands:
git config --global core.autocrlf false git config --global core.longpaths true You can check the setting of these parameters with the following commands:
git config --get core.autocrlf git config --get core.longpaths These need to be false and true respectively.
- Docker (https://docs.docker.com/get-docker/)
- Visual Studio Code
- Plugins : Required to Run
- Java Extension Pack
- IBM Blockchain Platform
- Open Liberty Tools
- Plugins : To create
- Tools for Microprofile
- Microprofile Starter
- Gradle Language Support
- Gradle Tasks
- Plugins : Required to Run
- Java 11 : for the above plugins
- Java 8 : For the PROJECT** (I flound that the Hyperledger Fabric Java SDK is only stable with Java 8 Version)
- Maven Compiler (https://www.javatpoint.com/how-to-install-maven)
- Gradle Compiler (Only required to create a new Gradle Project)
-
Clone the Git into your workspace (**FOLLOW the WINDOWS 10 Special requirements to avoid any issues)
-
Import the two folders (Chaincode & resp-aoi) seperately into your workspace.
-
Open the IBM Blockchain Platform Plugin and Create a new environment.
- Click create new environment.
- Select "Create new from template".
- Select "1 Org template"
- Give a name for the environment.
- Select Channel Capability version 2.0
- Finally you will be able to see the new environement you created is avalable in the FABRIC ENVIRONMENTS tab.
- Click on the new environment and it will be created. (New Docker Container will run in background.)
-
Package the new chaincode.
- Goto the SMART CONTRACTS tab in the IBM Blockchain Platform plugin.
- Click the three dot icon and select "Package Open Project".** Make sure the Chaincode folder is added to your worksapce.
- Select the Chaincode Project from the drop down menu.
- Select the packaging format "tar.gz"
- Set the name to any name you like. I use "asset"
- Set the version of the package to "0.0.1"
- Once click enter the package will be created and can be seen under SMART CONTRACTS tab.
-
Deploy the new contract into the blockchain.
- Double click on the new environment you've created.
- Once logged into the environment, click "Deploy smart contract" under mychannel.
- The "Deploy Smart Contract" Window will open.
- In the new window select the package you've created before.
- Click NEXT and skip both Step 2 and 3.
- Finally click "Deploy".
-
Test the chaincode deployment is success
-
Create and enroll a new user.
- Goto back to the FABRIC ENVIRONMENT.
- Under Nodes you can find the Org1 Certificate Authority (Org1 CA).
- Right click on it and then click "Create Identity".
- Insert a name (Short name reccomended) Ex. "sachi".
- Select No to add attributes.
- If created successfully, you can find the newly created account under FABRIC WALLETS tab.
-
Deploy the REST API
- Goto the "LIBERTY DEV DASHBOARD" in the explorer.
- If you have already loaded the rest-api folder to your workspace you can find it here.
- Right click on the rest-api liberty project and click "Start"
- This will let Open Liberty Plugin to compile and start the REST API server.
- Once the server started, access the API user interface via http://localhost:9080/openapi/ui
-
Load the Connection settings and wallet to the API in order to access the blockchain.
-
Update the Configuration file and user ID in the REST API code.
-
Test the Functions and Have fun!