This project combines the a basic contract example with the help of conv-rest-api to generate an API server and integrates a browser adapter to make calls to the API.
The project is created with Angular but the same approach can be used with any other framework.
# Install dependencies - From the root of your project
npm i
npm run start
Generate and regenerate the REST Server with conv-rest-api
.
npm i -g @worldsibu/conv-rest-api
# [re]generate the REST server from the api.json file
conv-rest-api generate api -c fabcar -f ./org1.fabcar.config.json
# Start the rest server (remove "npx" if you don't use it)
npx lerna run start --scope server --stream
POST http://localhost:8000/fabcar/init
You can either use CURL if available or a tool like Postman.
curl http://localhost:8000/fabcar/init -H "Content-Type: application/json" --request POST
curl http://localhost:8000/fabcar/queryAll -H "Content-Type: application/json" --request GET
curl http://localhost:8000/fabcar/queryOne/1 -H "Content-Type: application/json" --request GET
POST http://localhost:8000/fabcar/init
GET http://localhost:8000/fabcar/queryAll
GET http://localhost:8000/fabcar/queryOne/1
You may as well install Hurley globally for easier and more flexible management.
npm i -g @worldsibu/hurley
Since with Hurley globally you have control over everything, some things that you can do, for example, is installing a Convector Smart Contract with a different name than the one you used for your project.
# Use the same package
# Install a new chaincode with the same source code but the name 'anothernameforyourcc'
hurl install anothernameforyourcc node
Other complex tasks you may need is installing to a different channel.
# Use the same package
# Be sure you started your environment with more than one channel running 'hurl new --channels 2'. Otherwise this will throw an error.
hurl install anothernameforyourcc node --channel ch2
# Install dependencies - From the root of your project
npm i
# Create a new development blockchain network - From the root of your project
hurl new
# Package your smart contract's code - From the root of your project
npm run cc:package -- fabcar org1
# Install to your blockchain - From the root of your project
hurl install fabcar node -P ./chaincode-fabcar
# Install in debug mode, this will run the chaincode server locally so you can debug
hurl install fabcar node -P ./chaincode-fabcar --debug
# Upgrade your existing chaincode - From the root of your project
hurl upgrade fabcar node 1.2 -P ./chaincode-fabcar
# Install dependencies - From the root of your project
npm i
# Create a new development blockchain network - From the root of your project
npm run env:restart
# Install to your blockchain - From the root of your project
npm run cc:start -- fabcar
# Upgrade your existing chaincode - From the root of your project
npm run cc:upgrade -- fabcar 1.2
npm run test
Check all the information to work with Convector in the DOCS site.