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

Empty chaincode page

To create and edit chaincode templates, follow these steps:

  1. Navigate to Chaincode Builder: Access the Chaincode Builder from the Main Menu.
  2. 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.

Create chaincode template

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)

Asset details

Click "Create template" to finalize.

Building a New Chaincode Source Code

Build a new chaincode using a template and base chaincode.

Chaincode build page

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 version v1.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.

Chaincode permissions

Base Chaincode

Select a Base Chaincode for building.

Base chaincode selection

Click "Build Chaincode" to proceed.

Uploading Chaincode

Manage chaincode versions and upload source code files.

Uploading Chaincode

Upload chaincode source code files:

  1. Access the "Upload Chaincode" section.
  2. Provide a unique name, version, and upload the chaincode file.

Upload chaincode

Click "Upload chaincode" to proceed.

Chaincode Sharing

Share chaincode with collaborators for collaborative development.

Sharing Chaincode

  1. Access the "Share Chaincode" section.
  2. Provide the email address of the user and select the chaincode.

Share chaincode

Click "Share chaincode" to complete.

Next Steps

Explore the Deploy Chaincode Guide for deploying chaincode to your network.