Development Preparation
A chaincode, also called a smart contract, is a program written in Go or Node.js for operating the ledger. It is a code logic that runs on a blockchain and is automatically executed under specific conditions. Chaincodes are an important method for users to implement service logic when using blockchains. Due to the blockchain features, the execution results of smart contracts are reliable and cannot be forged or tampered with.
To use BCS, you must develop your own chaincodes and applications. Applications invoke chaincodes through peers in the blockchain network, and the chaincodes operate ledger data through peers.
Preparing the Development Environment
- Install the Go development environment. Download the installation package from https://golang.org/dl/. (Select a version later than 1.9.2.)
The package name for each OS is as follows (version 1.11.12 is used as an example):
OS
Package
Windows
go1.11.12.windows-amd64.msi
Linux
go1.11.12.linux-amd64.tar.gz
- In Windows, you can use the .msi installation package for installation. By default, the .msi file is installed in C:\Go. You can add the C:\Go\bin directory to the Path environment variable. Restart the CLI for the settings to take effect.
- In Linux, decompress the downloaded binary package to the /usr/local directory. Add the /usr/local/go/bin directory to the Path environment variable.
export PATH=$PATH:/usr/local/go/bin
After Golang is installed, you can run the go version command to view the version information and run the go env command to view the path configuration.
- Install a Go editor of your choice. GoLand is recommended.
Downloading the Source Code Package
Download the Fabric source code package as the third-party repository.
Download the required version from the following addresses:
https://github.com/hyperledger/fabric/tree/release-2.2
The version of the Fabric package should match that of the blockchain. For example, if a blockchain is v4.x.x, it uses Fabric v2.2, so you need to download the Fabric v2.2 package.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot