Catalyst Blockchain Manager
Hyperledger Fabric Service 2.4.0
Search
⌃K
Links

Creating Your First Application

Catalyst Blockchain Platform consists of two components: smart contracts (chaincodes) deployed in the Catalyst Blockchain Platform Hyperledger Fabric service and the custom program portion, which will communicate with the Catalyst Blockchain Platform Hyperledger Fabric service.

Writing Simple “Hello World” Chaincode

Catalyst Blockchain Platform runs chaincodes as external services, meaning that this must be considered during deployment.
A detailed guide on how to write external chaincode can be found in the official Hyperledger Fabric documentation.
Here, we will be using an already created simple “Hello World” chaincode example written in Go to show specific details of how to run smart contracts in Catalyst Blockchain Platform.
The source code of this chaincode can be found following the link.
The key part of this example chaincode is the function where its server starts:
func main() {
ccid := os.Getenv("CHAINCODE_ID")
address := os.Getenv("CHAINCODE_ADDRESS")
server := &shim.ChaincodeServer{
CCID: ccid,
Address: address,
CC: &HelloWorld{},
TLSProps: shim.TLSProperties{
Disabled: true,
},
}
if err := server.Start(); err != nil {
fmt.Printf("Error starting HelloWorld chaincode: %s", err)
}
}
To run chaincode in Catalyst Blockchain Platform, you need to set CCID and Address fields of shim.ChaincodeServer as environment variables CHAINCODE_ID and CHAINCODE_ADDRESS, respectively. These two environment variables will be passed during the creation of the chaincode external service, CHAINCODE_IDmatches chaincode package id after its installation on a peer and CHAINCODE_ADDRESS is the listen address of a chaincode server that was used to build the chaincode server endpoint accessible from a peer in connection.json.

Communication with Catalyst Blockchain Platform

There are two ways to communicate with Catalyst Blockchain Platform: Hyperledger Fabric SDK and Catalyst Blockchain Platform API.

Hyperledger Fabric SDK

There are many different Hyperledger Fabric resources and guides on configuring the SDK for interaction with Hyperledger Fabric, and these can be utilized as well.
To complete SDK integration with Catalyst Blockchain Platform:
1. Register a client signing identity and TLS identity for the business application on behalf of your Catalyst Blockchain Platform user.
You can do that on the Catalyst Blockchain Platform UI in the CA tab. Information about how to register an identity can be found here.
2. Enroll the registered identities through SDK CA client from your business application or Hyperledger Fabric CA Client in CLI.
SDK method allows you to fully integrate with Catalyst Blockchain Platform Hyperledger Fabric service and interact with all network components. However, this method is complicated. Instead of using Hyperledger Fabric SDK, you can use Catalyst Blockchain Platform API.

Catalyst Blockchain Platform API

For communication between your business application and a chaincode, Catalyst Blockchain Platform provides you with an API to invoke, query deployed chaincodes, and subscribe for chaincode's events.
Endpoints and required parameters are listed here.