You are on page 1of 16

Hyperledger Labs: CC-Tools

Build chaincodes better and faster with the CC-Tools Lab


• CTO at GoLedger

• Working with Hyperledger Fabric since 2018

• Certi ed Hyperledger Fabric Administrator (now extinct)

• Exam Developer for the HFCP certi cation https://www.linkedin.com/in/venzi/


https://github.com/samuelvenzi

• Core maintainer of CC-Tools


fi
fi
What is Hyperledger Labs

• Hyperledger Labs encourages innovation in blockchain and distributed


ledger technology

• It hosts diverse experimental projects related to various aspects of


blockchain

• Projects are maintained fully by the community

• Successful projects may integrate into the main Hyperledger ecosystem


What is CC-Tools
• The CC-Tools package provides a relational-like framework for programming
Hyperledger Fabric chaincodes

• CC-Tools implements tools to work with Go chaincodes:

• Assets

• Data types

• Transactions

• Events
A brief history
• When developing, a good practice is to attempt to reuse code

• First working version was called template-cc, in 2019

• In 2020, GoLedger created an external package called CC-Tools


A brief history
• In June 2021, GoLedger released the package as an open-source project
along with an example repository called cc-tools-demo

• CC-Tools was maintained and used in production as a GoLedger project

• In September 2023, CC-Tools was approved as a Hyperledger Labs project


Standard chaincode development

• There are in nite ways one could implement a chaincode

• Usage of hyperledger/fabric-contract-api-go

• At the time CC-Tools got started, chaincodes used hyperledger/fabric-


chaincode-go directly

• Generally, developers will ultimately do a GetState or PutState in a


transaction
fi
Standard chaincode development
hyperledger/fabric-samples
asset := Asset{
ID: id,
Color: color,
Size: size,
Owner: owner,
AppraisedValue: appraisedValue,
}

assetJSON, err := json.Marshal(asset)


if err != nil {
return err
}

return ctx.GetStub().PutState(id, assetJSON)


Standard chaincode development

• Simple chaincodes can be easily implemented the standard way

• Implementing multiple simple chaincodes might present the issue of


copied and pasted code (e.g. validating elds, performing consistency
checks)

• Implementing multiple complex chaincodes can take far too long


fi
How to actually build better and faster
• CC-Tools is the result of 5 years of chaincode building experience at
GoLedger

• The main features observed in our daily development were implemented as


to make the development easier

• Assets are well structured and allow referencing

• Basic CRUD transactions are built-in into the chaincode for every asset

• Custom data types can be extended from primary data types

• Transactions can be customized and leverage a range of CC-Tools functions


Parts of CC-Tools

• The CC-Tools lab project is made of 3 repositories

• hyperledger-labs/cc-tools - core library which is imported to projects

• hyperledger-labs/cc-tools-demo - a template of a working project

• hyperledger-labs/cc-tools-doc - ReadTheDocs for the library


hyperledger-labs/cc-tools-demo
for those who want just to use it

1. The repository structure

2. How assets are de ned

3. How data types are de ned and used

4. How transactions are de ned

5. How it all comes together in the end


fi
fi
fi
hyperledger-labs/cc-tools-demo
extras!

1. Asset permissioning

2. Transaction permissioning

3. Chaincode events

4. Dynamic asset types

5. Automated tests
hyperledger-labs/cc-tools
for those who want to go deeper

1. Assets package

2. Transactions package

3. The StubWrapper

4. Automated tests
How to get involved
1. Hyperledger’s Discord: #cc-tools channel: https://discord.gg/hyperledger

2. GoLedger’s community Discord: https://discord.gg/GndkYHxNyQ

3. Start developing. Check the docs: https://goledger-cc-tools.readthedocs.io/en/


latest/

4. Contribute with issues and PRs on every repository

1. hyperledger-labs/cc-tools

2. hyperledger-labs/cc-tools-demo

3. hyperledger-labs/cc-tools-doc
Thank you!
Questions?

Samuel Venzi, CTO


samuel.venzi@goledger.com.br

You might also like