Build Chaincode Guide
This tutorial will walk you through creating and managing chaincodes within your GoFabric environment, essential for developing applications on blockchain networks.
Prerequisites
Before you start building a new chaincode, ensure you have already created a channel. If you haven't done so yet, refer to the Channel Guide. To access the Chaincode Builder, go to the Main Menu and select "Chaincode Builder." From there, you can either create a new Chaincode or upload an existing one.
Creating and Editing Chaincode Templates
To create and edit chaincode templates, follow these steps:
- Navigate to Chaincode Builder: Access the Chaincode Builder from the Main Menu.
- Create a New Template: Click on "+ New Template"
Provide the following details:
- Name: Enter the template name.
- Version: Specify the template version.
- Description: Briefly describe the template's purpose.
Click "Next" to proceed.
Asset Properties
Define asset properties for your chaincode:
- Label: Attribute name
- Tag: Unique identifier
- Constraints: Special constraints (e.g., mandatory, primary key)
- Data Type: Data type (e.g., String, Number)
Click "Create template" to finalize.
Building a New Chaincode Source Code
Build a new chaincode using a template and base chaincode.
Define basic details:
- Chaincode Name: Name of the chaincode
- Version: Version of the chaincode
Select a template to build your chaincode. Example:
- Template:
registro-pessoal
with versionv1.0
Permissioning
For each tag of each asset you can define Writers rules according to organizations in Business Group you are a part of. And for each asset type, you can define Readers, creating a private asset accessible only for the selected organizations. Refer to the example below.
Base Chaincode
Select a Base Chaincode for building.
Click "Build Chaincode" to proceed.
Uploading Chaincode
Manage chaincode versions and upload source code files.
Uploading Chaincode
Upload chaincode source code files:
- Access the "Upload Chaincode" section.
- Provide a unique name, version, and upload the chaincode file.
Click "Upload chaincode" to proceed.
Chaincode Sharing
Share chaincode with collaborators for collaborative development.
Sharing Chaincode
- Access the "Share Chaincode" section.
- Provide the email address of the user and select the chaincode.
Click "Share chaincode" to complete.
Next Steps
Explore the Deploy Chaincode Guide for deploying chaincode to your network.