Skip to content

Basic example of how to use cc-tools to easily program a Hyperledger Fabric chaincode.

Notifications You must be signed in to change notification settings

pssilva/cc-tools-demo

 
 

Repository files navigation

Goledger CC Tools Demo Chaincode

Directory Structure

  • /fabric: Fabric network v2.2 used as a test environment
  • /chaincode: chaincode-related files
  • /ccapi: chaincode REST API in Golang project

The following directories are deprecated:

  • /rest-server: chaincode REST API in Node.js project (deprecated)

Development

The cc-tools library has been tested in Fabric v1.4, v2.2 and v2.4 networks.

Dependencies for chaincode and chaincode API:

  • Go 1.14 or higher

Dependencies for test environment:

  • Docker 20.10.5 or higher
  • Docker Compose 1.28.5 or higher
  • Node v8.17.0
  • Node Package Manager (npm) 6.14.11 or higher

Installation if using Chaincode API Node:

$ cd chaincode; go mod vendor; cd ..
$ cd rest-server; npm install; cd ..

Intallation if using Chaincode API Go:

$ cd chaincode; go mod vendor; cd ..
$ cd ccapi; go mod vendor; cd ..

Deploying test env in v2.2

After installing, use the script ./startDev.sh in the root folder to start the development environment. It will start all components of the project with 3 organizations.

If you want to deploy with 1 organization, run the command ./startDev.sh -n 1.

To apply chaincode changes, run $ ./upgradeCC2.sh <version> <sequence> with a version higher than the current one (starts with 0.1). Append -n 1 to the command if running with 1 organization.

To apply CC API changes, run $ ./reloadCCAPI.sh.

Observations for Chaincode API

If you want to deploy the Node.js Chaincode API with the scripts that deploy v2.2 you can uncomment startDev.sh:L31 and comment startDev2.sh:L34:39.

## This brings up API in Node
# cd ./rest-server; ./startDev.sh -n $ORG_QNTY; cd ..

## This brings up API in Go
if [ $ORG_QNTY == 1 ]
then
    cd ./ccapi; docker-compose -f docker-compose-1org.yaml up -d; cd ..
else
    cd ./ccapi; docker-compose up -d; cd ..
fi

Automated tryout and test

To test transactions after starting all components, run $ ./tryout.sh.

To test transactions using the godog tool, run $ ./godog.sh.

More

You can reach GoLedger developers and cc-tools maintainers at our Discord - Join us!

More documentation and details on cc-tools can be found at https://goledger-cc-tools.readthedocs.io/en/latest/

For production deployment please consider using GoFabric - https://gofabric.io

About

Basic example of how to use cc-tools to easily program a Hyperledger Fabric chaincode.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 93.2%
  • Shell 3.2%
  • Go 2.0%
  • TypeScript 1.4%
  • Gherkin 0.2%