IBM has always been a promoter for the blockchain-oriented solution as well as architecture. That’s the reason why IBM launched hyperledger projects in collaboration with Linux. Hyper ledger has chosen a different path from others in the blockchain sector. It primarily concentrates on the private blockchain rather than public. Broadly there exists a misconception about hyper ledger project. Most of the people think its an individual blockchain but in fact, it's a group of blockchain projects which pseudonym a hyper ledger. The most widely used hyperledger project is fabric which is primarily built for enterprise use-cases.
The hyperledger got huge community support and a wide variety of tutorials, but still, developers around the world are struggling to install and instantiate smart contract. In order to make the developer's job a little simple, IBM introduced a package extension for visual studio code ide. The idea behind this package was vs code- it is a widely accepted developer ide. So rather than instantly one by one library in the local system, the IBM blockchain platform package simplifies and does that job in a single click. Today I’m going to explain how fabric can be responsive through vs code.
How to set up Hyperledger Fabric
First of all open vs code and create a directory where you want to clone the hyper ledger fabric images(docker). It may take a while because it will download all necessary docker images for the network to run. Once you finished downloading all docker images, it will generate a folder named ‘fabric-samples inside your directory. Enter into the directory by ‘cd’ command and list out the folder by ‘ls’.
Now select the “Extension” option from the vs code and enter “IBM blockchain platform”,
It will show a bunch of extensions, but please go for the above name and install it
Once you click on the install button you'll be forwarded to an output console and show missing parameters. If you have followed every installation dependency correctly you will not get above window. So install every dependency like nodejs which is required, you can omit the optional dependencies.
If everything got installed perfectly, you will be redirected to new window followed by and new square ico below extension option.
Once you click on the square icon you will get four small box options namely
1. Smart contracts
2. Fabric environments
3. Fabric gateway
4. Fabric wallet
Now click on the “lets blockchain” option which will populate the four square boxes with few options.
Now click on the local fabric option inside the fabric environment which will pull all necessary images and run it as a containers. Once the connection gets successful, you will see a fully populated fabric environment.
Now right click on the smart contract option which will show three options
1. Create project
2. Import project
3. Package open project
As we are new here, click on the create project option which will again show 4 options.
After selecting the path, it will again show three options.
Select the add to workspace option followed by enter, which will generate smart contract in your chosen folder.
Now go through lib folder and open the contract.js file, which will be auto populated by a dummy contract.
Now select the square icon again and click on the install smart contract option,it will show the name of your corresponding folder, all you need to do is just click on the folder name.
Now the contract name will appear under the installed contract list with the name as same as folder name. After successful installation, we have to instantiate the contract.
Click on the instantiate option which will again show the name of the installed smart contract. Just click the enter.
Note: some of the vs code may ask for more questions, just click enter for default choosing.
After successful install and instantiate, the smart contract will appear on the smart contract list as well as on the fabric environment list
Moreover, we have channel options available for private transaction between two parties in the same network. So this is the IBM extension installation for hyperledger fabric. For more details stay tuned.