You will need to follow the requirements for the IBM Blockchain Platform Extension for VS Code:
- VSCode version 1.26 or greater
- Yeoman (yo) v2.x
- Docker version v17.06.2-ce or greater
- Docker Compose v1.14.0 or greater
- Clone the repo
- Package the smart contract
- Setup network locally and deploy the smart contract
- Run the application
Clone this repository in a folder your choice:
git clone https://github.com/IBM/fabcar-blockchain-sample.git
cd fabcar-blockchain-sample
We will use the IBM Blockchain Platform extension to package the Fabcar smart contract.
-
Open Visual Studio code and open the
contract
folder from this repository that was cloned earlier. -
Press the
F1
key to see the different VS code options. ChooseIBM Blockchain Platform: Package a Smart Contract Project
. -
Click the
IBM Blockchain Platform
extension button on the left. This will show the packaged contracts on top and the blockchain connections on the bottom. -
Next, right click on the packaged contract to export it and choose
Export Package
-
Choose a location on your machine and save
.cds
file. We will use this packages smart contract later to deploy on our work.
-
Click on the overflow menu for
LOCAL FABRIC OPS
, and chooseStart Fabric Runtime
to start a network. This will download the Docker images required for a local Fabric setup, and start the network. Once setup is complete, you should see underLOCAL FABRIC OPS
, options to install and instantiate smart contract, yourChannels
information, your peer underNodes
and the organization msp underOrganizations
. You are now ready to install the smart contract. -
Click on
+Install
underInstalled
dropdown in theLOCAL FABRIC OPS
console. Choose the peer:peer0.org1.example.com
. Choose thefabcar@1.0.0
contract. You should see a notification for successful install of the smart contract, and the smart contract listed underInstalled
in yourLOCAL FABRIC OPS
console. You are now ready to instantiate the smart contract. -
Click on
+Instantiate
underInstantiated
dropdown in theLOCAL FABRIC OPS
console. Choose the channel:mychannel
. Choose thefabcar@1.0.0
contract. Type ininitLedger
for the function. You can press Enter for optional arguments. Once this is successfully instantiated, you should see a successful notification in the output view, and the smart contract listed underInstantiated
in yourLOCAL FABRIC OPS
console.
-
-
First, navigate to the
web-app
directory, and install the node dependencies.cd web-app/server npm install
-
Run the
enrollAdmin.js
scriptnode enrollAdmin.js
-
You should see the following in the terminal:
msg: Successfully enrolled admin user app-admin and imported it into the wallet
-
-
-
Run the
registerUser.js
script.node registerUser.js
-
You should see the following in the terminal:
Successfully registered and enrolled admin user user1 and imported it into the wallet
-
-
-
From the
server
directory, start the server.npm start
-
-
-
In a new terminal, open the web client folder and install the dependencies.
cd web-app/client npm install
-
Start the client:
npm run serve
-
You can find the app running at http://localhost:8080/