Skip to content

worldsibu/convector-example-fabcar

Repository files navigation

Fabcar example in Convector code

This is a Convector-CLI generated project for Hyperledger Fabric.

It is based on the Fabcar chaincode created in Fabric-samples.

The idea is to showcase how to migrate your mental concepts from Go development to TypeScript based Convector smart contracts.

Prerequisites

Run this project

# Compile everything
npx lerna bootstrap
# Wake yourself up a dev blockchain
npm run env:restart
# Now install the chaincode!
npm run cc:start -- car 1

There is also included a NodeJS backend to make a few REST endpoints available.

# Start the backend
npx lerna run dev:debug --scope myapp --stream

A few API endpoints will be available at http://localhost:300. You can test them out with Postman.

GET localhost:3000/api/v1/examples
GET localhost:3000/api/v1/examples/1
POST localhost:3000/api/v1/examples/
Body
{
 "make":"Volkswagen",
 "model":"Jetta",
 "colour":"gray",
 "owner":"Walter Montes",
 "id":"1"
}

How it was done - Smart Contract

As simple as the example looks like, getting around all the Go code may be confusing, so we made it even easier with the framework's CLI.

# In case you don't have Convector-CLI installed already
npm i -g @worldsibu/convector-cli
conv new fabcar -c car
cd fabcar
npm i

Modify the default ./packages/car-cc/src/car.model.ts. and ./packages/car-cc/src/car.controller.ts., refer to Run this project section.

Learn how to make the smart contract from scratch

A tutorial in Hacker Noon here.

Original smart contract code

You can find the original Go Fabcar example here as well the original NodeJS non-Convector file. That way you can compare how a Convector file helps you build better code.

This examples is provided under an Apache 2.0 license.

About

Convector version of Fabcar official Fabric-Samples codebase

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published