Coder Social home page Coder Social logo

akoita / start-with-convector Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 296 KB

This project was created as part of a tutorial on Convector, the TypeScript framework for creating Hyperledger Fabric applications.

Home Page: https://medium.com/@aboubakarkoita/develop-a-hyperledger-fabric-application-with-convector-suite-1a2fa8f01011

License: MIT License

TypeScript 95.09% JavaScript 4.91%
blockchain hyperledger-fabric convector smart-contracts

start-with-convector's Introduction

Start with Convector

This project was created as part of a tutorial on Convector, the TypeScript framework for creating Hyperledger Fabric applications.

The project is composed of two chaincode packages, packages/participant-cc and packages/asset-cc. It allows organizations to create and share assets associated with participants as owners.

For more information on the context, see the tutorial page.

To install and test the project, follow the following steps.

Install and test the project

To install and test the project, you must clone the repo and follow the following instructions.

Prerequisites

  • Operating system: The project has been tested on ubuntu desktop 16.0 64-bits, but it should work in any environment that supports Fabric and Convector.
  • Node.js: Version 8.14.1. But other versions can work.
  • Docker: 18.09.5
  • Docker-compose: 1.23.1

Install npm dependencies

While in the project directory, install the dependencies:

npm i

And start the unit tests:

npm test

Create a Hyperledger Fabric development network with Hurley

Hurley is a toolset of the Convector Suite that facilitates the management of a Fabric development environment. The first creation of a Fabric network will take time because it will start downloading docker images:

npm i -g @worldsibu/hurley
hurl new

Build and deploy the chaincode in the Fabric network

The following command will build the deployment package of the chaincode and deploy it in the Fabric network:

npm run cc:start -- asset

Invoke the deployed chaincode

Some invocations that can be made on the chaincode.

Create and request participants

Note that the first invocation will take time because it will cause the instantiation of the chaincode. The following invocations will be much faster.

# create two participants
hurl invoke asset participant_register ptcp1 Damien
hurl invoke asset participant_register ptcp2 Booba

# request the participants by their id
hurl invoke asset participant_getParticipantById ptcp1
hurl invoke asset participant_getParticipantById ptcp2

Create and request assets

Create assets owned by previously created participants:

ASSET1_PARAMS='{"id":"as1","ownerId":"ptcp1","value":"Asset1Value","name":"Asset1Name"}'
ASSET2_PARAMS='{"id":"as2","ownerId":"ptcp1","value":"Asset2Value","name":"Asset2Name"}'
ASSET3_PARAMS='{"id":"as3","ownerId":"ptcp2","value":"Asset3Value","name":"Asset3Name"}'
ASSET4_PARAMS='{"id":"as4","ownerId":"ptcp2","value":"Asset4Value","name":"Asset4Name"}'

hurl invoke asset asset_createAsset $ASSET1_PARAMS
hurl invoke asset asset_createAsset $ASSET2_PARAMS
hurl invoke asset asset_createAsset $ASSET3_PARAMS
hurl invoke asset asset_createAsset $ASSET4_PARAMS

Request the list of open and closed assets:

# list of open assets (must return now the list of all assets)
hurl invoke asset asset_getAllOpenAsset

# list of closed assets (must return now an empty list)
hurl invoke asset asset_getAllClosedAsset

Let's close some assets:

hurl invoke asset asset_closeAsset as1
hurl invoke asset asset_closeAsset as2

Request again the list of open and closed assets:

# list of open assets (must return now the assets as3 and as4)
hurl invoke asset asset_getAllOpenAsset

# list of closed assets (must return now the assets as1 and as2)
hurl invoke asset asset_getAllClosedAsset

Troubleshooting

In case of unexpected errors, you can reset the Fabric environment by starting from scratch:

hurl clean; hurl new

start-with-convector's People

Contributors

akoita avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.